Mixer: Fix azimuth/elevation reporting. Load current values in Module_Parameter_Editor.

This commit is contained in:
Jonathan Moore Liles 2010-02-14 15:20:50 -06:00
parent d12bdc27a4
commit 82583365f6
3 changed files with 35 additions and 9 deletions

View File

@ -135,7 +135,9 @@ Module_Parameter_Editor::make_controls ( void )
/* these are for detecting related parameter groups which can be /* these are for detecting related parameter groups which can be
better represented by a single control */ better represented by a single control */
int azimuth_port_number = -1; int azimuth_port_number = -1;
float azimuth_value;
int elevation_port_number = -1; int elevation_port_number = -1;
float elevation_value;
for ( unsigned int i = 0; i < module->control_input.size(); ++i ) for ( unsigned int i = 0; i < module->control_input.size(); ++i )
{ {
@ -143,14 +145,20 @@ Module_Parameter_Editor::make_controls ( void )
Module::Port *p = &module->control_input[i]; Module::Port *p = &module->control_input[i];
if ( !strcasecmp( "Azimuth", p->name() ) ) if ( !strcasecmp( "Azimuth", p->name() ) &&
180.0f == p->hints.maximum &&
-180.0f == p->hints.minimum )
{ {
azimuth_port_number = i; azimuth_port_number = i;
azimuth_value = p->control_value();
continue; continue;
} }
else if ( !strcasecmp( "Elevation", p->name() ) ) else if ( !strcasecmp( "Elevation", p->name() ) &&
90.0f == p->hints.maximum &&
-90.0f == p->hints.minimum )
{ {
elevation_port_number = i; elevation_port_number = i;
elevation_value = p->control_value();
continue; continue;
} }
@ -288,7 +296,12 @@ Module_Parameter_Editor::make_controls ( void )
o->labelsize( 10 ); o->labelsize( 10 );
o->callback( cb_panner_value_handle, new callback_data( this, azimuth_port_number, elevation_port_number ) ); o->callback( cb_panner_value_handle, new callback_data( this, azimuth_port_number, elevation_port_number ) );
control_pack->add( o ); o->point( 0 )->azimuth( azimuth_value );
o->point( 0 )->elevation( elevation_value );
Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( o );
control_pack->add( flg );
} }
@ -312,8 +325,8 @@ Module_Parameter_Editor::cb_panner_value_handle ( Fl_Widget *w, void *v )
{ {
callback_data *cd = (callback_data*)v; callback_data *cd = (callback_data*)v;
cd->base_widget->set_value( cd->port_number[0], ((Panner*)w)->point( 0 ).azimuth() ); cd->base_widget->set_value( cd->port_number[0], ((Panner*)w)->point( 0 )->azimuth() );
cd->base_widget->set_value( cd->port_number[1], ((Panner*)w)->point( 0 ).elevation() ); cd->base_widget->set_value( cd->port_number[1], ((Panner*)w)->point( 0 )->elevation() );
} }
void void

View File

@ -263,10 +263,10 @@ Panner::draw ( void )
} }
/* return the current gain setting for the path in/out */ /* return the current gain setting for the path in/out */
Panner::Point Panner::Point *
Panner::point( int i ) Panner::point( int i )
{ {
return _points[ i ]; return &_points[ i ];
} }
int int

View File

@ -56,14 +56,27 @@ class Panner : public Fl_Widget
float azimuth ( void ) const float azimuth ( void ) const
{ {
return a; return a > 180.0f ? a - 360.0f : a;
} }
float elevation ( void ) const float elevation ( void ) const
{ {
return ( 1.0f - d ) * 90.0f; return ( 1.0f - d ) * 90.0f;
} }
void azimuth ( float v )
{
a = v < -180.0f ? 360.0f - v : v;
a = a < 0.0f ? 0.0f : a > 360.0f ? 360.0f : a;
}
void elevation ( float v )
{
d = 1.0f - ( v / 90.0f );
d = d < 0.0f ? 0.0f : d > 1.0f ? 1.0f : d;
}
/** set point position in X, Y coordinates (0.0 to 1.0) */ /** set point position in X, Y coordinates (0.0 to 1.0) */
void void
angle ( float X1, float Y1 ) angle ( float X1, float Y1 )
@ -179,6 +192,6 @@ public:
virtual ~Panner ( ) { } virtual ~Panner ( ) { }
Panner::Point point ( int i ); Panner::Point *point ( int i );
}; };