Beispiel #1
0
void
Module::insert_menu_cb ( const Fl_Menu_ *m )
{
    if ( ! m->mvalue() || m->mvalue()->flags & FL_SUBMENU_POINTER || m->mvalue()->flags & FL_SUBMENU )
        return;

    void * v = m->mvalue()->user_data();

    if ( v )
    {
        unsigned long id = *((unsigned long *)v);

        Module *mod = NULL;

        switch ( id )
        {
            case 1:
                mod = new JACK_Module();
                break;
            case 2:
                mod = new Gain_Module();
                break;
            case 3:
                mod = new Meter_Module();
                break;
            case 4:
                mod = new Mono_Pan_Module();
                break;
            default:
            {
                Plugin_Module *m = new Plugin_Module();

                m->load( id );

                mod = m;
            }
        }

        if ( mod )
        {
            if ( !strcmp( mod->name(), "JACK" ) )
            {
                DMESSAGE( "Special casing JACK module" );
                JACK_Module *jm = (JACK_Module*)mod;
                jm->chain( chain() );
                jm->configure_inputs( ninputs() );
                jm->configure_outputs( ninputs() );
            }

            if ( ! chain()->insert( this, mod ) )
            {
                fl_alert( "Cannot insert this module at this point in the chain" );
                delete mod;
                return;
            }

            redraw();
        }
    }
}
Beispiel #2
0
Datei: Module.C Projekt: 0mk/non
void
Module::insert_menu_cb ( const Fl_Menu_ *m )
{
    
    const char * picked =  m->mvalue()->label();

    DMESSAGE("picked = %s", picked );

    Module *mod = NULL;
    
    if ( !strcmp( picked, "Aux" ) )
    {
        int n = 0;
        for ( int i = 0; i < chain()->modules(); i++ )
        {
            if ( !strcmp( chain()->module(i)->name(), "AUX" ) )
                n++;
        }

        AUX_Module *jm = new AUX_Module();
        jm->chain( chain() );
        jm->number( n );
        jm->configure_inputs( ninputs() );
        jm->configure_outputs( ninputs() );
        jm->initialize();
     
        mod = jm;
    }
    if ( !strcmp( picked, "Spatializer" ) )
    {
        int n = 0;
        for ( int i = 0; i < chain()->modules(); i++ )
        {
            if ( !strcmp( chain()->module(i)->name(), "Spatializer" ) )
                n++;
        }

        if ( n == 0 )
        {
            Spatializer_Module *jm = new Spatializer_Module();
            
            jm->chain( chain() );
//        jm->number( n );
//        jm->configure_inputs( ninputs() );
//        jm->configure_outputs( ninputs() );
            jm->initialize();
            
            mod = jm;
        }
    }
    else if ( !strcmp( picked, "Gain" ) )
            mod = new Gain_Module();
    /* else if ( !strcmp( picked, "Spatializer" ) ) */
    /*         mod = new Spatializer_Module(); */
    else if ( !strcmp( picked, "Meter" ) )
        mod = new Meter_Module();
    else if ( !strcmp( picked, "Mono Pan" ))
        mod = new Mono_Pan_Module();
    else if ( !strcmp(picked, "Plugin" ))
    {
        unsigned long id = Plugin_Chooser::plugin_chooser( this->ninputs() );
        
        if ( id == 0 )
            return;
        
        Plugin_Module *m = new Plugin_Module();
        
        m->load( id );
        
        mod = m;
    }

    if ( mod )
    {
        if ( ! chain()->insert( this, mod ) )
        {
            fl_alert( "Cannot insert this module at this point in the chain" );
            delete mod;
            return;
        }

        redraw();
    }
}