Browse Source

Mixer: Give better visual feedback in control OSC/MIDI learning mode.

tags/non-daw-v1.3.0
Jonathan Moore Liles 4 years ago
parent
commit
a2089421b1
4 changed files with 44 additions and 5 deletions
  1. +26
    -2
      mixer/src/Controller_Module.C
  2. +4
    -0
      mixer/src/Controller_Module.H
  3. +11
    -2
      nonlib/OSC/Endpoint.C
  4. +3
    -1
      nonlib/OSC/Endpoint.H

+ 26
- 2
mixer/src/Controller_Module.C View File

@@ -50,6 +50,9 @@

bool Controller_Module::learn_by_number = false;
bool Controller_Module::_learn_mode = false;

Controller_Module* Controller_Module::_learning_control = NULL;


void
@@ -836,10 +839,27 @@ Controller_Module::draw ( void )

if ( learn_mode() )
{
fl_rectf( x(),y(),w(),h(), fl_color_add_alpha( FL_MAGENTA, 50 ) );
fl_rectf( x(),y(),w(),h(),
fl_color_add_alpha(
this == _learning_control
? FL_RED
: FL_GREEN,
60 ) );
}
}

void Controller_Module::learning_callback ( void *userdata )
{
((Controller_Module*)userdata)->learning_callback();
}

void Controller_Module::learning_callback ( void )
{
_learning_control = NULL;
this->redraw();
}


int
Controller_Module::handle ( int m )
{
@@ -852,6 +872,10 @@ Controller_Module::handle ( int m )
{
tooltip( "Now learning control. Move the desired control on your controller" );

_learning_control = this;
this->redraw();
//connect_to( &module->control_input[port] );
Port *p = control_output[0].connected_port();
@@ -861,7 +885,7 @@ Controller_Module::handle ( int m )

DMESSAGE( "Will learn %s", path );

mixer->osc_endpoint->learn( path );
mixer->osc_endpoint->learn( path, Controller_Module::learning_callback, this );
}

return 1;


+ 4
- 0
mixer/src/Controller_Module.H View File

@@ -47,9 +47,13 @@ class Controller_Module : public Module
void add_osc_peers_to_menu ( Fl_Menu_Button *m, const char *prefix );
void add_osc_connections_to_menu ( Fl_Menu_Button *m, const char *prefix );

static void learning_callback ( void *userdata );
void learning_callback ( void );
public:

static bool _learn_mode;
static Controller_Module *_learning_control;

static bool learn_by_number;
static bool learn_mode ( void ) { return _learn_mode; }


+ 11
- 2
nonlib/OSC/Endpoint.C View File

@@ -187,6 +187,7 @@ namespace OSC
Endpoint::Endpoint ( )
{
_learning_path = NULL;
_learning_callback = NULL;
_peer_signal_notification_callback = 0;
_peer_signal_notification_userdata = 0;
_peer_scan_complete_callback = 0;
@@ -685,8 +686,13 @@ namespace OSC
DMESSAGE( "Learned translation \"%s\" -> \"%s\"", path, ep->_learning_path );
free(ep->_learning_path);

ep->_learning_callback(ep->_learning_userdata);

ep->_learning_userdata = NULL;
ep->_learning_callback = NULL;
ep->_learning_path = NULL;
return 0;
}

@@ -1066,13 +1072,16 @@ namespace OSC

/* prepare to learn a translation for /path/. The next unhandled message to come through will be mapped to /path/ */
void
Endpoint::learn ( const char *path )
Endpoint::learn ( const char *path, void (*callback)(void*), void *userdata )
{
if ( _learning_path )
free( _learning_path );

_learning_path = NULL;

_learning_callback = callback;
_learning_userdata = userdata;

if ( path )
_learning_path = strdup( path );
}


+ 3
- 1
nonlib/OSC/Endpoint.H View File

@@ -241,6 +241,8 @@ namespace OSC
std::list<Method*> _methods;

char *_learning_path;
void (*_learning_callback)(void *);
void *_learning_userdata;

class TranslationDestination {

@@ -305,7 +307,7 @@ namespace OSC
public:

void send_feedback ( const char *path, float v );
void learn ( const char *path );
void learn ( const char *path, void (*callback)(void*), void *userdata );

lo_address address ( void )
{


Loading…
Cancel
Save