Changeset 565

Show
Ignore:
Timestamp:
10/15/08 12:51:48 (2 months ago)
Author:
smoors
Message:

added midi-action which controls the effect level ( absoulute only )

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/midiAutosense/libs/hydrogen/src/action.cpp

    r564 r565  
    8989        << "STRIP_VOLUME_RELATIVE" 
    9090        << "STRIP_VOLUME_ABSOLUTE" 
     91        << "EFFECT1_LEVEL_RELATIVE" 
     92        << "EFFECT2_LEVEL_RELATIVE" 
     93        << "EFFECT3_LEVEL_RELATIVE" 
     94        << "EFFECT4_LEVEL_RELATIVE" 
     95        << "EFFECT1_LEVEL_ABSOLUTE" 
     96        << "EFFECT2_LEVEL_ABSOLUTE" 
     97        << "EFFECT3_LEVEL_ABSOLUTE" 
     98        << "EFFECT4_LEVEL_ABSOLUTE" 
    9199        << "PAN_RELATIVE" 
    92100        << "PAN_ABSOULTE" 
     
    132140} 
    133141 
     142 
     143 
     144bool setAbsoluteFXLevel( int nLine, int fx_channel , int fx_param) 
     145{ 
     146        //helper function to set fx levels 
     147                         
     148        Hydrogen::get_instance()->setSelectedInstrumentNumber( nLine ); 
     149 
     150        Hydrogen *engine = Hydrogen::get_instance(); 
     151        Song *song = engine->getSong(); 
     152        InstrumentList *instrList = song->get_instrument_list(); 
     153        Instrument *instr = instrList->get( nLine ); 
     154        if ( instr == NULL) return false; 
     155 
     156        if( fx_param != 0 ){ 
     157                        instr->set_fx_level(  ( (float) (fx_param / 127.0 ) ), fx_channel ); 
     158        } else { 
     159                        instr->set_fx_level( 0 , fx_channel ); 
     160        } 
     161                 
     162        Hydrogen::get_instance()->setSelectedInstrumentNumber(nLine); 
     163         
     164        return true; 
     165 
     166} 
     167 
     168 
    134169bool actionManager::handleAction( action * pAction ){ 
    135170 
     
    212247                return true; 
    213248        } 
     249 
     250 
     251 
     252        if( sActionString == "STRIP_VOLUME_ABSOLUTE" ){ 
     253                //sets the volume of a mixer strip to a given level (percentage) 
     254 
     255                bool ok; 
     256                int nLine = pAction->getParameter1().toInt(&ok,10); 
     257                int vol_param = pAction->getParameter2().toInt(&ok,10); 
     258                         
     259 
     260                Hydrogen *engine = Hydrogen::get_instance(); 
     261                Song *song = engine->getSong(); 
     262 
     263 
     264                if( vol_param != 0 ){ 
     265                                song->set_volume( 1.5* ( (float) (vol_param / 127.0 ) )); 
     266                } else { 
     267                                song->set_volume( 0 ); 
     268                } 
     269 
     270        } 
     271 
     272        if( sActionString == "STRIP_VOLUME_RELATIVE" ){ 
     273                //increments/decrements the volume of one mixer strip    
     274                 
     275                bool ok; 
     276                int nLine = pAction->getParameter1().toInt(&ok,10); 
     277                int vol_param = pAction->getParameter2().toInt(&ok,10); 
     278                         
     279                Hydrogen::get_instance()->setSelectedInstrumentNumber( nLine ); 
     280 
     281                Hydrogen *engine = Hydrogen::get_instance(); 
     282                Song *song = engine->getSong(); 
     283                InstrumentList *instrList = song->get_instrument_list(); 
     284 
     285                Instrument *instr = instrList->get( nLine ); 
     286 
     287                if ( instr == NULL) return 0; 
     288 
     289                if( vol_param != 0 ){ 
     290                                if ( vol_param == 1 && instr->get_volume() < 1.5 ){ 
     291                                        instr->set_volume( instr->get_volume() + 0.1 );   
     292                                }  else  { 
     293                                        if( instr->get_volume() >= 0.0 ){ 
     294                                                instr->set_volume( instr->get_volume() - 0.1 ); 
     295                                        } 
     296                                } 
     297                } else { 
     298                        instr->set_volume( 0 ); 
     299                } 
     300 
     301                Hydrogen::get_instance()->setSelectedInstrumentNumber(nLine); 
     302        } 
     303 
     304        if( sActionString == "EFFECT1_LEVEL_ABSOLUTE" ){ 
     305                bool ok; 
     306                int nLine = pAction->getParameter1().toInt(&ok,10); 
     307                int fx_param = pAction->getParameter2().toInt(&ok,10); 
     308                setAbsoluteFXLevel( nLine, 0 , fx_param ); 
     309        } 
     310 
     311        if( sActionString == "EFFECT2_LEVEL_ABSOLUTE" ){ 
     312                bool ok; 
     313                int nLine = pAction->getParameter1().toInt(&ok,10); 
     314                int fx_param = pAction->getParameter2().toInt(&ok,10); 
     315                setAbsoluteFXLevel( nLine, 1 , fx_param ); 
     316        } 
     317 
     318        if( sActionString == "EFFECT3_LEVEL_ABSOLUTE" ){ 
     319                bool ok; 
     320                int nLine = pAction->getParameter1().toInt(&ok,10); 
     321                int fx_param = pAction->getParameter2().toInt(&ok,10); 
     322                setAbsoluteFXLevel( nLine, 2 , fx_param ); 
     323        } 
     324 
     325        if( sActionString == "EFFECT4_LEVEL_ABSOLUTE" ){ 
     326                bool ok; 
     327                int nLine = pAction->getParameter1().toInt(&ok,10); 
     328                int fx_param = pAction->getParameter2().toInt(&ok,10); 
     329                setAbsoluteFXLevel( nLine, 3 , fx_param ); 
     330        } 
     331 
    214332 
    215333