Show
Ignore:
Timestamp:
08/17/08 21:45:13 (5 years ago)
Author:
wolke
Message:

prevent, that used notes in pattern and the needed instruments will not deleted if a smaller drumkit will loaded.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/libs/hydrogen/src/hydrogen.cpp

    r332 r333  
     1#include "libs/hydrogen/include/hydrogen/note.h" /* defines Note */ 
    12/* 
    23 * Hydrogen 
     
    22392240void Hydrogen::functionDeleteInstrument( int instrumentnumber) 
    22402241{ 
    2241         AudioEngine::get_instance()->lock("InstrumentLine::Hydrogen::functionDeleteInstrument"); 
     2242//      hi seems that it not necessary to lock the audio engine for this process 
     2243//      AudioEngine::get_instance()->lock("InstrumentLine::Hydrogen::functionDeleteInstrument"); 
    22422244        Instrument *pInstr = m_pSong->get_instrument_list()->get( instrumentnumber ); 
    22432245 
     
    22472249        } 
    22482250 
     2251 
     2252        // new! this check if a pattern has an active note  
     2253        //if there is an note inside the pattern the intrument would not be deleted 
     2254        PatternList* pPatternList = getSong()->get_pattern_list(); 
     2255        for ( int nPattern = 0; nPattern < (int)pPatternList->get_size(); ++nPattern ) { 
     2256                H2Core::Pattern *pPattern = pPatternList->get( nPattern ); 
     2257 
     2258                std::multimap <int, Note*>::iterator pos; 
     2259                for ( pos = pPattern->note_map.begin(); pos != pPattern->note_map.end(); ++pos ) { 
     2260                        Note *pNote = pos->second; 
     2261                        assert( pNote ); 
     2262                        if ( pNote->get_instrument() == pInstr ) { 
     2263                                if( pNote->get_velocity() >= 0.0){  
     2264//                                      AudioEngine::get_instance()->unlock(); 
     2265                                        return; 
     2266                                } 
     2267                        } 
     2268                } 
     2269        } 
     2270 
    22492271        // delete the instrument from the instruments list 
    22502272        getSong()->get_instrument_list()->del( instrumentnumber ); 
    22512273        getSong()->__is_modified = true; 
    22522274 
    2253  
    22542275        // delete all the notes using this instrument 
    2255         PatternList* pPatternList = getSong()->get_pattern_list(); 
     2276//      PatternList* pPatternList = getSong()->get_pattern_list(); 
    22562277        for ( int nPattern = 0; nPattern < (int)pPatternList->get_size(); ++nPattern ) { 
    22572278                H2Core::Pattern *pPattern = pPatternList->get( nPattern ); 
     
    22732294        delete pInstr; 
    22742295 
    2275         AudioEngine::get_instance()->unlock(); 
     2296//      AudioEngine::get_instance()->unlock(); 
    22762297 
    22772298        // this will force an update...