Changeset 533
- Timestamp:
- 09/29/08 01:34:32 (2 months ago)
- Files:
-
- branches/jackMidi/gui/src/HydrogenApp.cpp (modified) (1 diff)
- branches/jackMidi/gui/src/MainForm.cpp (modified) (5 diffs)
- branches/jackMidi/gui/src/Mixer/Mixer.cpp (modified) (1 diff)
- branches/jackMidi/gui/src/Mixer/Mixer.h (modified) (1 diff)
- branches/jackMidi/gui/src/PatternEditor/DrumPatternEditor.cpp (modified) (1 diff)
- branches/jackMidi/gui/src/PatternEditor/PatternEditorInstrumentList.cpp (modified) (5 diffs)
- branches/jackMidi/gui/src/PatternEditor/PatternEditorInstrumentList.h (modified) (1 diff)
- branches/jackMidi/gui/src/SongEditor/SongEditor.cpp (modified) (2 diffs)
- branches/jackMidi/gui/src/SoundLibrary/SoundLibraryImportDialog.cpp (modified) (2 diffs)
- branches/jackMidi/gui/src/SoundLibrary/SoundLibraryPanel.cpp (modified) (10 diffs)
- branches/jackMidi/gui/src/SoundLibrary/SoundLibraryPanel.h (modified) (3 diffs)
- branches/jackMidi/gui/src/SoundLibrary/SoundLibraryPropertiesDialog.cpp (modified) (1 diff)
- branches/jackMidi/libs/hydrogen/include/hydrogen/Pattern.h (modified) (2 diffs)
- branches/jackMidi/libs/hydrogen/include/hydrogen/Song.h (modified) (1 diff)
- branches/jackMidi/libs/hydrogen/include/hydrogen/hydrogen.h (modified) (3 diffs)
- branches/jackMidi/libs/hydrogen/include/hydrogen/instrument.h (modified) (19 diffs)
- branches/jackMidi/libs/hydrogen/src/hydrogen.cpp (modified) (17 diffs)
- branches/jackMidi/libs/hydrogen/src/instrument.cpp (modified) (5 diffs)
- branches/jackMidi/libs/hydrogen/src/local_file_mgr.cpp (modified) (1 diff)
- branches/jackMidi/libs/hydrogen/src/pattern.cpp (modified) (2 diffs)
- branches/jackMidi/libs/hydrogen/src/sample.cpp (modified) (6 diffs)
- branches/jackMidi/libs/hydrogen/src/sampler/sampler.cpp (modified) (7 diffs)
- branches/jackMidi/libs/hydrogen/src/song.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/jackMidi/gui/src/HydrogenApp.cpp
r404 r533 351 351 void HydrogenApp::onEventQueueTimer() 352 352 { 353 // use the timer to do schedule instrument slaughter; 353 354 EventQueue *pQueue = EventQueue::get_instance(); 354 355 branches/jackMidi/gui/src/MainForm.cpp
r531 r533 496 496 h2app->setStatusBarMessage( trUtf8("Song saved."), 10000 ); 497 497 //update SoundlibraryPanel 498 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems(); 498 499 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList(); 499 500 } … … 536 537 } 537 538 //update SoundlibraryPanel 539 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems(); 538 540 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList(); 539 541 } … … 622 624 623 625 //update SoundlibraryPanel 626 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems(); 624 627 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList(); 625 628 } … … 921 924 void MainForm::action_instruments_importLibrary() 922 925 { 923 SoundLibraryImportDialog dialog( this );924 dialog.exec();926 SoundLibraryImportDialog dialog( this ); 927 dialog.exec(); 925 928 } 926 929 … … 929 932 void MainForm::action_instruments_saveLibrary() 930 933 { 931 SoundLibrarySaveDialog dialog( this );932 dialog.exec();933 934 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList();934 SoundLibrarySaveDialog dialog( this ); 935 dialog.exec(); 936 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems(); 937 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList(); 935 938 } 936 939 branches/jackMidi/gui/src/Mixer/Mixer.cpp
r402 r533 247 247 void Mixer::soloClicked(uint nLine) 248 248 { 249 Hydrogen *pEngine = Hydrogen::get_instance(); 250 Song *pSong = pEngine->getSong(); 251 InstrumentList *pInstrList = pSong->get_instrument_list(); 252 int nInstruments = pInstrList->get_size(); 253 254 bool isSoloClicked = m_pMixerLine[ nLine ]->isSoloClicked(); 255 256 if (!isSoloClicked) { 257 for ( int i = 0; i < nInstruments; i++ ) { 258 m_pMixerLine[i]->setSoloClicked( false ); 259 m_pMixerLine[i]->setMuteClicked( true ); 260 pInstrList->get( i )->set_muted( true ); 261 } 262 m_pMixerLine[nLine]->setSoloClicked( true ); 263 m_pMixerLine[nLine]->setMuteClicked( false ); 264 pInstrList->get( nLine )->set_muted( false ); 265 } 266 else { 267 for ( int i = 0; i < nInstruments; i++ ) { 268 m_pMixerLine[i]->setMuteClicked( false ); 269 m_pMixerLine[i]->setSoloClicked( false ); 270 pInstrList->get( i )->set_muted( false ); 271 } 272 } 273 274 } 275 276 249 MixerLine * L = m_pMixerLine[ nLine ]; 250 L->setSoloClicked( !L->isSoloClicked() ); 251 soloClicked( L ); 252 // Hydrogen *pEngine = Hydrogen::get_instance(); 253 // Song *pSong = pEngine->getSong(); 254 // InstrumentList *pInstrList = pSong->get_instrument_list(); 255 // int nInstruments = pInstrList->get_size(); 256 // 257 // bool isSoloClicked = m_pMixerLine[ nLine ]->isSoloClicked(); 258 // 259 // if (!isSoloClicked) { 260 // for ( int i = 0; i < nInstruments; i++ ) { 261 // m_pMixerLine[i]->setSoloClicked( false ); 262 // m_pMixerLine[i]->setMuteClicked( true ); 263 // pInstrList->get( i )->set_muted( true ); 264 // } 265 // m_pMixerLine[nLine]->setSoloClicked( true ); 266 // m_pMixerLine[nLine]->setMuteClicked( false ); 267 // pInstrList->get( nLine )->set_muted( false ); 268 // } 269 // else { 270 // for ( int i = 0; i < nInstruments; i++ ) { 271 // m_pMixerLine[i]->setMuteClicked( false ); 272 // m_pMixerLine[i]->setSoloClicked( false ); 273 // pInstrList->get( i )->set_muted( false ); 274 // } 275 // } 276 277 } 278 279 bool Mixer::isSoloClicked( uint n ) 280 { 281 if ( n >= MAX_INSTRUMENTS || m_pMixerLine[ n ] == NULL ) { 282 return false; 283 } 284 return m_pMixerLine[ n ]->isSoloClicked(); 285 } 277 286 278 287 void Mixer::noteOnClicked( MixerLine* ref ) branches/jackMidi/gui/src/Mixer/Mixer.h
r402 r533 52 52 void resizeEvent ( QResizeEvent *ev ); 53 53 void soloClicked(uint nLine); 54 bool isSoloClicked(uint nLine); 54 55 55 56 void getPeaksInMixerLine( uint nMixerLine, float& fPeak_L, float& fPeak_R ); branches/jackMidi/gui/src/PatternEditor/DrumPatternEditor.cpp
r404 r533 193 193 Note *pNote2 = new Note( pSelectedInstrument, 0, fVelocity, fPan_L, fPan_R, nLength, fPitch); 194 194 AudioEngine::get_instance()->get_sampler()->note_on(pNote2); 195 // pSelectedInstrument->enqueue();196 195 } 197 196 } branches/jackMidi/gui/src/PatternEditor/PatternEditorInstrumentList.cpp
r404 r533 139 139 140 140 141 void InstrumentLine::setSoloed( bool soloed ) 142 { 143 m_pSoloBtn->setPressed( soloed ); 144 } 145 146 141 147 142 148 void InstrumentLine::muteClicked() … … 213 219 Instrument *pSelectedInstrument = H->getSong()->get_instrument_list()->get( nSelectedInstrument ); 214 220 215 std::multimap <int, Note*>::iterator pos; 216 for ( pos = pCurrentPattern->note_map.begin(); pos != pCurrentPattern->note_map.end(); ++pos ) { 217 Note *pNote = pos->second; 218 assert( pNote ); 219 if ( pNote->get_instrument() != pSelectedInstrument ) { 220 continue; 221 } 222 223 delete pNote; 224 pCurrentPattern->note_map.erase( pos ); 225 } 226 AudioEngine::get_instance()->unlock(); // unlock the audio engine 221 pCurrentPattern->purge_instrument( pSelectedInstrument ); 222 // std::multimap <int, Note*>::iterator pos; 223 // for ( pos = pCurrentPattern->note_map.begin(); pos != pCurrentPattern->note_map.end(); ++pos ) { 224 // Note *pNote = pos->second; 225 // assert( pNote ); 226 // if ( pNote->get_instrument() != pSelectedInstrument ) { 227 // continue; 228 // } 229 // 230 // delete pNote; 231 // pCurrentPattern->note_map.erase( pos ); 232 // } 233 // AudioEngine::get_instance()->unlock(); // unlock the audio engine 227 234 228 235 // this will force an update... … … 361 368 { 362 369 Hydrogen *pEngine = Hydrogen::get_instance(); 370 pEngine->removeInstrument( m_nInstrumentNumber, false ); 363 371 364 372 AudioEngine::get_instance()->lock("InstrumentLine::functionDeleteInstrument"); 365 Instrument *pInstr = pEngine->getSong()->get_instrument_list()->get( m_nInstrumentNumber );366 367 // if the instrument was the last on the instruments list, select the next-last368 if ( m_nInstrumentNumber >= (int)pEngine->getSong()->get_instrument_list()->get_size() -1 ) {369 Hydrogen::get_instance()->setSelectedInstrumentNumber(std::max(0, m_nInstrumentNumber - 1) );370 }371 372 // delete the instrument from the instruments list373 pEngine->getSong()->get_instrument_list()->del( m_nInstrumentNumber );374 pEngine->getSong()->__is_modified = true;375 376 377 // delete all the notes using this instrument378 PatternList* pPatternList = pEngine->getSong()->get_pattern_list();379 for ( int nPattern = 0; nPattern < (int)pPatternList->get_size(); ++nPattern ) {380 H2Core::Pattern *pPattern = pPatternList->get( nPattern );381 382 std::multimap <int, Note*>::iterator pos;383 for ( pos = pPattern->note_map.begin(); pos != pPattern->note_map.end(); ++pos ) {384 Note *pNote = pos->second;385 assert( pNote );386 if ( pNote->get_instrument() == pInstr ) {387 delete pNote;388 pPattern->note_map.erase( pos );389 }390 }391 }392 393 // stop all notes playing394 AudioEngine::get_instance()->get_sampler()->stop_playing_notes();395 396 delete pInstr;397 398 373 #ifdef JACK_SUPPORT 399 374 pEngine->renameJackPorts(); 400 375 #endif 401 376 AudioEngine::get_instance()->unlock(); 402 403 // this will force an update...404 EventQueue::get_instance()->push_event( EVENT_SELECTED_INSTRUMENT_CHANGED, -1 );405 377 } 406 378 … … 517 489 Song *pSong = pEngine->getSong(); 518 490 InstrumentList *pInstrList = pSong->get_instrument_list(); 491 Mixer * mixer = HydrogenApp::getInstance()->getMixer(); 519 492 520 493 unsigned nSelectedInstr = pEngine->getSelectedInstrumentNumber(); … … 551 524 pLine->setSelected( nInstr == nSelectedInstr ); 552 525 pLine->setMuted( pInstr->is_muted() ); 526 if ( mixer ) { 527 pLine->setSoloed( mixer->isSoloClicked( nInstr ) ); 528 } 553 529 554 530 } branches/jackMidi/gui/src/PatternEditor/PatternEditorInstrumentList.h
r402 r533 53 53 void setNumber(int nIndex); 54 54 void setMuted(bool isMuted); 55 void setSoloed( bool soloed ); 55 56 56 57 private slots: branches/jackMidi/gui/src/SongEditor/SongEditor.cpp
r402 r533 993 993 int err = fileMng.savePattern( song , nSelectedPattern, patternname, realpatternname, 1 ); 994 994 if ( err != 0 ) { 995 _ERRORLOG( "Error saving the pattern" ); 995 switch ( err ){ 996 case 1: //file exists 997 QMessageBox::information ( this, "Hydrogen", trUtf8 ( "Error saving pattern!\nThe pattern-file exists." )); 998 return; //exit patternPopup_save without update the drumkitlist 999 default: //anything else 1000 _ERRORLOG( "Error saving the pattern" ); 1001 break; 1002 1003 } 996 1004 } 997 1005 … … 1001 1009 usleep ( 10000 ); 1002 1010 #endif 1011 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems(); 1003 1012 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList(); 1004 1013 } branches/jackMidi/gui/src/SoundLibrary/SoundLibraryImportDialog.cpp
r402 r533 403 403 404 404 // update the drumkit list 405 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems(); 405 406 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList(); 406 407 updateSoundLibraryList(); … … 448 449 QMessageBox::information( this, "Hydrogen", QString( trUtf8( "SoundLibrary imported in %1" ).arg( dataDir ) ) ); 449 450 // update the drumkit list 451 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems(); 450 452 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList(); 451 453 setCursor( QCursor( Qt::ArrowCursor ) ); branches/jackMidi/gui/src/SoundLibrary/SoundLibraryPanel.cpp
r531 r533 79 79 m_pPatternMenu->addSeparator(); 80 80 m_pPatternMenu->addAction( trUtf8( "Load" ), this, SLOT( on_patternLoadAction() ) ); 81 m_pPatternMenu->addAction( trUtf8( "Delete" ), this, SLOT( on_patternDeleteAction() ) ); 81 82 82 83 m_pPatternMenuList = new QMenu( this ); … … 103 104 this->setLayout( pVBox ); 104 105 106 expandpatternlist = false; 107 expandsongslist = false; 108 105 109 updateDrumkitList(); 106 110 } … … 138 142 m_pSongItem->setText( 0, trUtf8( "Songs" ) ); 139 143 m_pSongItem->setToolTip( 0, "double click to expand the list" ); 144 m_pSoundLibraryTree->setItemExpanded( m_pSongItem, expandsongslist ); 140 145 141 146 for (uint i = 0; i < songList.size(); i++) … … 159 164 m_pPatternItem->setText( 0, trUtf8( "Patterns" ) ); 160 165 m_pPatternItem->setToolTip( 0, "double click to expand the list" ); 161 166 m_pSoundLibraryTree->setItemExpanded( m_pPatternItem, expandpatternlist ); 167 162 168 //this is to push the mng.getPatternList in all patterns/drumkit dirs 163 169 for (uint i = 0; i < patternDirList.size(); ++i) { … … 406 412 407 413 QString patternName = m_pSoundLibraryTree->currentItem()->text( 0 ) + ".h2pattern"; 414 QString drumkitname = m_pSoundLibraryTree->currentItem()->toolTip ( 0 ); 408 415 409 416 QString sDirectory = ""; … … 420 427 for (uint i = 0; i < allPatternDirList.size(); ++i) { 421 428 QString testName = allPatternDirList[i]; 422 if( testName.contains( patternName ) ){429 if( testName.contains( patternName ) && testName.contains( drumkitname )){ 423 430 424 431 sDirectory = allPatternDirList[i]; … … 535 542 536 543 Drumkit::removeDrumkit( sSoundLibrary ); 537 538 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList();544 test_expandedItems(); 545 updateDrumkitList(); 539 546 } 540 547 … … 655 662 656 663 QString patternName = m_pSoundLibraryTree->currentItem()->text( 0 ) + ".h2pattern"; 664 QString drumkitname = m_pSoundLibraryTree->currentItem()->toolTip ( 0 ); 657 665 Hydrogen *engine = Hydrogen::get_instance(); 658 666 Song *song = engine->getSong(); … … 672 680 for (uint i = 0; i < allPatternDirList.size(); ++i) { 673 681 QString testName = allPatternDirList[i]; 674 if( testName.contains( patternName )){ 675 676 sDirectory = allPatternDirList[i]; 677 682 if( testName.contains( patternName ) && testName.contains( drumkitname )){ 683 sDirectory = allPatternDirList[i]; 678 684 } 679 685 } … … 695 701 } 696 702 703 704 void SoundLibraryPanel::on_patternDeleteAction() 705 { 706 LocalFileMng mng; 707 708 QString patternName = m_pSoundLibraryTree->currentItem()->text( 0 ) + ".h2pattern"; 709 QString drumkitname = m_pSoundLibraryTree->currentItem()->toolTip ( 0 ); 710 711 QString sDirectory = ""; 712 713 std::vector<QString> patternDirList = mng.getPatternDirList(); 714 715 for (uint i = 0; i < patternDirList.size(); ++i) { 716 QString absPath = patternDirList[i]; 717 mng.getPatternList( absPath ); 718 } 719 720 std::vector<QString> allPatternDirList = mng.getallPatternList(); 721 722 for (uint i = 0; i < allPatternDirList.size(); ++i) { 723 QString testName = allPatternDirList[i]; 724 if( testName.contains( patternName ) && testName.contains( drumkitname )){ 725 sDirectory = allPatternDirList[i]; 726 } 727 } 728 729 int res = QMessageBox::information( this, "Hydrogen", tr( "Warning, the selected pattern will be deleted from disk.\nAre you sure?"), tr("&Ok"), tr("&Cancel"), 0, 1 ); 730 if ( res == 1 ) { 731 return; 732 } 733 734 QFile rmfile(sDirectory ); 735 bool err = rmfile.remove(); 736 if ( err == false ) 737 { 738 _ERRORLOG ( "Error removing the pattern" ); 739 } 740 741 test_expandedItems(); 742 updateDrumkitList(); 743 } 744 745 746 void SoundLibraryPanel::test_expandedItems() 747 { 748 expandsongslist = m_pSoundLibraryTree->isItemExpanded( m_pSongItem ); 749 expandpatternlist = m_pSoundLibraryTree->isItemExpanded( m_pPatternItem ); 750 } branches/jackMidi/gui/src/SoundLibrary/SoundLibraryPanel.h
r402 r533 45 45 46 46 void updateDrumkitList(); 47 47 void test_expandedItems(); 48 48 49 49 private slots: … … 61 61 void on_songLoadAction(); 62 62 void on_patternLoadAction(); 63 void on_patternDeleteAction(); 63 64 64 65 private: … … 81 82 std::vector<H2Core::Drumkit*> m_systemDrumkitInfoList; 82 83 std::vector<H2Core::Drumkit*> m_userDrumkitInfoList; 84 bool expandpatternlist; 85 bool expandsongslist; 86 83 87 84 88 branches/jackMidi/gui/src/SoundLibrary/SoundLibraryPropertiesDialog.cpp
r531 r533 133 133 //reload if necessary 134 134 if ( reload == true ){ 135 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->test_expandedItems(); 135 136 HydrogenApp::getInstance()->getInstrumentRack()->getSoundLibraryPanel()->updateDrumkitList(); 136 137 } branches/jackMidi/libs/hydrogen/include/hydrogen/Pattern.h
r404 r533 31 31 32 32 class Note; 33 class Instrument; 33 34 34 35 /// … … 42 43 Pattern( const QString& name, const QString& category, unsigned lenght = MAX_NOTES ); 43 44 ~Pattern(); 45 46 /** 47 Delete notes that pertain to instrument I. 48 The function is thread safe (it locks the audio data while deleting notes) 49 */ 50 void purge_instrument( Instrument * I ); 51 52 /** 53 Check if there are any notes pertaining to I 54 */ 55 bool references_instrument( Instrument * I ); 44 56 45 57 static Pattern* get_empty_pattern(); branches/jackMidi/libs/hydrogen/include/hydrogen/Song.h
r404 r533 79 79 Song( const QString& name, const QString& author, float bpm, float volume ); 80 80 ~Song(); 81 82 /** 83 Remove all the notes in the song that play on instrument I. 84 The function is real-time safe (it locks the audio data while deleting notes) 85 */ 86 void purge_instrument( Instrument* I ); 81 87 82 88 void set_volume( float volume ) { branches/jackMidi/libs/hydrogen/include/hydrogen/hydrogen.h
r404 r533 120 120 121 121 int loadDrumkit( Drumkit *drumkitInfo ); 122 void functionDeleteInstrument( int instrumentnumber); 122 123 /// delete an instrument. If `conditional` is true, and there are patterns that 124 /// use this instrument, it's not deleted anyway 125 void removeInstrument( int instrumentnumber, bool conditional ); 123 126 124 127 //return the name of the current drumkit … … 191 194 void setNewBpmJTM( float bpmJTM); 192 195 void ComputeHumantimeFrames(uint32_t nFrames); 196 197 void kill_instruments(); 193 198 194 199 private: … … 201 206 Song::SongMode m_oldEngineMode; 202 207 bool m_bOldLoopEnabled; 208 std::list<Instrument*> instrument_death_row; /// Deleting instruments too soon leads to potential crashes. 203 209 }; 204 210 branches/jackMidi/libs/hydrogen/include/hydrogen/instrument.h
r404 r533 27 27 #include <hydrogen/globals.h> 28 28 #include <hydrogen/Object.h> 29 #include <cassert> 29 30 30 31 namespace H2Core … … 104 105 ); 105 106 107 /// create a new object without anything in it. 108 static Instrument * create_empty(); 106 109 ~Instrument(); 107 110 111 /// creates a new object; loads samples from drumkit/instrument. 108 112 static Instrument* load_instrument( 109 113 const QString& drumkit_name, … … 111 115 ); 112 116 117 /// loads state _and_ samples into an Instrument from a `placeholder` instrument 118 /// (i.e. an Instrument that has everything but the actal samples.) 119 void load_from_placeholder( Instrument* placeholder, bool is_live = true ); 120 121 /// loads instrument from path into a `live` Instrument object. 122 void load_from_name( 123 const QString& drumkit_name, 124 const QString& instrument_name, 125 bool is_live = true 126 ); 113 127 114 128 /** 115 129 \brief Returns a layer in the list 116 130 */ 117 InstrumentLayer* get_layer( int index );131 inline InstrumentLayer* get_layer( int index ); 118 132 119 133 /** … … 133 147 __id = id; 134 148 } 135 const QString& get_id() {149 inline const QString& get_id() { 136 150 return __id; 137 151 } … … 145 159 __mute_group = group; 146 160 } 147 in t get_mute_group() {161 inline int get_mute_group() { 148 162 return __mute_group; 149 163 } … … 152 166 __muted = muted; 153 167 } 154 bool is_muted() {168 inline bool is_muted() { 155 169 return __muted; 156 170 } 157 171 158 float get_pan_l() {172 inline float get_pan_l() { 159 173 return __pan_l; 160 174 } … … 163 177 } 164 178 165 float get_pan_r() {179 inline float get_pan_r() { 166 180 return __pan_r; 167 181 } … … 170 184 } 171 185 172 float get_gain() {186 inline float get_gain() { 173 187 return __gain; 174 188 } … … 177 191 } 178 192 179 float get_volume() {193 inline float get_volume() { 180 194 return __volume; 181 195 } … … 184 198 } 185 199 186 bool is_filter_active() {200 inline bool is_filter_active() { 187 201 return __filter_active; 188 202 } … … 191 205 } 192 206 193 float get_filter_resonance() {207 inline float get_filter_resonance() { 194 208 return __filter_resonance; 195 209 } … … 198 212 } 199 213 200 float get_filter_cutoff() {214 inline float get_filter_cutoff() { 201 215 return __filter_cutoff; 202 216 } … … 205 219 } 206 220 207 float get_peak_l() {221 inline float get_peak_l() { 208 222 return __peak_l; 209 223 } … … 212 226 } 213 227 214 float get_peak_r() {228 inline float get_peak_r() { 215 229 return __peak_r; 216 230 } … … 219 233 } 220 234 221 float get_fx_level( int index ) {235 inline float get_fx_level( int index ) { 222 236 return __fx_level[index]; 223 237 } … … 226 240 } 227 241 228 float get_random_pitch_factor() {242 inline float get_random_pitch_factor() { 229 243 return __random_pitch_factor; 230 244 } … … 240 254 } 241 255 242 bool is_active() {256 inline bool is_active() { 243 257 return __active; 244 258 } … … 247 261 } 248 262 249 bool is_soloed() {263 inline bool is_soloed() { 250 264 return __soloed; 251 265 } … … 253 267 __soloed = soloed; 254 268 } 269 inline void enqueue() { 270 __queued++; 271 } 272 inline void dequeue() { 273 assert( __queued > 0 ); 274 __queued--; 275 } 276 inline int is_queued() { 277 return __queued; 278 } 255 279 256 280 private: 281 int __queued; 257 282 InstrumentLayer* __layer_list[MAX_LAYERS]; 258 283 ADSR* __adsr; branches/jackMidi/libs/hydrogen/src/hydrogen.cpp
r404 r533 289 289 AudioEngine::get_instance()->get_sampler()->stop_playing_notes(); 290 290 291 292 291 // delete all copied notes in the song notes queue 293 292 while ( !m_songNoteQueue.empty() ) { 293 m_songNoteQueue.top()->get_instrument()->dequeue(); 294 294 delete m_songNoteQueue.top(); 295 295 m_songNoteQueue.pop(); … … 395 395 // delete all copied notes in the song notes queue 396 396 while(!m_songNoteQueue.empty()){ 397 m_songNoteQueue.top()->get_instrument()->dequeue(); 397 398 delete m_songNoteQueue.top(); 398 399 m_songNoteQueue.pop(); … … 522 523 523 524 m_songNoteQueue.pop(); // rimuovo la nota dalla lista di note 524 525 pNote->get_instrument()->dequeue(); 525 526 // raise noteOn event 526 527 int nInstrument = m_pSong->get_instrument_list()->get_pos( pNote->get_instrument() ); … … 624 625 625 626 while (!m_songNoteQueue.empty()) { // delete all copied notes in the song notes queue 627 m_songNoteQueue.top()->get_instrument()->dequeue(); 626 628 delete m_songNoteQueue.top(); 627 629 m_songNoteQueue.pop(); … … 1037 1039 // printf ("tick=%d pos=%d\n", tick, note->getPosition()); 1038 1040 m_midiNoteQueue.pop_front(); 1041 note->get_instrument()->enqueue(); 1039 1042 m_songNoteQueue.push( note ); 1040 1043 } else { … … 1178 1181 1179 1182 Note *pMetronomeNote = new Note( m_pMetronomeInstrument, tick, fVelocity, 0.5, 0.5, -1, fPitch ); 1183 m_pMetronomeInstrument->enqueue(); 1180 1184 m_songNoteQueue.push( pMetronomeNote ); 1181 1185 } … … 1220 1224 1221 1225 pCopiedNote->m_nHumanizeDelay = nOffset; // humanize time 1226 pNote->get_instrument()->enqueue(); 1222 1227 m_songNoteQueue.push( pCopiedNote ); 1223 1228 //pCopiedNote->dumpInfo(); … … 1654 1659 audioEngine_stopAudioDrivers(); 1655 1660 audioEngine_destroy(); 1661 kill_instruments(); 1656 1662 instance = NULL; 1657 1663 } … … 2078 2084 int Hydrogen::loadDrumkit( Drumkit *drumkitInfo ) 2079 2085 { 2080 _INFOLOG( drumkitInfo->getName() );2086 INFOLOG( drumkitInfo->getName() ); 2081 2087 m_currentDrumkit = drumkitInfo->getName(); 2082 2088 LocalFileMng fileMng; … … 2122 2128 assert( pInstr ); 2123 2129 } else { 2124 pInstr = new Instrument( "", "", new ADSR() ); 2125 AudioEngine::get_instance()->lock( "Hydrogen::loadDrumkit" ); 2130 pInstr = Instrument::create_empty(); 2131 // The instrument isn't playing yet; no need for locking :-) - Jakob Lund. 2132 // AudioEngine::get_instance()->lock( "Hydrogen::loadDrumkit" ); 2126 2133 songInstrList->add( pInstr ); 2127 AudioEngine::get_instance()->unlock();2134 // AudioEngine::get_instance()->unlock(); 2128 2135 } 2129 2136 … … 2133 2140 2134 2141 // creo i nuovi layer in base al nuovo strumento 2135 for ( unsigned nLayer = 0; nLayer < MAX_LAYERS; ++nLayer ) { 2136 InstrumentLayer *pNewLayer = pNewInstr->get_layer( nLayer ); 2137 if ( pNewLayer != NULL ) { 2138 Sample *pNewSample = pNewLayer->get_sample(); 2139 QString sSampleFilename = sDrumkitPath + drumkitInfo->getName() + "/" + pNewSample->get_filename(); 2140 _INFOLOG( " |-> Loading layer [ " + sSampleFilename + " ]" ); 2141 2142 // carico il nuovo sample e creo il nuovo layer 2143 Sample *pSample = Sample::load( sSampleFilename ); 2144 // pSample->setFilename( pNewSample->getFilename() ); // riuso il path del nuovo sample (perche' e' gia relativo al path del drumkit) 2145 InstrumentLayer *pOldLayer = pInstr->get_layer( nLayer ); 2146 2147 if ( pSample == NULL ) { 2148 //_ERRORLOG( "Error Loading drumkit: NULL sample, now using /emptySample.wav" ); 2149 //pSample = Sample::load(string(DataPath::getDataPath() ).append( "/emptySample.wav" )); 2150 //pSample->m_sFilename = string(DataPath::getDataPath() ).append( "/emptySample.wav" ); 2151 _ERRORLOG( "Error loading sample. Creating a new empty layer." ); 2152 AudioEngine::get_instance()->lock( "Hydrogen::loadDrumkit" ); 2153 pInstr->set_layer( NULL, nLayer ); 2154 AudioEngine::get_instance()->unlock(); 2155 delete pOldLayer; 2156 continue; 2157 } 2158 InstrumentLayer *pLayer = new InstrumentLayer( pSample ); 2159 pLayer->set_start_velocity( pNewLayer->get_start_vel
