Changeset 166

Show
Ignore:
Timestamp:
05/26/08 23:46:37 (5 years ago)
Author:
smoors
Message:

added experimental support for customizable note messages

Location:
trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/gui/src/PreferencesDialog.cpp

    r159 r166  
    389389 
    390390 
     391 
    391392void PreferencesDialog::setupMidiTable() 
    392393{ 
     
    446447 
    447448                QString actionParameter; 
    448                 if(pAction->getParameterList().size() != 0){ 
     449                if( pAction->getParameterList().size() != 0 ){ 
    449450                        actionParameter = pAction->getParameterList().at(0); 
    450451                } 
     
    457458                tableWidget->setCellWidget( rowCount , 3, actionParameterSpinner ); 
    458459                rowCount++; 
     460        } 
     461 
     462        for( int note = 0; note < 128; note++ ){ 
     463                 
     464                QString eventString = "NOTE"; 
     465                 
     466                action * pAction = mM->getNoteAction( note ); 
     467                if( pAction->getType() != "NOTHING" ){ 
     468                        cout << note << pAction << endl; 
     469                         
     470                        tableWidget->insertRow( tableWidget->rowCount() ); 
     471                        QComboBox *eventBox = new QComboBox(); 
     472                        eventBox->insertItems( rowCount , aH->getEventList() ); 
     473                        eventBox->setCurrentIndex( eventBox->findText(eventString) ); 
     474                        tableWidget->setCellWidget( rowCount, 0, eventBox ); 
     475                         
     476                        QSpinBox *eventParameterSpinner = new QSpinBox(); 
     477                        tableWidget->setCellWidget( rowCount , 1, eventParameterSpinner ); 
     478                        eventParameterSpinner->setValue( note ); 
     479                         
     480                        QComboBox *actionBox = new QComboBox(); 
     481                        actionBox->insertItems(rowCount,aH->getActionList()); 
     482                        actionBox->setCurrentIndex ( actionBox->findText(pAction->getType() ) ); 
     483                        tableWidget->setCellWidget( rowCount , 2, actionBox ); 
     484                 
     485         
     486                        QString actionParameter; 
     487                        QSpinBox *actionParameterSpinner = new QSpinBox(); 
     488 
     489                        if( pAction->getParameterList().size() > 0 ){ 
     490                                actionParameter = pAction->getParameterList().at(0); 
     491                                bool ok; 
     492                                actionParameterSpinner->setValue( actionParameter.toInt(&ok,10) ); 
     493                        } 
     494         
     495                        tableWidget->setCellWidget( rowCount , 3, actionParameterSpinner ); 
     496                        rowCount++; 
     497                } 
    459498        } 
    460499         
     
    490529                QComboBox * eventCombo =  dynamic_cast <QComboBox *> ( tableWidget->cellWidget( row, 0 ) ); 
    491530         
     531                QSpinBox * eventSpinner = dynamic_cast <QSpinBox *> ( tableWidget->cellWidget( row, 1 ) ); 
     532 
    492533                QComboBox * actionCombo = dynamic_cast <QComboBox *> ( tableWidget->cellWidget( row, 2 ) ); 
    493534 
    494535                QSpinBox * actionSpinner = dynamic_cast <QSpinBox *> ( tableWidget->cellWidget( row, 3 ) ); 
     536 
     537                 
    495538 
    496539                QString eventString; 
    497540                QString actionString; 
     541                 
    498542 
    499543                if( eventCombo->currentText() != "" && actionCombo->currentText() != "" ){ 
     
    508552                        } 
    509553         
    510                         mM->registerMMCEvent( eventString , pAction ); 
     554                        if( eventString.left(3) == "MMC" ){ 
     555                                mM->registerMMCEvent( eventString , pAction ); 
     556                        } 
     557                         
     558                        if( eventString.left(4) == "NOTE" ){ 
     559                                mM->registerNoteEvent( eventSpinner->cleanText().toInt() , pAction ); 
     560                                cout << "register " << eventSpinner->value() << endl; 
     561                        } 
    511562                } 
    512563        } 
  • trunk/libs/hydrogen/include/hydrogen/action.h

    r158 r166  
    5353 
    5454                void registerMMCEvent( QString,action * ); 
     55                void registerNoteEvent( int , action * ); 
     56 
     57                map <QString , action *> getMMCMap(); 
    5558 
    5659                action * getMMCAction( QString ); 
     60                action * getNoteAction( int note ); 
     61 
     62                void setupNoteArray(); 
    5763                 
    58                 map <QString , action *> getMMCMap(); 
     64                 
     65 
     66        private: 
     67 
     68                action * noteArray[128]; 
    5969                map <QString , action *> mmcMap; 
    6070}; 
  • trunk/libs/hydrogen/src/IO/midi_input.cpp

    r146 r166  
    3737{ 
    3838        //INFOLOG( "INIT" ); 
     39         
    3940} 
    4041 
     
    132133{ 
    133134        INFOLOG( "handleNoteOnMessage" ); 
     135 
     136        actionManager * aH = actionManager::getInstance(); 
     137        midiMap * mM = midiMap::getInstance(); 
     138 
     139        aH->handleAction( mM->getNoteAction( msg.m_nData1 ) ); 
    134140 
    135141        int nMidiChannelFilter = Preferences::getInstance()->m_nMidiChannelFilter; 
  • trunk/libs/hydrogen/src/action.cpp

    r159 r166  
    6161{ 
    6262        //constructor 
     63        for(int note = 0; note < 128; note++ ){ 
     64                noteArray[ note ] = new action("NOTHING"); 
     65        } 
    6366} 
    6467 
     
    6669{ 
    6770        std::map< QString , action *>::iterator dIter(mmcMap.begin()); 
     71 
    6872        for( dIter = mmcMap.begin(); dIter != mmcMap.end(); dIter++ ) 
    6973        { 
    7074                delete dIter->second; 
    7175        } 
     76 
     77        for(int i = 0; i < 128; i++){ 
     78                delete noteArray[i]; 
     79        } 
     80 
    7281        instance = NULL; 
    7382} 
     
    8897} 
    8998 
     99void midiMap::registerNoteEvent( int note , action * pAction ){ 
     100         
     101        if( note >= 0 && note < 128 ){ 
     102                delete noteArray[ note ]; 
     103                noteArray[ note ] = pAction; 
     104        } 
     105} 
    90106 
    91107action * midiMap::getMMCAction( QString eventString ){ 
     
    100116} 
    101117 
    102  
     118action * midiMap::getNoteAction( int note ){ 
     119        return noteArray[ note ]; 
     120} 
    103121 
    104122 
     
    127145        << "MMC_RECORD_STROBE" 
    128146        << "MMC_RECORD_EXIT" 
    129         << "MMC_PAUSE"; 
     147        << "MMC_PAUSE" 
     148        << "NOTE"; 
    130149} 
    131150 
  • trunk/libs/hydrogen/src/preferences.cpp

    r159 r166  
    421421                                                 
    422422                                        } 
     423 
     424                                         
     425                                        if( pMidiEventNode->FirstChild()->Value() == QString("noteEvent")){ 
     426                                                QString event = pMidiEventNode->FirstChild("noteEvent")->FirstChild()->Value(); 
     427         
     428                                                QString s_action = pMidiEventNode->FirstChild("action")->FirstChild()->Value(); 
     429 
     430                                                //QString s_param = pMidiEventNode->FirstChild("parameter")->FirstChild()->Value(); 
     431 
     432                                                QString s_eventParameter = pMidiEventNode->FirstChild("eventParameter")->FirstChild()->Value(); 
     433         
     434                                                action * pAction = new action( s_action ); 
     435 
     436                                         
     437                                                //pAction->addParameter( s_param ); 
     438                                 
     439                                                mM->registerNoteEvent(s_eventParameter.toInt(), pAction); 
     440                                        } 
    423441                                } 
    424442                        } else { 
     
    643661        { 
    644662                 
    645                 std::map< QString , action *>::iterator dIter(mmcMap.begin()); 
     663                std::map< QString , action *>::iterator dIter( mmcMap.begin() ); 
    646664                for( dIter = mmcMap.begin(); dIter != mmcMap.end(); dIter++ ){ 
    647665                         
     
    665683                                midiEventMapNode.InsertEndChild(midiEventNode); 
    666684 
     685                        } 
     686                } 
     687                 
     688                for( int note=0; note < 128; note++ ){ 
     689                        action * pAction = mM->getNoteAction( note ); 
     690                        if( pAction != NULL && pAction->getType() != "NOTHING") 
     691                        { 
     692                                TiXmlElement midiEventNode( "midiEvent" ); 
     693                                 
     694                                LocalFileMng::writeXmlString( &midiEventNode, "noteEvent" , QString("NOTE") ); 
     695                                LocalFileMng::writeXmlString( &midiEventNode, "eventParameter" , QString::number( note ) ); 
     696 
     697                                LocalFileMng::writeXmlString( &midiEventNode, "action" , pAction->getType() ); 
     698 
     699                                if ( pAction->getParameterList().size() != 0 ){ 
     700                                        LocalFileMng::writeXmlString( &midiEventNode, "parameter" , pAction->getParameterList().at(0) ); 
     701                                } 
     702 
     703                                midiEventMapNode.InsertEndChild(midiEventNode); 
    667704                        } 
    668705                }