2008-04-20 23:46:47 +02:00
|
|
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Copyright (C) 2008 Jonathan Moore Liles */
|
|
|
|
|
/* */
|
|
|
|
|
/* This program is free software; you can redistribute it and/or modify it */
|
|
|
|
|
/* under the terms of the GNU General Public License as published by the */
|
|
|
|
|
/* Free Software Foundation; either version 2 of the License, or (at your */
|
|
|
|
|
/* option) any later version. */
|
|
|
|
|
/* */
|
|
|
|
|
/* This program is distributed in the hope that it will be useful, but WITHOUT */
|
|
|
|
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
|
|
|
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */
|
|
|
|
|
/* more details. */
|
|
|
|
|
/* */
|
|
|
|
|
/* You should have received a copy of the GNU General Public License along */
|
|
|
|
|
/* with This program; see the file COPYING. If not,write to the Free Software */
|
|
|
|
|
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
2010-01-30 17:58:59 +01:00
|
|
|
|
#include "const.h"
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
2008-04-28 20:17:46 +02:00
|
|
|
|
#include <FL/fl_ask.H>
|
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
|
#include "Control_Sequence.H"
|
|
|
|
|
#include "Track.H"
|
2008-04-28 16:20:17 +02:00
|
|
|
|
|
2008-05-26 08:20:49 +02:00
|
|
|
|
#include "Engine/Engine.H" // for lock()
|
2008-05-26 21:39:50 +02:00
|
|
|
|
|
2008-06-18 06:01:22 +02:00
|
|
|
|
#include <list>
|
|
|
|
|
using std::list;
|
|
|
|
|
|
2012-02-21 09:48:13 +01:00
|
|
|
|
#include "Transport.H"
|
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
#include "OSC/Endpoint.H"
|
|
|
|
|
|
2012-06-05 07:58:57 +02:00
|
|
|
|
#include "string_util.h"
|
|
|
|
|
|
2008-05-26 21:39:50 +02:00
|
|
|
|
|
2008-04-28 16:20:17 +02:00
|
|
|
|
|
2008-04-22 02:45:17 +02:00
|
|
|
|
bool Control_Sequence::draw_with_grid = true;
|
2012-10-25 09:25:23 +02:00
|
|
|
|
bool Control_Sequence::draw_with_polygon = true;
|
2008-04-21 05:05:25 +02:00
|
|
|
|
|
2008-05-26 21:39:50 +02:00
|
|
|
|
|
|
|
|
|
|
2008-05-05 07:29:39 +02:00
|
|
|
|
Control_Sequence::Control_Sequence ( Track *track ) : Sequence( 0 )
|
2008-04-21 05:05:25 +02:00
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
|
|
|
|
|
_track = track;
|
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
mode( OSC );
|
2012-04-27 19:14:53 +02:00
|
|
|
|
|
2008-04-21 05:05:25 +02:00
|
|
|
|
if ( track )
|
|
|
|
|
track->add( this );
|
|
|
|
|
|
|
|
|
|
log_create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Control_Sequence::~Control_Sequence ( )
|
|
|
|
|
{
|
2012-02-24 10:59:26 +01:00
|
|
|
|
// Fl::remove_timeout( &Control_Sequence::process_osc, this );
|
2008-06-06 06:14:00 +02:00
|
|
|
|
|
|
|
|
|
Loggable::block_start();
|
|
|
|
|
|
|
|
|
|
clear();
|
|
|
|
|
|
2008-04-21 05:05:25 +02:00
|
|
|
|
log_destroy();
|
2008-05-22 09:05:49 +02:00
|
|
|
|
|
2008-05-26 08:20:49 +02:00
|
|
|
|
engine->lock();
|
|
|
|
|
|
|
|
|
|
track()->remove( this );
|
|
|
|
|
|
|
|
|
|
engine->unlock();
|
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
if ( _output )
|
|
|
|
|
{
|
|
|
|
|
_output->shutdown();
|
2012-02-24 12:52:57 +01:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
delete _output;
|
2012-02-24 12:52:57 +01:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
_output = NULL;
|
|
|
|
|
}
|
2012-02-24 12:52:57 +01:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
if ( _osc_output )
|
|
|
|
|
{
|
|
|
|
|
delete _osc_output;
|
|
|
|
|
|
|
|
|
|
_osc_output = NULL;
|
|
|
|
|
}
|
2012-02-24 12:52:57 +01:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
for ( list<char*>::iterator i = _persistent_osc_connections.begin();
|
|
|
|
|
i != _persistent_osc_connections.end();
|
|
|
|
|
++i )
|
|
|
|
|
{
|
|
|
|
|
free( *i );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_persistent_osc_connections.clear();
|
2012-02-24 12:52:57 +01:00
|
|
|
|
|
2008-06-06 06:14:00 +02:00
|
|
|
|
Loggable::block_end();
|
2008-04-21 05:05:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Control_Sequence::init ( void )
|
|
|
|
|
{
|
|
|
|
|
_track = NULL;
|
2008-04-25 05:29:28 +02:00
|
|
|
|
_highlighted = false;
|
2008-04-28 21:04:16 +02:00
|
|
|
|
_output = NULL;
|
2012-02-21 09:48:13 +01:00
|
|
|
|
_osc_output = NULL;
|
2012-06-10 04:51:02 +02:00
|
|
|
|
_mode = (Mode)-1;
|
2012-02-21 09:48:13 +01:00
|
|
|
|
|
2012-02-24 09:59:39 +01:00
|
|
|
|
interpolation( Linear );
|
2008-04-21 05:05:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-05-26 21:39:50 +02:00
|
|
|
|
|
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
|
void
|
2008-04-25 08:34:08 +02:00
|
|
|
|
Control_Sequence::get ( Log_Entry &e ) const
|
2008-04-20 23:46:47 +02:00
|
|
|
|
{
|
2008-05-07 17:28:57 +02:00
|
|
|
|
e.add( ":track", _track );
|
|
|
|
|
e.add( ":name", name() );
|
2008-04-20 23:46:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
void
|
|
|
|
|
Control_Sequence::get_unjournaled ( Log_Entry &e ) const
|
|
|
|
|
{
|
|
|
|
|
e.add( ":interpolation", _interpolation );
|
2012-02-26 03:01:46 +01:00
|
|
|
|
|
|
|
|
|
if ( _osc_output && _osc_output->connected() )
|
2012-02-24 09:59:39 +01:00
|
|
|
|
{
|
2012-02-26 03:01:46 +01:00
|
|
|
|
DMESSAGE( "OSC Output connections: %i", _osc_output->noutput_connections() );
|
|
|
|
|
|
|
|
|
|
for ( int i = 0; i < _osc_output->noutput_connections(); ++i )
|
|
|
|
|
{
|
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
|
|
s = _osc_output->get_output_connection_peer_name_and_path(i);
|
|
|
|
|
|
|
|
|
|
e.add( ":osc-output", s );
|
2012-02-25 05:23:45 +01:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
free( s );
|
|
|
|
|
}
|
2012-02-24 09:59:39 +01:00
|
|
|
|
}
|
2012-02-26 03:01:46 +01:00
|
|
|
|
|
|
|
|
|
e.add( ":mode", mode() );
|
2012-02-24 05:53:51 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
|
void
|
|
|
|
|
Control_Sequence::set ( Log_Entry &e )
|
|
|
|
|
{
|
|
|
|
|
for ( int i = 0; i < e.size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
const char *s, *v;
|
|
|
|
|
|
|
|
|
|
e.get( i, &s, &v );
|
|
|
|
|
|
2008-05-07 17:28:57 +02:00
|
|
|
|
if ( ! strcmp( ":track", s ) )
|
2008-04-20 23:46:47 +02:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
sscanf( v, "%X", &i );
|
|
|
|
|
Track *t = (Track*)Loggable::find( i );
|
|
|
|
|
|
|
|
|
|
assert( t );
|
|
|
|
|
|
2010-01-17 01:38:27 +01:00
|
|
|
|
_output = new JACK::Port( engine, JACK::Port::Output, t->name(), t->ncontrols(), "cv" );
|
2008-05-22 09:05:49 +02:00
|
|
|
|
|
2010-01-30 17:58:59 +01:00
|
|
|
|
if ( ! _output->activate() )
|
|
|
|
|
{
|
|
|
|
|
FATAL( "could not create JACK port" );
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
|
t->add( this );
|
|
|
|
|
}
|
2008-05-07 17:28:57 +02:00
|
|
|
|
else if ( ! strcmp( ":name", s ) )
|
2012-02-25 05:23:45 +01:00
|
|
|
|
{
|
2008-05-07 04:32:37 +02:00
|
|
|
|
name( v );
|
2012-02-25 05:23:45 +01:00
|
|
|
|
}
|
2012-02-24 05:53:51 +01:00
|
|
|
|
else if ( ! strcmp( ":interpolation", s ) )
|
2012-02-25 05:23:45 +01:00
|
|
|
|
{
|
2012-02-26 03:01:46 +01:00
|
|
|
|
interpolation( (Curve_Type)atoi( v ) );
|
|
|
|
|
}
|
|
|
|
|
else if ( ! strcmp( ":mode", s ) )
|
|
|
|
|
mode( (Mode)atoi( v ) );
|
|
|
|
|
else if ( ! strcmp( ":osc-output", s ) )
|
|
|
|
|
{
|
|
|
|
|
_persistent_osc_connections.push_back( strdup( v ) );
|
2012-02-25 05:23:45 +01:00
|
|
|
|
}
|
2012-02-26 03:01:46 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Control_Sequence::mode ( Mode m )
|
|
|
|
|
{
|
|
|
|
|
if ( CV != m && mode() == CV )
|
|
|
|
|
{
|
|
|
|
|
if ( _output )
|
2012-02-24 09:59:39 +01:00
|
|
|
|
{
|
2012-02-26 03:01:46 +01:00
|
|
|
|
_output->shutdown();
|
|
|
|
|
|
|
|
|
|
delete _output;
|
|
|
|
|
|
|
|
|
|
_output = NULL;
|
2012-02-24 09:59:39 +01:00
|
|
|
|
}
|
2012-02-26 03:01:46 +01:00
|
|
|
|
}
|
|
|
|
|
else if ( OSC != m && mode() == OSC )
|
|
|
|
|
{
|
|
|
|
|
if ( _osc_output )
|
|
|
|
|
{
|
|
|
|
|
delete _osc_output;
|
|
|
|
|
|
|
|
|
|
_osc_output = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( CV == m && mode() != CV )
|
|
|
|
|
{
|
|
|
|
|
_output = new JACK::Port( engine, JACK::Port::Output, track()->name(), track()->ncontrols(), "cv" );
|
|
|
|
|
|
|
|
|
|
if ( ! _output->activate() )
|
2012-02-24 09:59:39 +01:00
|
|
|
|
{
|
2012-02-26 03:01:46 +01:00
|
|
|
|
fl_alert( "Could not create JACK port for control output on %s", track()->name() );
|
|
|
|
|
delete _output;
|
|
|
|
|
_output = NULL;
|
2012-02-24 09:59:39 +01:00
|
|
|
|
}
|
2008-04-20 23:46:47 +02:00
|
|
|
|
}
|
2012-02-26 03:01:46 +01:00
|
|
|
|
else if ( OSC == m && mode() != OSC )
|
|
|
|
|
{
|
|
|
|
|
char *path;
|
|
|
|
|
asprintf( &path, "/track/%s/control/%i", track()->name(), track()->ncontrols() );
|
2012-06-05 07:58:57 +02:00
|
|
|
|
|
|
|
|
|
char *s = escape_url( path );
|
|
|
|
|
|
|
|
|
|
free( path );
|
|
|
|
|
|
|
|
|
|
path = s;
|
2012-02-26 03:01:46 +01:00
|
|
|
|
|
2012-02-27 03:47:07 +01:00
|
|
|
|
_osc_output = timeline->osc->add_signal( path, OSC::Signal::Output, 0, 1, 0, NULL, NULL );
|
2012-02-26 03:01:46 +01:00
|
|
|
|
|
|
|
|
|
free( path );
|
|
|
|
|
|
|
|
|
|
connect_osc();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_mode = m;
|
2008-04-20 23:46:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-23 17:41:35 +02:00
|
|
|
|
void
|
2012-10-25 09:25:23 +02:00
|
|
|
|
Control_Sequence::draw_curve ( bool filled )
|
2008-04-23 17:41:35 +02:00
|
|
|
|
{
|
|
|
|
|
const int bx = x();
|
|
|
|
|
const int by = y() + Fl::box_dy( box() );
|
|
|
|
|
const int bw = w();
|
|
|
|
|
const int bh = h() - Fl::box_dh( box() );
|
|
|
|
|
|
|
|
|
|
list <Sequence_Widget *>::const_iterator e = _widgets.end();
|
|
|
|
|
e--;
|
|
|
|
|
|
|
|
|
|
if ( _widgets.size() )
|
|
|
|
|
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); ; r++ )
|
|
|
|
|
{
|
|
|
|
|
const int ry = (*r)->y();
|
|
|
|
|
|
|
|
|
|
if ( r == _widgets.begin() )
|
|
|
|
|
{
|
2012-10-25 09:25:23 +02:00
|
|
|
|
if ( filled )
|
|
|
|
|
fl_vertex( bx, bh + by );
|
|
|
|
|
fl_vertex( bx, ry );
|
2008-04-23 17:41:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-27 07:11:00 +02:00
|
|
|
|
fl_vertex( (*r)->line_x(), ry );
|
2008-04-23 17:41:35 +02:00
|
|
|
|
|
|
|
|
|
if ( r == e )
|
|
|
|
|
{
|
2012-10-25 09:25:23 +02:00
|
|
|
|
fl_vertex( bx + bw, ry );
|
|
|
|
|
if ( filled )
|
|
|
|
|
fl_vertex( bx + bw, bh + by );
|
2008-04-23 17:41:35 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-04-25 05:29:28 +02:00
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
|
void
|
|
|
|
|
Control_Sequence::draw ( void )
|
|
|
|
|
{
|
2012-06-07 09:29:54 +02:00
|
|
|
|
// draw_box();
|
2008-04-20 23:46:47 +02:00
|
|
|
|
|
|
|
|
|
fl_push_clip( x(), y(), w(), h() );
|
|
|
|
|
|
2012-06-07 09:29:54 +02:00
|
|
|
|
|
2008-04-23 05:40:31 +02:00
|
|
|
|
/* draw the box with the ends cut off. */
|
2012-06-07 09:29:54 +02:00
|
|
|
|
// draw_box( box(), x() - Fl::box_dx( box() ), y(), w() + Fl::box_dw( box() ) + 1, h(), color() );
|
2008-04-23 05:40:31 +02:00
|
|
|
|
|
|
|
|
|
const int bx = x();
|
|
|
|
|
const int by = y() + Fl::box_dy( box() );
|
|
|
|
|
const int bw = w();
|
|
|
|
|
const int bh = h() - Fl::box_dh( box() );
|
2008-04-20 23:46:47 +02:00
|
|
|
|
|
|
|
|
|
int X, Y, W, H;
|
|
|
|
|
|
2008-04-23 05:40:31 +02:00
|
|
|
|
fl_clip_box( bx, by, bw, bh, X, Y, W, H );
|
2008-04-20 23:46:47 +02:00
|
|
|
|
|
2008-04-27 21:37:52 +02:00
|
|
|
|
bool active = active_r();
|
2008-04-25 08:58:08 +02:00
|
|
|
|
|
2008-04-27 21:37:52 +02:00
|
|
|
|
const Fl_Color color = active ? this->color() : fl_inactive( this->color() );
|
2012-11-06 08:50:28 +01:00
|
|
|
|
// const Fl_Color selection_color = active ? this->selection_color() : fl_inactive( this->selection_color() );
|
2008-04-25 08:58:08 +02:00
|
|
|
|
|
2012-10-25 09:25:23 +02:00
|
|
|
|
fl_rectf( X, Y, W, H, fl_color_average( FL_WHITE, FL_BACKGROUND_COLOR, 0.3 ) );
|
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
if ( draw_with_grid )
|
|
|
|
|
{
|
2012-10-25 09:25:23 +02:00
|
|
|
|
fl_color( FL_GRAY );
|
2008-04-22 02:45:17 +02:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
const int inc = bh / 10;
|
|
|
|
|
if ( inc )
|
|
|
|
|
for ( int gy = 0; gy < bh; gy += inc )
|
|
|
|
|
fl_line( X, by + gy, X + W, by + gy );
|
2008-04-22 02:45:17 +02:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
}
|
2008-04-22 01:45:54 +02:00
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
if ( interpolation() != None )
|
2008-04-23 17:41:35 +02:00
|
|
|
|
{
|
2012-02-24 05:53:51 +01:00
|
|
|
|
if ( draw_with_polygon )
|
|
|
|
|
{
|
2012-10-25 09:25:23 +02:00
|
|
|
|
fl_color( fl_color_add_alpha( color, 100 ) );
|
2008-04-27 21:37:52 +02:00
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
fl_begin_complex_polygon();
|
2012-10-25 09:25:23 +02:00
|
|
|
|
draw_curve( true );
|
2012-02-24 05:53:51 +01:00
|
|
|
|
fl_end_complex_polygon();
|
2008-04-20 23:46:47 +02:00
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
}
|
2008-04-23 17:41:35 +02:00
|
|
|
|
|
2012-10-25 09:25:23 +02:00
|
|
|
|
fl_color( fl_color_average( FL_WHITE, color, 0.5 ) );
|
|
|
|
|
fl_line_style( FL_SOLID, 3 );
|
|
|
|
|
|
|
|
|
|
fl_begin_line();
|
|
|
|
|
draw_curve( false );
|
|
|
|
|
fl_end_line();
|
2008-04-20 23:46:47 +02:00
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
fl_line_style( FL_SOLID, 0 );
|
|
|
|
|
}
|
2008-04-20 23:46:47 +02:00
|
|
|
|
|
2012-06-07 09:29:54 +02:00
|
|
|
|
timeline->draw_measure_lines( X, Y, W, H );
|
2008-04-20 23:46:47 +02:00
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
if ( interpolation() == None || _highlighted || Fl::focus() == this )
|
2008-04-25 05:29:28 +02:00
|
|
|
|
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
|
|
|
|
(*r)->draw_box();
|
2008-05-01 07:29:46 +02:00
|
|
|
|
else
|
|
|
|
|
for ( list <Sequence_Widget *>::const_iterator r = _widgets.begin(); r != _widgets.end(); r++ )
|
|
|
|
|
if ( (*r)->selected() )
|
|
|
|
|
(*r)->draw_box();
|
2008-04-20 23:46:47 +02:00
|
|
|
|
|
|
|
|
|
fl_pop_clip();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-21 09:48:13 +01:00
|
|
|
|
#include "FL/menu_popup.H"
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Control_Sequence::menu_cb ( Fl_Widget *w, void *v )
|
|
|
|
|
{
|
|
|
|
|
((Control_Sequence*)v)->menu_cb( (const Fl_Menu_*)w );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Control_Sequence::menu_cb ( const Fl_Menu_ *m )
|
|
|
|
|
{
|
|
|
|
|
char picked[1024];
|
|
|
|
|
|
|
|
|
|
if ( ! m->mvalue() ) // || m->mvalue()->flags & FL_SUBMENU_POINTER || m->mvalue()->flags & FL_SUBMENU )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m->item_pathname( picked, sizeof( picked ), m->mvalue() );
|
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
if ( ! strncmp( picked, "Connect To/", strlen( "Connect To/" ) ) )
|
|
|
|
|
{
|
2012-02-21 09:48:13 +01:00
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
char *peer_name = index( picked, '/' ) + 1;
|
2012-02-21 09:48:13 +01:00
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
*index( peer_name, '/' ) = 0;
|
2012-02-21 09:48:13 +01:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
const char *path = ((OSC::Signal*)m->mvalue()->user_data())->path();
|
2012-02-25 05:23:45 +01:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
char *peer_and_path;
|
|
|
|
|
asprintf( &peer_and_path, "%s:%s", peer_name, path );
|
2012-02-25 05:23:45 +01:00
|
|
|
|
|
|
|
|
|
if ( ! _osc_output->is_connected_to( ((OSC::Signal*)m->mvalue()->user_data()) ) )
|
|
|
|
|
{
|
2012-02-26 03:01:46 +01:00
|
|
|
|
_persistent_osc_connections.push_back( peer_and_path );
|
|
|
|
|
|
2012-02-25 05:23:45 +01:00
|
|
|
|
connect_osc();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-02-26 03:01:46 +01:00
|
|
|
|
timeline->osc->disconnect_signal( _osc_output, peer_name, path );
|
|
|
|
|
|
|
|
|
|
for ( std::list<char*>::iterator i = _persistent_osc_connections.begin();
|
|
|
|
|
i != _persistent_osc_connections.end();
|
|
|
|
|
++i )
|
|
|
|
|
{
|
|
|
|
|
if ( !strcmp( *i, peer_and_path ) )
|
|
|
|
|
{
|
|
|
|
|
free( *i );
|
|
|
|
|
i = _persistent_osc_connections.erase( i );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free( peer_and_path );
|
2012-02-25 05:23:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
}
|
|
|
|
|
else if ( ! strcmp( picked, "Interpolation/Linear" ) )
|
|
|
|
|
interpolation( Linear );
|
|
|
|
|
else if ( ! strcmp( picked, "Interpolation/None" ) )
|
|
|
|
|
interpolation( None );
|
2012-02-26 03:01:46 +01:00
|
|
|
|
else if ( ! strcmp( picked, "Mode/Control Signal (OSC)" ))
|
|
|
|
|
mode( OSC );
|
|
|
|
|
else if ( ! strcmp( picked, "Mode/Control Voltage (JACK)" ) )
|
|
|
|
|
mode( CV );
|
2012-02-24 09:59:39 +01:00
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
else if ( ! strcmp( picked, "/Rename" ) )
|
|
|
|
|
{
|
|
|
|
|
const char *s = fl_input( "Input new name for control sequence:", name() );
|
|
|
|
|
|
|
|
|
|
if ( s )
|
|
|
|
|
name( s );
|
|
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
}
|
|
|
|
|
else if ( !strcmp( picked, "/Remove" ) )
|
|
|
|
|
{
|
|
|
|
|
Fl::delete_widget( this );
|
|
|
|
|
}
|
2012-02-21 09:48:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-24 09:59:39 +01:00
|
|
|
|
void
|
|
|
|
|
Control_Sequence::connect_osc ( void )
|
|
|
|
|
{
|
2012-02-26 03:01:46 +01:00
|
|
|
|
if ( _persistent_osc_connections.size() )
|
2012-02-24 09:59:39 +01:00
|
|
|
|
{
|
2012-02-26 03:01:46 +01:00
|
|
|
|
for ( std::list<char*>::iterator i = _persistent_osc_connections.begin();
|
|
|
|
|
i != _persistent_osc_connections.end();
|
|
|
|
|
++i )
|
2012-02-25 05:23:45 +01:00
|
|
|
|
{
|
2012-02-26 03:01:46 +01:00
|
|
|
|
if ( ! timeline->osc->connect_signal( _osc_output, *i ) )
|
|
|
|
|
{
|
|
|
|
|
// MESSAGE( "Failed to connect output %s to ", _osc_output->path(), *i );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MESSAGE( "Connected output %s to %s", _osc_output->path(), *i );
|
2012-02-25 05:23:45 +01:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
// tooltip( _osc_connected_path );
|
|
|
|
|
}
|
2012-02-24 12:52:57 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-24 09:59:39 +01:00
|
|
|
|
}
|
2012-02-21 09:48:13 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Control_Sequence::process_osc ( void *v )
|
|
|
|
|
{
|
|
|
|
|
((Control_Sequence*)v)->process_osc();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Control_Sequence::process_osc ( void )
|
|
|
|
|
{
|
|
|
|
|
if ( _osc_output && _osc_output->connected() )
|
|
|
|
|
{
|
|
|
|
|
sample_t buf[1];
|
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
play( buf, (nframes_t)transport->frame, (nframes_t) 1 );
|
2012-02-21 09:48:13 +01:00
|
|
|
|
_osc_output->value( (float)buf[0] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-25 05:23:45 +01:00
|
|
|
|
void
|
|
|
|
|
Control_Sequence::peer_callback( const char *name, const OSC::Signal *sig, void *v )
|
|
|
|
|
{
|
|
|
|
|
((Control_Sequence*)v)->peer_callback( name, sig );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Fl_Menu_Button *peer_menu;
|
|
|
|
|
static const char *peer_prefix;
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Control_Sequence::peer_callback( const char *name, const OSC::Signal *sig )
|
|
|
|
|
{
|
|
|
|
|
char *s;
|
|
|
|
|
|
2012-02-27 03:47:07 +01:00
|
|
|
|
/* only show inputs */
|
|
|
|
|
if ( sig->direction() != OSC::Signal::Input )
|
|
|
|
|
return;
|
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
/* only list CV signals for now */
|
|
|
|
|
if ( ! ( sig->parameter_limits().min == 0.0 &&
|
|
|
|
|
sig->parameter_limits().max == 1.0 ) )
|
|
|
|
|
return;
|
|
|
|
|
|
2012-06-05 07:58:57 +02:00
|
|
|
|
|
|
|
|
|
assert( sig->path() );
|
|
|
|
|
|
|
|
|
|
char *path = strdup( sig->path() );
|
|
|
|
|
|
|
|
|
|
unescape_url( path );
|
|
|
|
|
|
|
|
|
|
asprintf( &s, "%s/%s%s", peer_prefix, name, path );
|
2012-02-25 05:23:45 +01:00
|
|
|
|
|
|
|
|
|
peer_menu->add( s, 0, NULL, (void*)( sig ),
|
2012-02-26 03:01:46 +01:00
|
|
|
|
FL_MENU_TOGGLE |
|
2012-02-25 05:23:45 +01:00
|
|
|
|
( _osc_output->is_connected_to( sig ) ? FL_MENU_VALUE : 0 ) );
|
|
|
|
|
|
2012-06-05 07:58:57 +02:00
|
|
|
|
free( path );
|
|
|
|
|
|
2012-02-25 05:23:45 +01:00
|
|
|
|
free( s );
|
|
|
|
|
|
|
|
|
|
connect_osc();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Control_Sequence::add_osc_peers_to_menu ( Fl_Menu_Button *m, const char *prefix )
|
|
|
|
|
{
|
2012-02-26 03:01:46 +01:00
|
|
|
|
peer_menu = m;
|
|
|
|
|
peer_prefix = prefix;
|
2012-02-25 05:23:45 +01:00
|
|
|
|
|
2012-02-27 03:47:07 +01:00
|
|
|
|
timeline->osc->list_peer_signals( &Control_Sequence::peer_callback, this );
|
2012-02-25 05:23:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
|
int
|
|
|
|
|
Control_Sequence::handle ( int m )
|
|
|
|
|
{
|
2008-04-25 05:29:28 +02:00
|
|
|
|
switch ( m )
|
|
|
|
|
{
|
|
|
|
|
case FL_ENTER:
|
|
|
|
|
_highlighted = true;
|
2008-05-02 13:42:50 +02:00
|
|
|
|
fl_cursor( cursor() );
|
2008-04-25 05:29:28 +02:00
|
|
|
|
redraw();
|
|
|
|
|
return 1;
|
|
|
|
|
case FL_LEAVE:
|
|
|
|
|
_highlighted = false;
|
|
|
|
|
redraw();
|
|
|
|
|
return 1;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
|
int r = Sequence::handle( m );
|
|
|
|
|
|
|
|
|
|
if ( r )
|
|
|
|
|
return r;
|
|
|
|
|
|
|
|
|
|
switch ( m )
|
|
|
|
|
{
|
|
|
|
|
case FL_PUSH:
|
|
|
|
|
{
|
2008-04-28 20:17:46 +02:00
|
|
|
|
Logger log( this );
|
|
|
|
|
|
2008-04-20 23:46:47 +02:00
|
|
|
|
if ( Fl::event_button1() )
|
|
|
|
|
{
|
|
|
|
|
Control_Point *r = new Control_Point( this, timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() ), (float)(Fl::event_y() - y()) / h() );
|
|
|
|
|
|
|
|
|
|
add( r );
|
|
|
|
|
}
|
2008-04-28 20:17:46 +02:00
|
|
|
|
else if ( Fl::event_button3() && ! ( Fl::event_state() & ( FL_ALT | FL_SHIFT | FL_CTRL ) ) )
|
|
|
|
|
{
|
2012-02-24 12:52:57 +01:00
|
|
|
|
|
2012-02-21 09:48:13 +01:00
|
|
|
|
Fl_Menu_Button menu( 0, 0, 0, 0, "Control Sequence" );
|
2008-04-28 20:17:46 +02:00
|
|
|
|
|
2012-02-21 09:48:13 +01:00
|
|
|
|
menu.clear();
|
2008-04-28 20:17:46 +02:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
if ( mode() == OSC )
|
|
|
|
|
{
|
|
|
|
|
add_osc_peers_to_menu( &menu, "Connect To" );
|
|
|
|
|
}
|
2012-02-21 09:48:13 +01:00
|
|
|
|
|
2012-02-24 05:53:51 +01:00
|
|
|
|
menu.add( "Interpolation/None", 0, 0, 0, FL_MENU_RADIO | ( interpolation() == None ? FL_MENU_VALUE : 0 ) );
|
|
|
|
|
menu.add( "Interpolation/Linear", 0, 0, 0, FL_MENU_RADIO | ( interpolation() == Linear ? FL_MENU_VALUE : 0 ) );
|
2012-02-26 03:01:46 +01:00
|
|
|
|
menu.add( "Mode/Control Voltage (JACK)", 0, 0, 0 ,FL_MENU_RADIO | ( mode() == CV ? FL_MENU_VALUE : 0 ) );
|
|
|
|
|
menu.add( "Mode/Control Signal (OSC)", 0, 0, 0 , FL_MENU_RADIO | ( mode() == OSC ? FL_MENU_VALUE : 0 ) );
|
2012-02-24 09:59:39 +01:00
|
|
|
|
|
2012-02-21 09:48:13 +01:00
|
|
|
|
menu.add( "Rename", 0, 0, 0 );
|
|
|
|
|
menu.add( "Remove", 0, 0, 0 );
|
2008-04-28 20:17:46 +02:00
|
|
|
|
|
2012-02-26 03:01:46 +01:00
|
|
|
|
menu.callback( &Control_Sequence::menu_cb, (void*)this);
|
2012-02-21 09:48:13 +01:00
|
|
|
|
|
|
|
|
|
menu_popup( &menu, x(), y() );
|
|
|
|
|
|
2008-04-28 20:17:46 +02:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
2008-04-20 23:46:47 +02:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|