linuxsampler 1.0.0
|
00001 /*************************************************************************** 00002 * * 00003 * Copyright (C) 2006 - 2009 Christian Schoenebeck * 00004 * * 00005 * This library is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This library is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this library; if not, write to the Free Software * 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 00018 * MA 02111-1307 USA * 00019 ***************************************************************************/ 00020 00021 #ifndef __LS_MIDIINSTRUMENTMAPPER_H__ 00022 #define __LS_MIDIINSTRUMENTMAPPER_H__ 00023 00024 #include <map> 00025 00026 #include "../../EventListeners.h" 00027 #include "../../common/global.h" 00028 #include "../../common/optional.h" 00029 #include "../../engines/InstrumentManager.h" 00030 #include "midi.h" 00031 00032 namespace LinuxSampler { 00033 00034 // just symbol prototyping 00035 class MidiInputPort; 00036 00050 class MidiInstrumentMapper { 00051 public: 00055 enum mode_t { 00056 ON_DEMAND = 0, 00057 ON_DEMAND_HOLD = 1, 00058 PERSISTENT = 2, 00059 #if !defined(WIN32) 00060 VOID = 127, 00061 #endif 00062 DONTCARE = 127 00063 }; 00064 00069 struct entry_t { 00070 String EngineName; 00071 String InstrumentFile; 00072 uint InstrumentIndex; 00073 mode_t LoadMode; 00074 float Volume; 00075 String Name; 00076 }; 00077 00082 static void AddMidiInstrumentCountListener(MidiInstrumentCountListener* l); 00083 00087 static void RemoveMidiInstrumentCountListener(MidiInstrumentCountListener* l); 00088 00093 static void AddMidiInstrumentInfoListener(MidiInstrumentInfoListener* l); 00094 00098 static void RemoveMidiInstrumentInfoListener(MidiInstrumentInfoListener* l); 00099 00104 static void AddMidiInstrumentMapCountListener(MidiInstrumentMapCountListener* l); 00105 00109 static void RemoveMidiInstrumentMapCountListener(MidiInstrumentMapCountListener* l); 00110 00115 static void AddMidiInstrumentMapInfoListener(MidiInstrumentMapInfoListener* l); 00116 00120 static void RemoveMidiInstrumentMapInfoListener(MidiInstrumentMapInfoListener* l); 00121 00146 static void AddOrReplaceEntry(int Map, midi_prog_index_t Index, entry_t Entry, bool bInBackground = false) throw (Exception); 00147 00154 static entry_t GetEntry(int Map, uint MidiBank, uint MidiProg); 00155 00162 static void RemoveEntry(int Map, midi_prog_index_t Index); 00163 00170 static void RemoveAllEntries(int Map); 00171 00179 static std::map<midi_prog_index_t,entry_t> Entries(int Map) throw (Exception); 00180 00185 static std::vector<int> Maps(); 00186 00195 static int AddMap(String MapName = "") throw (Exception) ; 00196 00203 static String MapName(int Map) throw (Exception); 00204 00213 static void RenameMap(int Map, String NewName) throw (Exception); 00214 00220 static void RemoveMap(int Map); 00221 00225 static void RemoveAllMaps(); 00226 00230 static int GetMapCount(); 00231 00236 static int GetInstrumentCount(); 00237 00242 static int GetInstrumentCount(int Map); 00243 00250 static int GetDefaultMap(); 00251 00256 static void SetDefaultMap(int MapId); 00257 00258 protected: 00265 static void fireMidiInstrumentCountChanged(int MapId, int NewCount); 00266 00274 static void fireMidiInstrumentInfoChanged(int MapId, int Bank, int Program); 00275 00280 static void fireMidiInstrumentMapCountChanged(int NewCount); 00281 00285 static void fireMidiInstrumentMapInfoChanged(int MapId); 00286 00287 static optional<entry_t> GetEntry(int Map, midi_prog_index_t Index); // shall only be used by EngineChannel ATM (see source comment) 00288 friend class EngineChannel; // allow EngineChannel to access GetEntry() 00289 00290 private: 00296 static void SetLoadMode(entry_t* pEntry); 00297 00298 static ListenerList<MidiInstrumentCountListener*> llMidiInstrumentCountListeners; 00299 static ListenerList<MidiInstrumentInfoListener*> llMidiInstrumentInfoListeners; 00300 static ListenerList<MidiInstrumentMapCountListener*> llMidiInstrumentMapCountListeners; 00301 static ListenerList<MidiInstrumentMapInfoListener*> llMidiInstrumentMapInfoListeners; 00302 00303 static int DefaultMap; 00304 }; 00305 00306 } // namespace LinuxSampler 00307 00308 #endif // __LS_MIDIINSTRUMENTMAPPER_H__