Browse Source

Mixer: Cleanup OSC value scaling/clamping behavior.

tags/non-daw-v1.1.0
Jonathan Moore Liles 13 years ago
parent
commit
a11961f9b6
2 changed files with 20 additions and 20 deletions
  1. +17
    -17
      mixer/src/Module.C
  2. +3
    -3
      mixer/src/Module.H

+ 17
- 17
mixer/src/Module.C View File

@@ -235,28 +235,25 @@ Module::Port::change_osc_path ( char *path )
if ( _osc_path )
{
mixer->osc_endpoint->del_method( _osc_path, "f" );
mixer->osc_endpoint->del_method( _osc_path_cv, "f" );
mixer->osc_endpoint->del_method( _osc_path_unscaled, "f" );

free( _osc_path );
free( _osc_path_cv );
free( _osc_path_unscaled );
_osc_path = NULL;
_osc_path_cv = NULL;
_osc_path_unscaled = NULL;
}

if ( path )
{
_osc_path_cv = NULL;

asprintf( &_osc_path_cv, "%s/unscaled", path );

mixer->osc_endpoint->add_method( path, "f", &Module::Port::osc_control_change_cv, this, "value" );
_osc_path_unscaled = NULL;
_osc_path = path;

mixer->osc_endpoint->add_method( _osc_path_cv, "f", &Module::Port::osc_control_change_exact, this, "value" );
asprintf( &_osc_path_unscaled, "%s/unscaled", path );

_osc_path = path;
mixer->osc_endpoint->add_method( _osc_path, "f", &Module::Port::osc_control_change_cv, this, "value" );

// tooltip( _osc_path );
mixer->osc_endpoint->add_method( _osc_path_unscaled, "f", &Module::Port::osc_control_change_exact, this, "value" );
}
}

@@ -266,8 +263,6 @@ Module::Port::osc_control_change_exact ( const char *path, const char *types, lo
{
Module::Port *p = (Module::Port*)user_data;

OSC_DMSG();

float f = argv[0]->f;

if ( p->hints.ranged )
@@ -281,7 +276,7 @@ Module::Port::osc_control_change_exact ( const char *path, const char *types, lo
p->control_value( f );

// mixer->osc_endpoint->send( lo_message_get_source( msg ), "/reply", path, "ok" );
mixer->osc_endpoint->send( lo_message_get_source( msg ), path, argv[0]->f );
mixer->osc_endpoint->send( lo_message_get_source( msg ), path, f );

return 0;
}
@@ -293,10 +288,15 @@ Module::Port::osc_control_change_cv ( const char *path, const char *types, lo_ar

float f = argv[0]->f;

if (p->hints.ranged )
// clamp value to control voltage range.
if ( f > 1.0 )
f = 1.0;
else if ( f < 0.0 )
f = 0.0;

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;
@@ -307,7 +307,7 @@ Module::Port::osc_control_change_cv ( const char *path, const char *types, lo_ar
p->control_value( f );

// mixer->osc_endpoint->send( lo_message_get_source( msg ), "/reply", path, "ok" );
mixer->osc_endpoint->send( lo_message_get_source( msg ), path, argv[0]->f );
mixer->osc_endpoint->send( lo_message_get_source( msg ), path, f );

return 0;
}


+ 3
- 3
mixer/src/Module.H View File

@@ -125,7 +125,7 @@ public:
_connected = 0;
_module = module;
_osc_path = 0;
_osc_path_cv = 0;
_osc_path_unscaled = 0;
}

Port ( const Port& p )
@@ -139,7 +139,7 @@ public:
_module = p._module;
hints = p.hints;
_osc_path = p._osc_path;
_osc_path_cv = p._osc_path;
_osc_path_unscaled = p._osc_path_unscaled;
}

virtual ~Port ( )
@@ -247,7 +247,7 @@ public:
Module *_module;

char *_osc_path;
char *_osc_path_cv;
char *_osc_path_unscaled;
};

void bbox ( int &X, int &Y, int &W, int &H )


Loading…
Cancel
Save