linuxsampler 2.3.1
MidiInstrumentMapper.h
Go to the documentation of this file.
1/***************************************************************************
2 * *
3 * Copyright (C) 2006 - 2009 Christian Schoenebeck *
4 * *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This library is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this library; if not, write to the Free Software *
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
18 * MA 02111-1307 USA *
19 ***************************************************************************/
20
21#ifndef __LS_MIDIINSTRUMENTMAPPER_H__
22#define __LS_MIDIINSTRUMENTMAPPER_H__
23
24#include <map>
25
26#include "../../EventListeners.h"
27#include "../../common/global.h"
28#include "../../common/optional.h"
29#include "../../engines/InstrumentManager.h"
30#include "midi.h"
31
32namespace LinuxSampler {
33
34 // just symbol prototyping
35 class MidiInputPort;
36
51 public:
55 enum mode_t {
59 #if !defined(WIN32)
60 VOID = 127,
61 #endif
62 DONTCARE = 127
63 };
64
77
83
88
94
99
105
110
116
121
147
155
163
171
180
185 static std::vector<int> Maps();
186
196
204
214
221
226
231
237
243
251
257
258 protected:
266
275
281
286
287 static optional<entry_t> GetEntry(int Map, midi_prog_index_t Index); // shall only be used by EngineChannel ATM (see source comment)
288 friend class EngineChannel; // allow EngineChannel to access GetEntry()
289
290 private:
296 static void SetLoadMode(entry_t* pEntry);
297
298 static ListenerList<MidiInstrumentCountListener*> llMidiInstrumentCountListeners;
299 static ListenerList<MidiInstrumentInfoListener*> llMidiInstrumentInfoListeners;
300 static ListenerList<MidiInstrumentMapCountListener*> llMidiInstrumentMapCountListeners;
301 static ListenerList<MidiInstrumentMapInfoListener*> llMidiInstrumentMapInfoListeners;
302
303 static int DefaultMap;
304 };
305
306} // namespace LinuxSampler
307
308#endif // __LS_MIDIINSTRUMENTMAPPER_H__
Channel Interface for LinuxSampler Sampler Engines.
Exception that will be thrown in NON REAL TIME PARTS of the LinuxSampler application.
Definition Exception.h:37
This class is used as a listener, which is notified when the number of MIDI instruments on a particul...
This class is used as a listener, which is notified when a MIDI instrument in a MIDI instrument map i...
This class is used as a listener, which is notified when the number of MIDI instrument maps is change...
This class is used as a listener, which is notified when the settings of a MIDI instrument map are ch...
Mapping MIDI bank/program numbers with real instruments.
static int GetDefaultMap()
Gets the ID of the default map.
static void fireMidiInstrumentMapCountChanged(int NewCount)
Notifies listeners that the number of MIDI instrument maps has been changed.
static void RemoveMidiInstrumentCountListener(MidiInstrumentCountListener *l)
Removes the specified listener.
static void AddMidiInstrumentMapCountListener(MidiInstrumentMapCountListener *l)
Registers the specified listener to be notified when the number of MIDI instrument maps is changed.
static int GetMapCount()
Returns amount of currently available MIDI instrument maps.
static void AddMidiInstrumentInfoListener(MidiInstrumentInfoListener *l)
Registers the specified listener to be notified when a MIDI instrument in a MIDI instrument map is ch...
static void RemoveMap(int Map)
Delete the given map.
static entry_t GetEntry(int Map, uint MidiBank, uint MidiProg)
Gets an entry from the MIDI instrument map.
static void RemoveAllMaps()
Completely delete all existing maps.
static int GetInstrumentCount()
Returns the amount of currently available MIDI instruments in all maps.
static void AddOrReplaceEntry(int Map, midi_prog_index_t Index, entry_t Entry, bool bInBackground=false)
Adds a new entry to the given MIDI instrument map in case an entry with Index does not exist yet,...
static String MapName(int Map)
Returns the custom name of the given map.
static void fireMidiInstrumentInfoChanged(int MapId, int Bank, int Program)
Notifies listeners that a MIDI instrument in a MIDI instrument map is changed.
static void AddMidiInstrumentCountListener(MidiInstrumentCountListener *l)
Registers the specified listener to be notified when the number of MIDI instruments on a particular M...
static void RemoveAllEntries(int Map)
Clear the whole given MIDI instrument map, that is delete all its entries.
static void AddMidiInstrumentMapInfoListener(MidiInstrumentMapInfoListener *l)
Registers the specified listener to be notified when the settings of a MIDI instrument map are change...
static void RemoveMidiInstrumentMapInfoListener(MidiInstrumentMapInfoListener *l)
Removes the specified listener.
static void RemoveMidiInstrumentMapCountListener(MidiInstrumentMapCountListener *l)
Removes the specified listener.
static void RemoveMidiInstrumentInfoListener(MidiInstrumentInfoListener *l)
Removes the specified listener.
static void SetDefaultMap(int MapId)
Sets the default map.
static void fireMidiInstrumentMapInfoChanged(int MapId)
Notifies listeners that the settings of a MIDI instrument map are changed.
static void fireMidiInstrumentCountChanged(int MapId, int NewCount)
Notifies listeners that the number of MIDI instruments on the specified MIDI instrument map has been ...
static int AddMap(String MapName="")
Create a new MIDI instrument map.
static std::map< midi_prog_index_t, entry_t > Entries(int Map)
Returns the currently existing MIDI instrument map entries of the given map with their current settin...
static void RenameMap(int Map, String NewName)
Rename the given, already existing map.
static std::vector< int > Maps()
Returns the IDs of all currently existing MIDI instrument maps.
static void RemoveEntry(int Map, midi_prog_index_t Index)
Remove an existing entry from the MIDI instrument map.
mode_t
Defines the life-time strategy for an instrument.
@ ON_DEMAND
Instrument will be loaded when needed, freed once not needed anymore.
@ DONTCARE
Don't care, let it up to the InstrumentManager to decide for an appropriate LoadMode.
@ ON_DEMAND_HOLD
Instrument will be loaded when needed and kept even if not needed anymore.
@ PERSISTENT
Instrument will immediately be loaded and kept all the time.
Wraps as a kind of pointer class some data object shared with other threads, to protect / synchronize...
std::string String
Definition global.h:44
Defines the instrument and settings a MIDI bank MSB, LSB, program triple ought to be mapped to.
uint InstrumentIndex
Index of the instrument within its file.
String EngineName
The sampler engine to be used.
String Name
Display name that should be associated with this mapping entry.
float Volume
Global volume factor for this instrument.
String InstrumentFile
File name of the instrument to be loaded.
mode_t LoadMode
Life-time strategy of instrument.
MIDI program index.
Definition midi.h:57