Ejemplo n.º 1
0
/** 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 )
{
    connect_spatializer_radius_to( m );
    
    /* 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;
        }
    }
    
    if ( ! ( azimuth_port && elevation_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[0].connect_to( azimuth_port );
    control_output[1].connect_to( elevation_port );

    maybe_create_panner();
    
    Panner *o = (Panner*)control;

    o->point( 0 )->azimuth( azimuth_value );
    o->point( 0 )->elevation( elevation_value );
   
    if ( Mixer::spatialization_console )
        Mixer::spatialization_console->update();

    return true;
}
Ejemplo n.º 2
0
void
Controller_Module::handle_control_changed ( Port *p )
{
    /* ignore changes initiated while mouse is over widget */
    if ( contains( Fl::pushed() ) )
        return;

    if ( p )
        control_value = p->control_value();

    if ( control->value() == control_value )
        return;

    /* if ( control->value() != control_value ) */
    /* { */
    /*     redraw(); */
    /* } */

    if ( type() == SPATIALIZATION )
    {
        Panner *pan = (Panner*)control;

        pan->point( 0 )->azimuth( control_output[0].control_value() );
        pan->point( 0 )->elevation( control_output[1].control_value() );

        pan->redraw();
    }
    else
    {
        if ( type() == TOGGLE )
            ((Fl_Button*)control)->value(control_value);
        else
            control->value(control_value);
    }
}
Ejemplo n.º 3
0
	Panner *SimpleGui::addPanner(string name, float &value, float min, float max) {
		Panner *slider = (Panner*)INSTANTIATE_WITH_ID("panner", name);
		slider->min = min;
		slider->max = max;
		slider->width = SIMPLE_GUI_WIDTH;
		slider->pointToValue(&value);
		slider->showValue = true;
		gui->addChild(slider);
		return slider;
	}
Ejemplo n.º 4
0
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() );
    }
}
Ejemplo n.º 5
0
void
Controller_Module::handle_control_changed ( Port *p )
{
    /* ignore changes initiated while mouse is over widget */

    if ( type() == SPATIALIZATION )
    {
        if ( Mixer::spatialization_console )
            Mixer::spatialization_console->handle_control_changed( this );
    }

    if ( contains( Fl::pushed() ) )
        return;

    if ( p )
        control_value = p->control_value();

    if ( control->value() == control_value )
        return;

    /* if ( control->value() != control_value ) */
    /* { */
    /*     redraw(); */
    /* } */

    if ( type() == SPATIALIZATION )
    {
        Panner *pan = (Panner*)control;

        pan->point( 0 )->azimuth( control_output[0].control_value() );
        pan->point( 0 )->elevation( control_output[1].control_value() );

        if ( control_output[2].connected() )
        {
//            Port *pp = control_output[2].connected_port();
            float v = control_output[2].control_value();
//            float s = pp->hints.maximum - pp->hints.minimum;

            pan->point( 0 )->radius( v );
        }
        if ( visible_r() )
            pan->redraw();
    }
    else
    {
        if ( type() == TOGGLE )
            ((Fl_Button*)control)->value(control_value);
        else
            control->value(control_value);
    }
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
Graph::Graph(QWidget *parent) : QwtPlot(parent)
{
    // zoom in/out with the wheel
    Magnifier *magnifier = new Magnifier( canvas() );
    magnifier->setMouseButton(Qt::NoButton);

    // panning with the left mouse button
    Panner *panner =  new Panner( canvas() );
    panner->setMouseButton(Qt::LeftButton);

    // zooming with middle button
    QwtPlotZoomer *zoomer = new QwtPlotZoomer(canvas());
    {
        QVector<QwtEventPattern::MousePattern> pattern(6);
        pattern[0].button = Qt::MiddleButton;
        zoomer->setMousePattern(pattern);
    }

    m_grid = new QwtPlotGrid();
    m_grid->setMinorPen(QPen(Qt::gray, 0.0, Qt::DotLine));
    m_grid->setMajorPen(QPen(Qt::black, 0.0, Qt::DotLine));
    m_grid->enableX(true);
    m_grid->enableXMin(true);
    m_grid->enableY(true);
    m_grid->enableYMin(true);
    m_grid->attach(this);

    initLegend();

    connect(axisWidget(QwtPlot::xBottom), SIGNAL(scaleDivChanged()), SIGNAL(updateSampleSize()));

    setAxisScale(QwtPlot::xBottom, -20, 20);
    setAxisScale(QwtPlot::yRight, -20, 20);
    setAxisScale(QwtPlot::yLeft, -20, 20);
    axisWidget(QwtPlot::xBottom)->setToolTip(tr("Double-click to add marker"));
    axisWidget(QwtPlot::yLeft)->setToolTip(tr("Double-click to add marker"));
    axisWidget(QwtPlot::yRight)->setToolTip(tr("Double-click to add marker"));

    // to show graph appearance while dragging from add button to widget area
    replot();
}
Ejemplo n.º 8
0
/** 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 )
{
    /* 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;
        }
    }

    if ( ! ( azimuth_port && elevation_port ) )
        return false;

    control_output.clear();
    add_port( Port( this, Port::OUTPUT, Port::CONTROL ) );
    add_port( Port( this, Port::OUTPUT, Port::CONTROL ) );

    control_output[0].connect_to( azimuth_port );
    control_output[1].connect_to( elevation_port );

    {
        clear();

        Panner *o = new Panner( 0,0, 100, 100 );

        o->box(FL_THIN_UP_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->point( 0 )->azimuth( azimuth_value );
        o->point( 0 )->elevation( elevation_value );

        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
        {
            o->resize( x(), y(), w(), h() );
            add( o );
            resizable( o );
            init_sizes();
        }

        _type = SPATIALIZATION;
        return true;
    }
}
Ejemplo n.º 9
0
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
        {
//            o->clear_visible_focus();
            o->resize( x(), y(), w(), h() );
            add( o );
            resizable( o );
            init_sizes();
        }

        _type = SPATIALIZATION;
    }
}