2009-12-25 01:59:39 +01:00
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
/* Copyright (C) 2009 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-25 03:12:10 +01:00
|
|
|
|
#include "const.h"
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
#include "Controller_Module.H"
|
|
|
|
|
|
2010-01-25 03:12:10 +01:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
|
#include <FL/Fl_Box.H>
|
2010-01-30 17:58:59 +01:00
|
|
|
|
#include <FL/fl_ask.H>
|
2009-12-25 01:59:39 +01:00
|
|
|
|
#include <FL/Fl_Counter.H>
|
2010-01-21 07:50:12 +01:00
|
|
|
|
#include <FL/Fl_Menu_Item.H>
|
|
|
|
|
#include <FL/Fl_Menu_Button.H>
|
|
|
|
|
#include <FL/Fl_Menu_.H>
|
2010-01-25 03:12:10 +01:00
|
|
|
|
#include <FL/Fl_Light_Button.H>
|
2009-12-25 01:59:39 +01:00
|
|
|
|
#include <FL/fl_draw.H>
|
2013-05-29 07:11:07 +02:00
|
|
|
|
#include "FL/Fl_DialX.H"
|
2009-12-25 01:59:39 +01:00
|
|
|
|
#include "FL/Fl_Labelpad_Group.H"
|
2010-01-25 03:12:10 +01:00
|
|
|
|
#include "FL/Fl_Value_SliderX.H"
|
2010-02-24 16:05:46 +01:00
|
|
|
|
#include "Panner.H"
|
2010-01-25 03:12:10 +01:00
|
|
|
|
#include "FL/test_press.H"
|
|
|
|
|
#include "FL/menu_popup.H"
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
#include "Chain.H"
|
2012-02-08 04:44:40 +01:00
|
|
|
|
#include "OSC/Endpoint.H"
|
|
|
|
|
|
|
|
|
|
// needed for mixer->endpoint
|
|
|
|
|
#include "Mixer.H"
|
2013-06-26 07:28:51 +02:00
|
|
|
|
#include "Spatialization_Console.H"
|
2013-07-09 06:51:21 +02:00
|
|
|
|
#include "string_util.h"
|
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
|
2013-06-06 00:58:52 +02:00
|
|
|
|
|
2013-06-06 01:26:36 +02:00
|
|
|
|
bool Controller_Module::learn_by_number = false;
|
|
|
|
|
bool Controller_Module::_learn_mode = false;
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
|
2013-09-20 06:28:02 +02:00
|
|
|
|
void
|
|
|
|
|
Controller_Module::take_focus ( void )
|
|
|
|
|
{
|
|
|
|
|
bool v = visible_focus();
|
|
|
|
|
|
|
|
|
|
if ( ! v )
|
|
|
|
|
set_visible_focus();
|
|
|
|
|
|
|
|
|
|
Fl_Widget::take_focus();
|
|
|
|
|
|
|
|
|
|
if ( ! v )
|
|
|
|
|
clear_visible_focus();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-25 03:12:10 +01:00
|
|
|
|
Controller_Module::Controller_Module ( bool is_default ) : Module( is_default, 50, 100, name() )
|
|
|
|
|
{
|
|
|
|
|
// label( "" );
|
|
|
|
|
box( FL_NO_BOX );
|
|
|
|
|
|
2013-09-19 02:10:23 +02:00
|
|
|
|
_horizontal = true;
|
2010-01-25 03:12:10 +01:00
|
|
|
|
_pad = true;
|
|
|
|
|
control = 0;
|
|
|
|
|
control_value =0.0f;
|
|
|
|
|
|
|
|
|
|
add_port( Port( this, Port::OUTPUT, Port::CONTROL ) );
|
|
|
|
|
|
|
|
|
|
_mode = GUI;
|
|
|
|
|
|
|
|
|
|
// mode( GUI );
|
|
|
|
|
// mode( CV );
|
|
|
|
|
// configure_inputs( 1 );
|
|
|
|
|
|
|
|
|
|
end();
|
|
|
|
|
|
2013-09-20 06:28:02 +02:00
|
|
|
|
// clear_visible_focus();
|
2010-01-25 03:12:10 +01:00
|
|
|
|
log_create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Controller_Module::~Controller_Module ( )
|
|
|
|
|
{
|
|
|
|
|
log_destroy();
|
2010-02-17 14:29:41 +01:00
|
|
|
|
|
|
|
|
|
/* shutdown JACK port, if we have one */
|
|
|
|
|
mode( GUI );
|
2013-06-26 07:28:51 +02:00
|
|
|
|
|
|
|
|
|
// disconnect();
|
2012-02-08 04:44:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::handle_chain_name_changed()
|
|
|
|
|
{
|
2013-06-26 07:28:51 +02:00
|
|
|
|
if ( type() == SPATIALIZATION )
|
|
|
|
|
{
|
|
|
|
|
if ( Mixer::spatialization_console )
|
|
|
|
|
Mixer::spatialization_console->update();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-09 07:38:34 +01:00
|
|
|
|
// change_osc_path( generate_osc_path() );
|
2010-01-25 03:12:10 +01:00
|
|
|
|
}
|
2010-02-17 14:29:41 +01:00
|
|
|
|
|
2012-05-21 00:08:38 +02:00
|
|
|
|
void
|
2013-06-26 07:28:51 +02:00
|
|
|
|
Controller_Module::handle_control_disconnect ( Module::Port *p )
|
2012-05-21 00:08:38 +02:00
|
|
|
|
{
|
2013-06-26 07:28:51 +02:00
|
|
|
|
if ( type() == SPATIALIZATION )
|
2012-05-21 00:08:38 +02:00
|
|
|
|
{
|
2013-06-26 07:28:51 +02:00
|
|
|
|
if ( Mixer::spatialization_console )
|
|
|
|
|
Mixer::spatialization_console->update();
|
2012-05-21 00:08:38 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-26 07:28:51 +02:00
|
|
|
|
void
|
|
|
|
|
Controller_Module::disconnect ( void )
|
|
|
|
|
{
|
|
|
|
|
for ( unsigned int i = 0; i < control_output.size(); ++i )
|
|
|
|
|
control_output[i].disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-25 03:12:10 +01:00
|
|
|
|
|
|
|
|
|
|
2009-12-28 06:25:28 +01:00
|
|
|
|
void
|
|
|
|
|
Controller_Module::get ( Log_Entry &e ) const
|
|
|
|
|
{
|
2010-01-21 07:50:12 +01:00
|
|
|
|
Module::get( e );
|
2009-12-28 06:25:28 +01:00
|
|
|
|
|
|
|
|
|
Port *p = control_output[0].connected_port();
|
|
|
|
|
|
2012-05-21 00:08:38 +02:00
|
|
|
|
if ( !p )
|
|
|
|
|
{
|
|
|
|
|
e.add( ":module", "" );
|
|
|
|
|
e.add( ":port", "" );
|
|
|
|
|
e.add( ":mode", "" );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Module *m = p->module();
|
|
|
|
|
|
|
|
|
|
e.add( ":module", m );
|
|
|
|
|
e.add( ":port", m->control_input_port_index( p ) );
|
|
|
|
|
e.add( ":mode", mode() );
|
|
|
|
|
}
|
2009-12-28 06:25:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::set ( Log_Entry &e )
|
|
|
|
|
{
|
|
|
|
|
Module::set( e );
|
|
|
|
|
|
|
|
|
|
int port = -1;
|
|
|
|
|
Module *module = NULL;
|
|
|
|
|
|
|
|
|
|
for ( int i = 0; i < e.size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
const char *s, *v;
|
|
|
|
|
|
|
|
|
|
e.get( i, &s, &v );
|
|
|
|
|
|
|
|
|
|
if ( ! strcmp( s, ":port" ) )
|
|
|
|
|
{
|
|
|
|
|
port = atoi( v );
|
|
|
|
|
}
|
|
|
|
|
else if ( ! strcmp( s, ":module" ) )
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
sscanf( v, "%X", &i );
|
|
|
|
|
Module *t = (Module*)Loggable::find( i );
|
|
|
|
|
|
|
|
|
|
assert( t );
|
|
|
|
|
|
|
|
|
|
module = t;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( port >= 0 && module )
|
2010-01-14 04:19:12 +01:00
|
|
|
|
{
|
2010-01-21 07:50:12 +01:00
|
|
|
|
connect_to( &module->control_input[port] );
|
2010-01-14 04:19:12 +01:00
|
|
|
|
module->chain()->add_control( this );
|
|
|
|
|
label( module->control_input[port].name() );
|
|
|
|
|
}
|
2010-01-21 07:50:12 +01:00
|
|
|
|
|
|
|
|
|
for ( int i = 0; i < e.size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
const char *s, *v;
|
|
|
|
|
|
|
|
|
|
e.get( i, &s, &v );
|
|
|
|
|
|
|
|
|
|
if ( ! strcmp( s, ":mode" ) )
|
|
|
|
|
{
|
|
|
|
|
mode( (Mode)atoi( v ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-28 06:25:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
void
|
2010-01-25 03:12:10 +01:00
|
|
|
|
Controller_Module::mode ( Mode m )
|
2009-12-25 01:59:39 +01:00
|
|
|
|
{
|
2010-01-25 03:12:10 +01:00
|
|
|
|
if( mode() != CV && m == CV )
|
|
|
|
|
{
|
|
|
|
|
if ( control_output[0].connected() )
|
|
|
|
|
{
|
2013-08-06 09:03:19 +02:00
|
|
|
|
chain()->client()->lock();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2010-01-25 03:12:10 +01:00
|
|
|
|
Port *p = control_output[0].connected_port();
|
2013-08-06 09:03:19 +02:00
|
|
|
|
|
|
|
|
|
char prefix[512];
|
|
|
|
|
snprintf( prefix, sizeof(prefix), "CV-%s", p->name() );
|
|
|
|
|
|
|
|
|
|
add_aux_audio_input( prefix, 0 );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2013-08-06 09:03:19 +02:00
|
|
|
|
chain()->client()->unlock();
|
2010-01-25 03:12:10 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-02-08 04:44:40 +01:00
|
|
|
|
else if ( mode() == CV && m != CV )
|
2009-12-25 01:59:39 +01:00
|
|
|
|
{
|
2013-08-06 09:03:19 +02:00
|
|
|
|
chain()->client()->lock();
|
|
|
|
|
|
|
|
|
|
delete aux_audio_input.back().jack_port();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2013-08-06 09:03:19 +02:00
|
|
|
|
aux_audio_input.pop_back();
|
2010-01-25 03:12:10 +01:00
|
|
|
|
|
2013-08-06 09:03:19 +02:00
|
|
|
|
chain()->client()->unlock();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
2010-01-25 03:12:10 +01:00
|
|
|
|
|
|
|
|
|
_mode = m ;
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-27 08:49:29 +02:00
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
Controller_Module::connect_spatializer_radius_to ( Module *m )
|
|
|
|
|
{
|
|
|
|
|
Port *radius_port = NULL;
|
|
|
|
|
float radius_value = 0.0f;
|
|
|
|
|
|
|
|
|
|
for ( unsigned int i = 0; i < m->control_input.size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
Port *p = &m->control_input[i];
|
|
|
|
|
|
|
|
|
|
if ( !strcasecmp( "Radius", p->name() ) )
|
|
|
|
|
/* 90.0f == p->hints.maximum && */
|
|
|
|
|
/* -90.0f == p->hints.minimum ) */
|
|
|
|
|
{
|
|
|
|
|
radius_port = p;
|
|
|
|
|
radius_value = p->control_value();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( ! radius_port )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if ( control_output.size() != 3 )
|
|
|
|
|
{
|
|
|
|
|
control_output.clear();
|
|
|
|
|
add_port( Port( this, Port::OUTPUT, Port::CONTROL ) );
|
|
|
|
|
add_port( Port( this, Port::OUTPUT, Port::CONTROL ) );
|
|
|
|
|
add_port( Port( this, Port::OUTPUT, Port::CONTROL ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
control_output[2].connect_to( radius_port );
|
|
|
|
|
|
|
|
|
|
maybe_create_panner();
|
|
|
|
|
|
|
|
|
|
Panner *o = (Panner*)control;
|
|
|
|
|
|
|
|
|
|
o->point( 0 )->radius( radius_value );
|
|
|
|
|
|
|
|
|
|
if ( Mixer::spatialization_console )
|
|
|
|
|
Mixer::spatialization_console->update();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::maybe_create_panner ( void )
|
|
|
|
|
{
|
|
|
|
|
if ( _type != SPATIALIZATION )
|
|
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
|
|
|
|
|
Panner *o = new Panner( 0,0, 92,92 );
|
|
|
|
|
|
|
|
|
|
o->box(FL_FLAT_BOX);
|
|
|
|
|
o->color(FL_GRAY0);
|
|
|
|
|
o->selection_color(FL_BACKGROUND_COLOR);
|
|
|
|
|
o->labeltype(FL_NORMAL_LABEL);
|
|
|
|
|
o->labelfont(0);
|
|
|
|
|
o->labelcolor(FL_FOREGROUND_COLOR);
|
|
|
|
|
o->align(FL_ALIGN_TOP);
|
|
|
|
|
o->when(FL_WHEN_CHANGED);
|
|
|
|
|
label( "Spatialization" );
|
|
|
|
|
|
|
|
|
|
o->align(FL_ALIGN_TOP);
|
|
|
|
|
o->labelsize( 10 );
|
|
|
|
|
// o->callback( cb_panner_value_handle, new callback_data( this, azimuth_port_number, elevation_port_number ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
o->callback( cb_spatializer_handle, this );
|
|
|
|
|
|
|
|
|
|
control = (Fl_Valuator*)o;
|
|
|
|
|
|
|
|
|
|
if ( _pad )
|
|
|
|
|
{
|
|
|
|
|
Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( o );
|
|
|
|
|
flg->position( x(), y() );
|
|
|
|
|
flg->set_visible_focus();
|
|
|
|
|
size( flg->w(), flg->h() );
|
|
|
|
|
add( flg );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-09-20 06:28:02 +02:00
|
|
|
|
// o->clear_visible_focus();
|
2013-06-27 08:49:29 +02:00
|
|
|
|
o->resize( x(), y(), w(), h() );
|
|
|
|
|
add( o );
|
|
|
|
|
resizable( o );
|
|
|
|
|
init_sizes();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_type = SPATIALIZATION;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-24 16:05:46 +01:00
|
|
|
|
/** attempt to transform this controller into a spatialization
|
|
|
|
|
controller and connect to the given module's spatialization
|
|
|
|
|
control inputs. Returns true on success, false if given module
|
|
|
|
|
does not accept spatialization inputs. */
|
|
|
|
|
bool
|
|
|
|
|
Controller_Module::connect_spatializer_to ( Module *m )
|
|
|
|
|
{
|
2013-06-27 08:49:29 +02:00
|
|
|
|
connect_spatializer_radius_to( m );
|
|
|
|
|
|
2010-02-24 16:05:46 +01:00
|
|
|
|
/* these are for detecting related parameter groups which can be
|
|
|
|
|
better represented by a single control */
|
|
|
|
|
Port *azimuth_port = NULL;
|
|
|
|
|
float azimuth_value = 0.0f;
|
|
|
|
|
Port *elevation_port = NULL;
|
|
|
|
|
float elevation_value = 0.0f;
|
|
|
|
|
|
|
|
|
|
for ( unsigned int i = 0; i < m->control_input.size(); ++i )
|
|
|
|
|
{
|
|
|
|
|
Port *p = &m->control_input[i];
|
|
|
|
|
|
|
|
|
|
if ( !strcasecmp( "Azimuth", p->name() ) &&
|
|
|
|
|
180.0f == p->hints.maximum &&
|
|
|
|
|
-180.0f == p->hints.minimum )
|
|
|
|
|
{
|
|
|
|
|
azimuth_port = p;
|
|
|
|
|
azimuth_value = p->control_value();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if ( !strcasecmp( "Elevation", p->name() ) &&
|
|
|
|
|
90.0f == p->hints.maximum &&
|
|
|
|
|
-90.0f == p->hints.minimum )
|
|
|
|
|
{
|
|
|
|
|
elevation_port = p;
|
|
|
|
|
elevation_value = p->control_value();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-27 08:49:29 +02:00
|
|
|
|
|
2010-02-24 16:05:46 +01:00
|
|
|
|
if ( ! ( azimuth_port && elevation_port ) )
|
|
|
|
|
return false;
|
|
|
|
|
|
2013-06-27 08:49:29 +02:00
|
|
|
|
if ( control_output.size() != 3 )
|
|
|
|
|
{
|
|
|
|
|
control_output.clear();
|
|
|
|
|
add_port( Port( this, Port::OUTPUT, Port::CONTROL ) );
|
|
|
|
|
add_port( Port( this, Port::OUTPUT, Port::CONTROL ) );
|
|
|
|
|
add_port( Port( this, Port::OUTPUT, Port::CONTROL ) );
|
|
|
|
|
}
|
2010-02-24 16:05:46 +01:00
|
|
|
|
|
|
|
|
|
control_output[0].connect_to( azimuth_port );
|
|
|
|
|
control_output[1].connect_to( elevation_port );
|
|
|
|
|
|
2013-06-27 08:49:29 +02:00
|
|
|
|
maybe_create_panner();
|
|
|
|
|
|
|
|
|
|
Panner *o = (Panner*)control;
|
2010-02-24 16:05:46 +01:00
|
|
|
|
|
2013-06-26 07:28:51 +02:00
|
|
|
|
o->point( 0 )->azimuth( azimuth_value );
|
|
|
|
|
o->point( 0 )->elevation( elevation_value );
|
2013-06-27 08:49:29 +02:00
|
|
|
|
|
2013-06-26 07:28:51 +02:00
|
|
|
|
if ( Mixer::spatialization_console )
|
|
|
|
|
Mixer::spatialization_console->update();
|
|
|
|
|
|
|
|
|
|
return true;
|
2010-02-24 16:05:46 +01:00
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
void
|
|
|
|
|
Controller_Module::connect_to ( Port *p )
|
|
|
|
|
{
|
|
|
|
|
control_output[0].connect_to( p );
|
|
|
|
|
|
2010-02-24 16:05:46 +01:00
|
|
|
|
clear();
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
Fl_Widget *w;
|
|
|
|
|
|
|
|
|
|
if ( p->hints.type == Module::Port::Hints::BOOLEAN )
|
|
|
|
|
{
|
2013-09-02 06:35:16 +02:00
|
|
|
|
Fl_Button *o = new Fl_Button( 0, 0, 40, 40, p->name() );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
w = o;
|
2013-09-02 06:35:16 +02:00
|
|
|
|
o->type( FL_TOGGLE_BUTTON );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->value( p->control_value() );
|
2013-09-02 06:35:16 +02:00
|
|
|
|
o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2010-02-25 00:25:56 +01:00
|
|
|
|
_type = TOGGLE;
|
2012-02-10 10:06:35 +01:00
|
|
|
|
|
|
|
|
|
/* FIXME: hack */
|
|
|
|
|
control = (Fl_Valuator*)o;
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
else if ( p->hints.type == Module::Port::Hints::INTEGER )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Fl_Counter *o = new Fl_Counter(0, 0, 58, 24, p->name() );
|
|
|
|
|
control = o;
|
|
|
|
|
w = o;
|
|
|
|
|
|
|
|
|
|
o->type(1);
|
|
|
|
|
o->step(1);
|
|
|
|
|
|
|
|
|
|
if ( p->hints.ranged )
|
|
|
|
|
{
|
|
|
|
|
o->minimum( p->hints.minimum );
|
|
|
|
|
o->maximum( p->hints.maximum );
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-25 00:25:56 +01:00
|
|
|
|
_type = SPINNER;
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->value( p->control_value() );
|
|
|
|
|
}
|
2013-09-19 02:10:23 +02:00
|
|
|
|
// else if ( p->hints.type == Module::Port::Hints::LOGARITHMIC )
|
|
|
|
|
else
|
2009-12-25 01:59:39 +01:00
|
|
|
|
{
|
2009-12-26 07:58:28 +01:00
|
|
|
|
Fl_Value_SliderX *o = new Fl_Value_SliderX(0, 0, 30, 250, p->name() );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
control = o;
|
|
|
|
|
w = o;
|
|
|
|
|
|
2013-09-19 02:10:23 +02:00
|
|
|
|
if ( ! _horizontal )
|
|
|
|
|
{
|
|
|
|
|
o->size( 30, 250 );
|
|
|
|
|
o->type(FL_VERT_NICE_SLIDER);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
o->size(250,20);
|
|
|
|
|
o->type(FL_HOR_NICE_SLIDER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// o->type(4);
|
2013-07-09 06:51:21 +02:00
|
|
|
|
o->color( FL_BACKGROUND2_COLOR );
|
2013-05-29 07:11:07 +02:00
|
|
|
|
o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->minimum(1.5);
|
|
|
|
|
o->maximum(0);
|
|
|
|
|
o->value(1);
|
2013-09-19 02:10:23 +02:00
|
|
|
|
// o->textsize(9);
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
if ( p->hints.ranged )
|
|
|
|
|
{
|
2013-09-19 02:10:23 +02:00
|
|
|
|
if ( ! _horizontal )
|
|
|
|
|
{
|
|
|
|
|
o->minimum( p->hints.maximum );
|
|
|
|
|
o->maximum( p->hints.minimum );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
o->minimum( p->hints.minimum );
|
|
|
|
|
o->maximum( p->hints.maximum );
|
|
|
|
|
}
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-19 08:28:58 +02:00
|
|
|
|
o->precision(2);
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
o->value( p->control_value() );
|
2010-02-25 00:25:56 +01:00
|
|
|
|
|
|
|
|
|
_type = SLIDER;
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
2013-09-19 02:10:23 +02:00
|
|
|
|
/* else */
|
|
|
|
|
/* { */
|
|
|
|
|
/* { Fl_DialX *o = new Fl_DialX( 0, 0, 50, 50, p->name() ); */
|
|
|
|
|
/* w = o; */
|
|
|
|
|
/* control = o; */
|
|
|
|
|
|
|
|
|
|
/* if ( p->hints.ranged ) */
|
|
|
|
|
/* { */
|
|
|
|
|
/* DMESSAGE( "Min: %f, max: %f", p->hints.minimum, p->hints.maximum ); */
|
|
|
|
|
/* o->minimum( p->hints.minimum ); */
|
|
|
|
|
/* o->maximum( p->hints.maximum ); */
|
|
|
|
|
/* } */
|
2012-03-02 06:02:06 +01:00
|
|
|
|
|
2013-09-19 02:10:23 +02:00
|
|
|
|
/* o->color( fl_darker( FL_GRAY ) ); */
|
|
|
|
|
/* o->selection_color( FL_WHITE ); */
|
|
|
|
|
/* o->value( p->control_value() ); */
|
|
|
|
|
/* } */
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2013-09-19 02:10:23 +02:00
|
|
|
|
/* _type = KNOB; */
|
|
|
|
|
/* } */
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
control_value = p->control_value();
|
|
|
|
|
|
2013-09-20 06:28:02 +02:00
|
|
|
|
w->clear_visible_focus();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
w->align(FL_ALIGN_TOP);
|
|
|
|
|
w->labelsize( 10 );
|
|
|
|
|
w->callback( cb_handle, this );
|
|
|
|
|
|
|
|
|
|
if ( _pad )
|
|
|
|
|
{
|
|
|
|
|
Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w );
|
2010-02-01 01:25:14 +01:00
|
|
|
|
flg->set_visible_focus();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
size( flg->w(), flg->h() );
|
2010-02-24 16:05:46 +01:00
|
|
|
|
flg->position( x(), y() );
|
2009-12-25 01:59:39 +01:00
|
|
|
|
add( flg );
|
2013-09-19 02:10:23 +02:00
|
|
|
|
resizable(flg);
|
|
|
|
|
// init_sizes();
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-02-06 01:38:40 +01:00
|
|
|
|
/* HACK: hide label */
|
2013-09-02 06:35:16 +02:00
|
|
|
|
if ( _type == TOGGLE )
|
|
|
|
|
{
|
|
|
|
|
w->align( FL_ALIGN_INSIDE );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
w->labeltype( FL_NO_LABEL );
|
|
|
|
|
}
|
2009-12-25 01:59:39 +01:00
|
|
|
|
w->resize( x(), y(), this->w(), h() );
|
|
|
|
|
add( w );
|
|
|
|
|
resizable( w );
|
2013-09-19 02:10:23 +02:00
|
|
|
|
init_sizes();
|
2010-01-12 03:31:15 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-25 03:12:10 +01:00
|
|
|
|
void
|
2013-06-18 04:26:04 +02:00
|
|
|
|
Controller_Module::update ( void )
|
2010-01-25 03:12:10 +01:00
|
|
|
|
{
|
2012-02-20 08:19:15 +01:00
|
|
|
|
/* we only need this in CV (JACK) mode, because with other forms
|
|
|
|
|
* of control the change happens in the GUI thread and we know it */
|
|
|
|
|
if ( mode() != CV )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* ensures that port value change callbacks are run */
|
2012-02-09 04:03:48 +01:00
|
|
|
|
if ( control && control_output.size() > 0 && control_output[0].connected() )
|
2012-02-20 08:19:15 +01:00
|
|
|
|
control_output[0].connected_port()->control_value( control_value );
|
2010-01-25 03:12:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::cb_handle ( Fl_Widget *w, void *v )
|
|
|
|
|
{
|
|
|
|
|
((Controller_Module*)v)->cb_handle( w );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::cb_handle ( Fl_Widget *w )
|
|
|
|
|
{
|
2012-02-10 10:06:35 +01:00
|
|
|
|
if ( type() == TOGGLE )
|
|
|
|
|
{
|
|
|
|
|
control_value = ((Fl_Button*)w)->value();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
control_value = ((Fl_Valuator*)w)->value();
|
|
|
|
|
|
2010-01-25 03:12:10 +01:00
|
|
|
|
if ( control_output[0].connected() )
|
2010-02-27 19:55:25 +01:00
|
|
|
|
control_output[0].connected_port()->control_value( control_value );
|
2010-02-24 16:05:46 +01:00
|
|
|
|
}
|
2010-01-25 03:12:10 +01:00
|
|
|
|
|
2010-02-24 16:05:46 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::cb_spatializer_handle ( Fl_Widget *w, void *v )
|
|
|
|
|
{
|
|
|
|
|
((Controller_Module*)v)->cb_spatializer_handle( w );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::cb_spatializer_handle ( Fl_Widget *w )
|
|
|
|
|
{
|
|
|
|
|
Panner *pan = (Panner*)w;
|
|
|
|
|
|
|
|
|
|
if ( control_output[0].connected() &&
|
|
|
|
|
control_output[1].connected() )
|
|
|
|
|
{
|
|
|
|
|
control_output[0].connected_port()->control_value( pan->point( 0 )->azimuth() );
|
|
|
|
|
control_output[1].connected_port()->control_value( pan->point( 0 )->elevation() );
|
2010-01-25 03:12:10 +01:00
|
|
|
|
}
|
2013-06-27 08:49:29 +02:00
|
|
|
|
|
|
|
|
|
if ( control_output[2].connected() )
|
|
|
|
|
{
|
|
|
|
|
control_output[2].connected_port()->control_value( pan->point( 0 )->radius() );
|
|
|
|
|
}
|
2010-01-25 03:12:10 +01:00
|
|
|
|
}
|
2010-01-21 07:50:12 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::menu_cb ( Fl_Widget *w, void *v )
|
|
|
|
|
{
|
|
|
|
|
((Controller_Module*)v)->menu_cb( (Fl_Menu_*) w );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::menu_cb ( const Fl_Menu_ *m )
|
|
|
|
|
{
|
|
|
|
|
char picked[256];
|
|
|
|
|
|
|
|
|
|
m->item_pathname( picked, sizeof( picked ) );
|
|
|
|
|
|
|
|
|
|
Logger log( this );
|
|
|
|
|
|
2012-02-24 09:59:39 +01:00
|
|
|
|
if ( ! strcmp( picked, "Mode/GUI + OSC" ) )
|
2010-01-21 07:50:12 +01:00
|
|
|
|
mode( GUI );
|
2012-02-24 09:59:39 +01:00
|
|
|
|
else if ( ! strcmp( picked, "Mode/Control Voltage (JACK)" ) )
|
2010-01-21 07:50:12 +01:00
|
|
|
|
mode( CV );
|
2012-05-21 00:08:38 +02:00
|
|
|
|
else if ( ! strcmp( picked, "/Remove" ) )
|
|
|
|
|
command_remove();
|
2013-07-09 06:51:21 +02:00
|
|
|
|
else if ( ! strncmp( picked, "Connect To/", strlen( "Connect To/" ) ) )
|
|
|
|
|
{
|
|
|
|
|
char *peer_name = index( picked, '/' ) + 1;
|
|
|
|
|
|
|
|
|
|
*index( peer_name, '/' ) = 0;
|
|
|
|
|
|
|
|
|
|
// OSC::Signal s = (OSC::Signal*)m->mvalue()->user_data();
|
|
|
|
|
const char *path = ((OSC::Signal*)m->mvalue()->user_data())->path();
|
|
|
|
|
|
|
|
|
|
/* if ( ! _osc_output()->is_connected_to( ((OSC::Signal*)m->mvalue()->user_data()) ) ) */
|
|
|
|
|
/* { */
|
|
|
|
|
/* _persistent_osc_connections.push_back( strdup(path) ); */
|
|
|
|
|
|
|
|
|
|
Port *p = control_output[0].connected_port();
|
|
|
|
|
|
|
|
|
|
if ( learn_by_number )
|
2013-07-09 06:53:20 +02:00
|
|
|
|
mixer->osc_endpoint->add_translation( path, p->osc_number_path());
|
2013-07-09 06:51:21 +02:00
|
|
|
|
else
|
|
|
|
|
mixer->osc_endpoint->add_translation( path, p->osc_path() );
|
|
|
|
|
}
|
|
|
|
|
else if ( ! strncmp( picked, "Disconnect From/", strlen( "Disconnect From/" ) ) )
|
|
|
|
|
{
|
|
|
|
|
/* char *peer_name = index( picked, '/' ) + 1; */
|
|
|
|
|
|
|
|
|
|
/* *index( peer_name, '/' ) = 0; */
|
|
|
|
|
|
|
|
|
|
// OSC::Signal s = (OSC::Signal*)m->mvalue()->user_data();
|
|
|
|
|
const char *path = (const char*)m->mvalue()->user_data();
|
|
|
|
|
|
|
|
|
|
/* if ( ! _osc_output()->is_connected_to( ((OSC::Signal*)m->mvalue()->user_data()) ) ) */
|
|
|
|
|
/* { */
|
|
|
|
|
/* _persistent_osc_connections.push_back( strdup(path) ); */
|
|
|
|
|
|
|
|
|
|
// Port *p = control_output[0].connected_port();
|
|
|
|
|
|
|
|
|
|
mixer->osc_endpoint->del_translation( path );
|
|
|
|
|
|
|
|
|
|
/* if ( learn_by_number ) */
|
|
|
|
|
/* { */
|
|
|
|
|
/* char *our_path = p->osc_number_path(); */
|
|
|
|
|
|
|
|
|
|
/* mixer->osc_endpoint->add_translation( path, our_path ); */
|
|
|
|
|
|
|
|
|
|
/* free(our_path); */
|
|
|
|
|
/* } */
|
|
|
|
|
/* else */
|
|
|
|
|
/* mixer->osc_endpoint->add_translation( path, p->osc_path() ); */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* } */
|
|
|
|
|
/* else */
|
|
|
|
|
/* { */
|
|
|
|
|
/* /\* timeline->osc->disconnect_signal( _osc_output(), path ); *\/ */
|
|
|
|
|
|
|
|
|
|
/* /\* for ( std::list<char*>::iterator i = _persistent_osc_connections.begin(); *\/ */
|
|
|
|
|
/* /\* i != _persistent_osc_connections.end(); *\/ */
|
|
|
|
|
/* /\* ++i ) *\/ */
|
|
|
|
|
/* /\* { *\/ */
|
|
|
|
|
/* /\* if ( !strcmp( *i, path ) ) *\/ */
|
|
|
|
|
/* /\* { *\/ */
|
|
|
|
|
/* /\* free( *i ); *\/ */
|
|
|
|
|
/* /\* i = _persistent_osc_connections.erase( i ); *\/ */
|
|
|
|
|
/* /\* break; *\/ */
|
|
|
|
|
/* /\* } *\/ */
|
|
|
|
|
/* /\* } *\/ */
|
|
|
|
|
|
|
|
|
|
/* //free( path ); */
|
|
|
|
|
/* } */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
static Fl_Menu_Button *peer_menu;
|
|
|
|
|
static const char *peer_prefix;
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::peer_callback( OSC::Signal *sig, OSC::Signal::State state, void *v )
|
|
|
|
|
{
|
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
|
|
DMESSAGE( "Paramter limits: %f %f", sig->parameter_limits().min, sig->parameter_limits().max );
|
|
|
|
|
|
|
|
|
|
/* only show outputs */
|
|
|
|
|
if ( sig->direction() != OSC::Signal::Output )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* only list CV signals for now */
|
|
|
|
|
if ( ! ( sig->parameter_limits().min == 0.0 &&
|
|
|
|
|
sig->parameter_limits().max == 1.0 ) )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if ( ! v )
|
|
|
|
|
{
|
|
|
|
|
/* if( state == OSC::Signal::Created ) */
|
|
|
|
|
/* timeline->connect_osc(); */
|
|
|
|
|
/* else */
|
|
|
|
|
/* timeline->update_osc_connection_state(); */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* building menu */
|
2013-07-09 06:53:20 +02:00
|
|
|
|
// const char *name = sig->peer_name();
|
2013-07-09 06:51:21 +02:00
|
|
|
|
|
|
|
|
|
assert( sig->path() );
|
|
|
|
|
|
|
|
|
|
char *path = strdup( sig->path() );
|
|
|
|
|
|
|
|
|
|
unescape_url( path );
|
|
|
|
|
|
|
|
|
|
asprintf( &s, "%s/%s", peer_prefix, path );
|
|
|
|
|
|
|
|
|
|
peer_menu->add( s, 0, NULL, (void*)( sig ), 0 );
|
|
|
|
|
|
|
|
|
|
/* FL_MENU_TOGGLE | */
|
|
|
|
|
/* ( ((Controller_Module*)v)->_osc_output()->is_connected_to( sig ) ? FL_MENU_VALUE : 0 ) ); */
|
|
|
|
|
|
|
|
|
|
free( path );
|
|
|
|
|
|
|
|
|
|
free( s );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::add_osc_peers_to_menu ( Fl_Menu_Button *m, const char *prefix )
|
|
|
|
|
{
|
|
|
|
|
mixer->osc_endpoint->peer_signal_notification_callback( &Controller_Module::peer_callback, NULL );
|
|
|
|
|
|
|
|
|
|
peer_menu = m;
|
|
|
|
|
peer_prefix = prefix;
|
|
|
|
|
|
|
|
|
|
mixer->osc_endpoint->list_peer_signals( this );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Controller_Module::add_osc_connections_to_menu ( Fl_Menu_Button *m, const char *prefix )
|
|
|
|
|
{
|
|
|
|
|
/* peer_menu = m; */
|
|
|
|
|
const char *peer_prefix = prefix;
|
|
|
|
|
|
|
|
|
|
// mixer->osc_endpoint->list_peer_signals( this );
|
|
|
|
|
|
|
|
|
|
Port *p = control_output[0].connected_port();
|
|
|
|
|
|
2013-07-09 06:53:20 +02:00
|
|
|
|
const char *number_path = p->osc_number_path();
|
|
|
|
|
const char *name_path = p->osc_path();
|
|
|
|
|
|
|
|
|
|
const char *paths[] = { number_path,name_path,NULL };
|
|
|
|
|
|
|
|
|
|
for ( const char **cpath = paths; *cpath; cpath++ )
|
2013-07-09 06:51:21 +02:00
|
|
|
|
{
|
2013-07-09 06:53:20 +02:00
|
|
|
|
const char ** conn = mixer->osc_endpoint->get_connections( *cpath );
|
|
|
|
|
|
|
|
|
|
if ( conn )
|
2013-07-09 06:51:21 +02:00
|
|
|
|
{
|
2013-07-09 06:53:20 +02:00
|
|
|
|
for ( const char **s = conn; *s; s++ )
|
|
|
|
|
{
|
|
|
|
|
/* building menu */
|
2013-07-09 06:51:21 +02:00
|
|
|
|
|
2013-07-09 06:53:20 +02:00
|
|
|
|
char *path = strdup( *s );
|
2013-07-09 06:51:21 +02:00
|
|
|
|
|
2013-07-09 06:53:20 +02:00
|
|
|
|
unescape_url( path );
|
2013-07-09 06:51:21 +02:00
|
|
|
|
|
2013-07-09 06:53:20 +02:00
|
|
|
|
char *ns;
|
|
|
|
|
asprintf( &ns, "%s/%s", peer_prefix, path );
|
2013-07-09 06:51:21 +02:00
|
|
|
|
|
2013-07-09 06:53:20 +02:00
|
|
|
|
peer_menu->add( ns, 0, NULL, const_cast<char*>(*s), 0 );
|
2013-07-09 06:51:21 +02:00
|
|
|
|
|
2013-07-09 06:53:20 +02:00
|
|
|
|
free( path );
|
2013-07-09 06:51:21 +02:00
|
|
|
|
// free(*s);
|
2013-07-09 06:53:20 +02:00
|
|
|
|
}
|
2013-07-09 06:51:21 +02:00
|
|
|
|
|
2013-07-09 06:53:20 +02:00
|
|
|
|
free( conn );
|
|
|
|
|
}
|
2013-07-09 06:51:21 +02:00
|
|
|
|
}
|
2010-01-21 07:50:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** build the context menu for this control */
|
|
|
|
|
Fl_Menu_Button &
|
|
|
|
|
Controller_Module::menu ( void )
|
|
|
|
|
{
|
|
|
|
|
static Fl_Menu_Button m( 0, 0, 0, 0, "Controller" );
|
|
|
|
|
|
2013-07-09 06:51:21 +02:00
|
|
|
|
m.clear();
|
|
|
|
|
|
|
|
|
|
if ( mode() == GUI )
|
|
|
|
|
{
|
|
|
|
|
add_osc_peers_to_menu( &m, "Connect To" );
|
|
|
|
|
add_osc_connections_to_menu( &m, "Disconnect From" );
|
|
|
|
|
}
|
2010-01-21 07:50:12 +01:00
|
|
|
|
|
2013-07-09 06:51:21 +02:00
|
|
|
|
m.add( "Mode/GUI + OSC", 0, 0, 0, FL_MENU_RADIO | ( mode() == GUI ? FL_MENU_VALUE : 0 ));
|
|
|
|
|
m.add( "Mode/Control Voltage (JACK)", 0, 0, 0, FL_MENU_RADIO | ( mode() == CV ? FL_MENU_VALUE : 0 ));
|
|
|
|
|
m.add( "Remove", 0, 0, 0, is_default() ? FL_MENU_INACTIVE : 0 );
|
2010-01-21 07:50:12 +01:00
|
|
|
|
|
2013-07-09 06:51:21 +02:00
|
|
|
|
// menu_set_callback( m.items(), &Controller_Module::menu_cb, (void*)this );
|
|
|
|
|
m.callback( &Controller_Module::menu_cb, (void*)this );
|
|
|
|
|
// m.copy( items, (void*)this );
|
2010-01-21 07:50:12 +01:00
|
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-06 00:58:52 +02:00
|
|
|
|
void
|
|
|
|
|
Controller_Module::draw ( void )
|
|
|
|
|
{
|
|
|
|
|
Fl_Group::draw();
|
2013-09-19 08:28:58 +02:00
|
|
|
|
draw_box(x(),y(),w(),h());
|
2013-06-06 00:58:52 +02:00
|
|
|
|
|
|
|
|
|
if ( learn_mode() )
|
|
|
|
|
{
|
|
|
|
|
fl_rectf( x(),y(),w(),h(), fl_color_add_alpha( FL_MAGENTA, 50 ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
int
|
|
|
|
|
Controller_Module::handle ( int m )
|
|
|
|
|
{
|
2010-01-21 07:50:12 +01:00
|
|
|
|
|
|
|
|
|
switch ( m )
|
|
|
|
|
{
|
|
|
|
|
case FL_PUSH:
|
|
|
|
|
{
|
2013-06-06 00:58:52 +02:00
|
|
|
|
if ( learn_mode() )
|
|
|
|
|
{
|
|
|
|
|
tooltip( "Now learning control. Move the desired control on your controller" );
|
|
|
|
|
|
|
|
|
|
//connect_to( &module->control_input[port] );
|
|
|
|
|
Port *p = control_output[0].connected_port();
|
|
|
|
|
|
|
|
|
|
if ( p )
|
|
|
|
|
{
|
2013-07-09 06:53:20 +02:00
|
|
|
|
const char * path = learn_by_number ? p->osc_number_path() : p->osc_path();
|
2013-06-06 01:26:36 +02:00
|
|
|
|
|
2013-07-09 06:53:20 +02:00
|
|
|
|
DMESSAGE( "Will learn %s", path );
|
2013-06-06 00:58:52 +02:00
|
|
|
|
|
2013-07-09 06:53:20 +02:00
|
|
|
|
mixer->osc_endpoint->learn( path );
|
2013-06-06 00:58:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( Fl::event_button3() )
|
2010-02-24 16:05:46 +01:00
|
|
|
|
{
|
|
|
|
|
/* context menu */
|
2013-06-22 02:23:17 +02:00
|
|
|
|
/* if ( type() != SPATIALIZATION ) */
|
2010-02-25 00:25:56 +01:00
|
|
|
|
menu_popup( &menu() );
|
2010-02-24 16:05:46 +01:00
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return Fl_Group::handle( m );
|
2010-01-21 07:50:12 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
return Fl_Group::handle( m );
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-24 16:05:46 +01:00
|
|
|
|
void
|
2012-02-09 07:38:34 +01:00
|
|
|
|
Controller_Module::handle_control_changed ( Port *p )
|
2010-02-24 16:05:46 +01:00
|
|
|
|
{
|
|
|
|
|
/* ignore changes initiated while mouse is over widget */
|
2013-06-26 07:28:51 +02:00
|
|
|
|
|
|
|
|
|
if ( type() == SPATIALIZATION )
|
|
|
|
|
{
|
|
|
|
|
if ( Mixer::spatialization_console )
|
|
|
|
|
Mixer::spatialization_console->handle_control_changed( this );
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-24 16:05:46 +01:00
|
|
|
|
if ( contains( Fl::pushed() ) )
|
|
|
|
|
return;
|
|
|
|
|
|
2012-02-09 07:38:34 +01:00
|
|
|
|
if ( p )
|
|
|
|
|
control_value = p->control_value();
|
|
|
|
|
|
2012-02-20 08:19:15 +01:00
|
|
|
|
if ( control->value() == control_value )
|
|
|
|
|
return;
|
|
|
|
|
|
2012-02-10 10:06:35 +01:00
|
|
|
|
/* if ( control->value() != control_value ) */
|
|
|
|
|
/* { */
|
|
|
|
|
/* redraw(); */
|
|
|
|
|
/* } */
|
2012-02-09 04:03:48 +01:00
|
|
|
|
|
2010-02-25 00:25:56 +01:00
|
|
|
|
if ( type() == SPATIALIZATION )
|
2010-02-24 16:05:46 +01:00
|
|
|
|
{
|
|
|
|
|
Panner *pan = (Panner*)control;
|
|
|
|
|
|
|
|
|
|
pan->point( 0 )->azimuth( control_output[0].control_value() );
|
|
|
|
|
pan->point( 0 )->elevation( control_output[1].control_value() );
|
2012-02-10 13:01:02 +01:00
|
|
|
|
|
2013-06-27 08:49:29 +02:00
|
|
|
|
if ( control_output[2].connected() )
|
|
|
|
|
{
|
2013-08-24 05:41:17 +02:00
|
|
|
|
// Port *pp = control_output[2].connected_port();
|
2013-06-27 08:49:29 +02:00
|
|
|
|
float v = control_output[2].control_value();
|
2013-08-24 05:41:17 +02:00
|
|
|
|
// float s = pp->hints.maximum - pp->hints.minimum;
|
2013-06-27 08:49:29 +02:00
|
|
|
|
|
|
|
|
|
pan->point( 0 )->radius( v );
|
|
|
|
|
}
|
2013-06-25 02:17:15 +02:00
|
|
|
|
if ( visible_r() )
|
|
|
|
|
pan->redraw();
|
2010-02-24 16:05:46 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-02-10 10:06:35 +01:00
|
|
|
|
if ( type() == TOGGLE )
|
|
|
|
|
((Fl_Button*)control)->value(control_value);
|
|
|
|
|
else
|
|
|
|
|
control->value(control_value);
|
2010-02-24 16:05:46 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
2012-05-21 00:08:38 +02:00
|
|
|
|
void
|
|
|
|
|
Controller_Module::command_remove ( void )
|
|
|
|
|
{
|
|
|
|
|
if ( is_default() )
|
|
|
|
|
fl_alert( "Default modules may not be deleted." );
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
chain()->remove( this );
|
|
|
|
|
Fl::delete_widget( this );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-25 03:12:10 +01:00
|
|
|
|
/**********/
|
2013-08-06 09:03:19 +02:00
|
|
|
|
/* Client */
|
2010-01-25 03:12:10 +01:00
|
|
|
|
/**********/
|
2010-01-21 07:50:12 +01:00
|
|
|
|
|
2009-12-25 01:59:39 +01:00
|
|
|
|
void
|
2010-01-30 09:35:32 +01:00
|
|
|
|
Controller_Module::process ( nframes_t nframes )
|
2009-12-25 01:59:39 +01:00
|
|
|
|
{
|
2010-01-14 04:19:12 +01:00
|
|
|
|
THREAD_ASSERT( RT );
|
|
|
|
|
|
2010-02-25 00:25:56 +01:00
|
|
|
|
if ( type() == SPATIALIZATION )
|
2010-02-24 16:05:46 +01:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( control_output[0].connected() )
|
2009-12-25 01:59:39 +01:00
|
|
|
|
{
|
|
|
|
|
float f = control_value;
|
|
|
|
|
|
|
|
|
|
if ( mode() == CV )
|
|
|
|
|
{
|
2013-08-06 09:03:19 +02:00
|
|
|
|
f = *((float*)aux_audio_input[0].jack_port()->buffer( nframes ));
|
2009-12-25 01:59:39 +01:00
|
|
|
|
|
|
|
|
|
const Port *p = control_output[0].connected_port();
|
|
|
|
|
|
|
|
|
|
if (p->hints.ranged )
|
|
|
|
|
{
|
|
|
|
|
// scale value to range.
|
|
|
|
|
// we assume that CV values are between 0 and 1
|
|
|
|
|
|
|
|
|
|
float scale = p->hints.maximum - p->hints.minimum;
|
|
|
|
|
float offset = p->hints.minimum;
|
|
|
|
|
|
|
|
|
|
f = ( f * scale ) + offset;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// else
|
|
|
|
|
// f = *((float*)control_output[0].buffer());
|
|
|
|
|
|
|
|
|
|
*((float*)control_output[0].buffer()) = f;
|
|
|
|
|
|
2010-02-24 16:05:46 +01:00
|
|
|
|
control_value = f;
|
2009-12-25 01:59:39 +01:00
|
|
|
|
}
|
|
|
|
|
}
|