/[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 1040 by schoenebeck, Wed Feb 7 15:41:31 2007 UTC revision 1130 by iliev, Sun Mar 25 18:59:14 2007 UTC
# Line 23  Line 23 
23  #include "../../common/Mutex.h"  #include "../../common/Mutex.h"
24  #include "../../engines/EngineFactory.h"  #include "../../engines/EngineFactory.h"
25  #include "../../engines/Engine.h"  #include "../../engines/Engine.h"
 #include "../../network/lscpserver.h"  
26    
27  namespace LinuxSampler {  namespace LinuxSampler {
28    
# Line 49  namespace LinuxSampler { Line 48  namespace LinuxSampler {
48      Mutex midiMapsMutex;      Mutex midiMapsMutex;
49    
50    
51        ListenerList<MidiInstrumentCountListener*> MidiInstrumentMapper::llMidiInstrumentCountListeners;
52        ListenerList<MidiInstrumentInfoListener*> MidiInstrumentMapper::llMidiInstrumentInfoListeners;
53        ListenerList<MidiInstrumentMapCountListener*> MidiInstrumentMapper::llMidiInstrumentMapCountListeners;
54        ListenerList<MidiInstrumentMapInfoListener*> MidiInstrumentMapper::llMidiInstrumentMapInfoListeners;
55        
56        void MidiInstrumentMapper::AddMidiInstrumentCountListener(MidiInstrumentCountListener* l) {
57            llMidiInstrumentCountListeners.AddListener(l);
58        }
59    
60        void MidiInstrumentMapper::RemoveMidiInstrumentCountListener(MidiInstrumentCountListener* l) {
61            llMidiInstrumentCountListeners.RemoveListener(l);
62        }
63    
64        void MidiInstrumentMapper::fireMidiInstrumentCountChanged(int MapId, int NewCount) {
65            for (int i = 0; i < llMidiInstrumentCountListeners.GetListenerCount(); i++) {
66                llMidiInstrumentCountListeners.GetListener(i)->MidiInstrumentCountChanged(MapId, NewCount);
67            }
68        }
69    
70        void MidiInstrumentMapper::AddMidiInstrumentInfoListener(MidiInstrumentInfoListener* l) {
71            llMidiInstrumentInfoListeners.AddListener(l);
72        }
73    
74        void MidiInstrumentMapper::RemoveMidiInstrumentInfoListener(MidiInstrumentInfoListener* l) {
75            llMidiInstrumentInfoListeners.RemoveListener(l);
76        }
77    
78        void MidiInstrumentMapper::fireMidiInstrumentInfoChanged(int MapId, int Bank, int Program) {
79            for (int i = 0; i < llMidiInstrumentInfoListeners.GetListenerCount(); i++) {
80                llMidiInstrumentInfoListeners.GetListener(i)->MidiInstrumentInfoChanged(MapId, Bank, Program);
81            }
82        }
83    
84        void MidiInstrumentMapper::AddMidiInstrumentMapCountListener(MidiInstrumentMapCountListener* l) {
85            llMidiInstrumentMapCountListeners.AddListener(l);
86        }
87    
88        void MidiInstrumentMapper::RemoveMidiInstrumentMapCountListener(MidiInstrumentMapCountListener* l) {
89            llMidiInstrumentMapCountListeners.RemoveListener(l);
90        }
91    
92        void MidiInstrumentMapper::fireMidiInstrumentMapCountChanged(int NewCount) {
93            for (int i = 0; i < llMidiInstrumentMapCountListeners.GetListenerCount(); i++) {
94                llMidiInstrumentMapCountListeners.GetListener(i)->MidiInstrumentMapCountChanged(NewCount);
95            }
96        }
97    
98        void MidiInstrumentMapper::AddMidiInstrumentMapInfoListener(MidiInstrumentMapInfoListener* l) {
99            llMidiInstrumentMapInfoListeners.AddListener(l);
100        }
101    
102        void MidiInstrumentMapper::RemoveMidiInstrumentMapInfoListener(MidiInstrumentMapInfoListener* l) {
103            llMidiInstrumentMapInfoListeners.RemoveListener(l);
104        }
105    
106        void MidiInstrumentMapper::fireMidiInstrumentMapInfoChanged(int MapId) {
107            for (int i = 0; i < llMidiInstrumentMapInfoListeners.GetListenerCount(); i++) {
108                llMidiInstrumentMapInfoListeners.GetListener(i)->MidiInstrumentMapInfoChanged(MapId);
109            }
110        }
111    
112      void MidiInstrumentMapper::AddOrReplaceEntry(int Map, midi_prog_index_t Index, entry_t Entry, bool bInBackground) throw (Exception) {      void MidiInstrumentMapper::AddOrReplaceEntry(int Map, midi_prog_index_t Index, entry_t Entry, bool bInBackground) throw (Exception) {
113          if (bInBackground) {          if (bInBackground) {
114              dmsg(3,("MidiInstrumentMapper: updating mapping %d (%d,%d,%d) -> ('%s','%s',%d) with vol=%f, mode=%d in background\n",              dmsg(3,("MidiInstrumentMapper: updating mapping %d (%d,%d,%d) -> ('%s','%s',%d) with vol=%f, mode=%d in background\n",
# Line 119  namespace LinuxSampler { Line 179  namespace LinuxSampler {
179                    
180          if (Replaced) {          if (Replaced) {
181              int Bank = (int(Index.midi_bank_msb) << 7) & int(Index.midi_bank_lsb);              int Bank = (int(Index.midi_bank_msb) << 7) & int(Index.midi_bank_lsb);
182              LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_info, Map, Bank, Index.midi_prog));              fireMidiInstrumentInfoChanged(Map, Bank, Index.midi_prog);
183          } else {          } else {
184              LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_count, Map, InstrCount));              fireMidiInstrumentCountChanged(Map, InstrCount);
185          }          }
186      }      }
187    
# Line 137  namespace LinuxSampler { Line 197  namespace LinuxSampler {
197          midiMapsMutex.Unlock();          midiMapsMutex.Unlock();
198                    
199          if (InstrCount != -1) {          if (InstrCount != -1) {
200              LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_count, Map, InstrCount));              fireMidiInstrumentCountChanged(Map, InstrCount);
201          }          }
202      }      }
203    
# Line 153  namespace LinuxSampler { Line 213  namespace LinuxSampler {
213          midiMapsMutex.Unlock();          midiMapsMutex.Unlock();
214                    
215          if (InstrCount != -1) {          if (InstrCount != -1) {
216              LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_count, Map, InstrCount));              fireMidiInstrumentCountChanged(Map, InstrCount);
217          }          }
218      }      }
219    
# Line 242  namespace LinuxSampler { Line 302  namespace LinuxSampler {
302          midiMaps[ID].name = MapName;          midiMaps[ID].name = MapName;
303          midiMapsMutex.Unlock();          midiMapsMutex.Unlock();
304    
305          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_map_count, Maps().size()));          fireMidiInstrumentMapCountChanged(Maps().size());
306          return ID;          return ID;
307      }      }
308    
# Line 268  namespace LinuxSampler { Line 328  namespace LinuxSampler {
328          }          }
329          iterMap->second.name = NewName;          iterMap->second.name = NewName;
330          midiMapsMutex.Unlock();          midiMapsMutex.Unlock();
331          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_map_info, Map));          fireMidiInstrumentMapInfoChanged(Map);
332      }      }
333    
334      void MidiInstrumentMapper::RemoveMap(int Map) {      void MidiInstrumentMapper::RemoveMap(int Map) {
335          midiMapsMutex.Lock();          midiMapsMutex.Lock();
336          midiMaps.erase(Map);          midiMaps.erase(Map);
337          midiMapsMutex.Unlock();          midiMapsMutex.Unlock();
338          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_map_count, Maps().size()));          fireMidiInstrumentMapCountChanged(Maps().size());
339      }      }
340    
341      void MidiInstrumentMapper::RemoveAllMaps() {      void MidiInstrumentMapper::RemoveAllMaps() {
342          midiMapsMutex.Lock();          midiMapsMutex.Lock();
343          midiMaps.clear();          midiMaps.clear();
344          midiMapsMutex.Unlock();          midiMapsMutex.Unlock();
345          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_map_count, Maps().size()));          fireMidiInstrumentMapCountChanged(Maps().size());
346      }      }
347    
348      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.1040  
changed lines
  Added in v.1130

  ViewVC Help
Powered by ViewVC