/[svn]/linuxsampler/trunk/src/drivers/midi/MidiInstrumentMapper.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/drivers/midi/MidiInstrumentMapper.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1130 by iliev, Sun Mar 25 18:59:14 2007 UTC revision 1135 by iliev, Thu Mar 29 09:40:45 2007 UTC
# Line 47  namespace LinuxSampler { Line 47  namespace LinuxSampler {
47      // for synchronization of midiMaps      // for synchronization of midiMaps
48      Mutex midiMapsMutex;      Mutex midiMapsMutex;
49    
   
50      ListenerList<MidiInstrumentCountListener*> MidiInstrumentMapper::llMidiInstrumentCountListeners;      ListenerList<MidiInstrumentCountListener*> MidiInstrumentMapper::llMidiInstrumentCountListeners;
51      ListenerList<MidiInstrumentInfoListener*> MidiInstrumentMapper::llMidiInstrumentInfoListeners;      ListenerList<MidiInstrumentInfoListener*> MidiInstrumentMapper::llMidiInstrumentInfoListeners;
52      ListenerList<MidiInstrumentMapCountListener*> MidiInstrumentMapper::llMidiInstrumentMapCountListeners;      ListenerList<MidiInstrumentMapCountListener*> MidiInstrumentMapper::llMidiInstrumentMapCountListeners;
53      ListenerList<MidiInstrumentMapInfoListener*> MidiInstrumentMapper::llMidiInstrumentMapInfoListeners;      ListenerList<MidiInstrumentMapInfoListener*> MidiInstrumentMapper::llMidiInstrumentMapInfoListeners;
54        int MidiInstrumentMapper::DefaultMap;
55            
56      void MidiInstrumentMapper::AddMidiInstrumentCountListener(MidiInstrumentCountListener* l) {      void MidiInstrumentMapper::AddMidiInstrumentCountListener(MidiInstrumentCountListener* l) {
57          llMidiInstrumentCountListeners.AddListener(l);          llMidiInstrumentCountListeners.AddListener(l);
# Line 278  namespace LinuxSampler { Line 278  namespace LinuxSampler {
278          return result;          return result;
279      }      }
280    
281        int MidiInstrumentMapper::GetMapCount() {
282            midiMapsMutex.Lock();
283            int i = midiMaps.size();
284            midiMapsMutex.Unlock();
285            return i;
286        }
287    
288      int MidiInstrumentMapper::AddMap(String MapName) throw (Exception) {      int MidiInstrumentMapper::AddMap(String MapName) throw (Exception) {
289          int ID;          int ID;
290          midiMapsMutex.Lock();          midiMapsMutex.Lock();
# Line 300  namespace LinuxSampler { Line 307  namespace LinuxSampler {
307          }          }
308          __create_map:          __create_map:
309          midiMaps[ID].name = MapName;          midiMaps[ID].name = MapName;
310          midiMapsMutex.Unlock();          
   
311          fireMidiInstrumentMapCountChanged(Maps().size());          fireMidiInstrumentMapCountChanged(Maps().size());
312            // If there were no maps until now we must set a default map.
313            if (midiMaps.size() == 1) SetDefaultMap(ID);
314            midiMapsMutex.Unlock();
315            
316          return ID;          return ID;
317      }      }
318    
# Line 334  namespace LinuxSampler { Line 344  namespace LinuxSampler {
344      void MidiInstrumentMapper::RemoveMap(int Map) {      void MidiInstrumentMapper::RemoveMap(int Map) {
345          midiMapsMutex.Lock();          midiMapsMutex.Lock();
346          midiMaps.erase(Map);          midiMaps.erase(Map);
347          midiMapsMutex.Unlock();          if(Map == GetDefaultMap()) {
348                SetDefaultMap(midiMaps.empty() ? -1 : (*(midiMaps.begin())).first);
349            }
350          fireMidiInstrumentMapCountChanged(Maps().size());          fireMidiInstrumentMapCountChanged(Maps().size());
351            midiMapsMutex.Unlock();
352      }      }
353    
354      void MidiInstrumentMapper::RemoveAllMaps() {      void MidiInstrumentMapper::RemoveAllMaps() {
355          midiMapsMutex.Lock();          midiMapsMutex.Lock();
356          midiMaps.clear();          midiMaps.clear();
357          midiMapsMutex.Unlock();          SetDefaultMap(-1);
358          fireMidiInstrumentMapCountChanged(Maps().size());          fireMidiInstrumentMapCountChanged(Maps().size());
359            midiMapsMutex.Unlock();
360        }
361    
362        int MidiInstrumentMapper::GetDefaultMap() {
363            midiMapsMutex.Lock();
364            int i = DefaultMap;
365            midiMapsMutex.Unlock();
366            return i;
367        }
368    
369        void MidiInstrumentMapper::SetDefaultMap(int MapId) {
370            midiMapsMutex.Lock();
371            DefaultMap = MapId;
372            midiMapsMutex.Unlock();
373            
374            if (MapId != -1) fireMidiInstrumentMapInfoChanged(MapId);
375      }      }
376    
377      optional<MidiInstrumentMapper::entry_t> MidiInstrumentMapper::GetEntry(int Map, midi_prog_index_t Index) {      optional<MidiInstrumentMapper::entry_t> MidiInstrumentMapper::GetEntry(int Map, midi_prog_index_t Index) {

Legend:
Removed from v.1130  
changed lines
  Added in v.1135

  ViewVC Help
Powered by ViewVC