3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
* Copyright (C) 2005 - 2009 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
25 |
#define __LS_INSTRUMENTMANAGER_H__ |
#define __LS_INSTRUMENTMANAGER_H__ |
26 |
|
|
27 |
#include "../common/global.h" |
#include "../common/global.h" |
28 |
|
#include "../common/Exception.h" |
29 |
|
|
30 |
#include <vector> |
#include <vector> |
31 |
|
|
33 |
|
|
34 |
// just symbol prototyping |
// just symbol prototyping |
35 |
class EngineChannel; |
class EngineChannel; |
36 |
|
class InstrumentEditor; |
37 |
|
|
38 |
|
/** |
39 |
|
* Will be thrown by InstrumentManager implementations on errors. |
40 |
|
*/ |
41 |
|
class InstrumentManagerException : public Exception { |
42 |
|
public: |
43 |
|
InstrumentManagerException(String msg) : Exception(msg) {} |
44 |
|
}; |
45 |
|
|
46 |
/** @brief Abstract interface class for InstrumentManagers. |
/** @brief Abstract interface class for InstrumentManagers. |
47 |
* |
* |
71 |
bool operator<(const instrument_id_t& o) const { |
bool operator<(const instrument_id_t& o) const { |
72 |
return (Index < o.Index || (Index == o.Index && FileName < o.FileName)); |
return (Index < o.Index || (Index == o.Index && FileName < o.FileName)); |
73 |
} |
} |
74 |
|
|
75 |
|
bool operator==(const instrument_id_t& o) const { |
76 |
|
return (Index == o.Index && FileName == o.FileName); |
77 |
|
} |
78 |
|
}; |
79 |
|
|
80 |
|
/** |
81 |
|
* Rather abstract informations about an instrument. |
82 |
|
*/ |
83 |
|
struct instrument_info_t { |
84 |
|
String InstrumentName; |
85 |
|
String FormatVersion; |
86 |
|
String Product; |
87 |
|
String Artists; |
88 |
|
uint8_t KeyBindings[128]; |
89 |
|
uint8_t KeySwitchBindings[128]; |
90 |
}; |
}; |
91 |
|
|
92 |
/** |
/** |
119 |
void SetModeInBackground(const instrument_id_t& ID, mode_t Mode); |
void SetModeInBackground(const instrument_id_t& ID, mode_t Mode); |
120 |
|
|
121 |
/** |
/** |
|
* Get global volume factor for this instrument. |
|
|
* |
|
|
* This method has to be implemented by the descendant. |
|
|
*/ |
|
|
virtual float GetVolume(const instrument_id_t& ID) = 0; |
|
|
|
|
|
/** |
|
|
* Change global volume factor for this instrument. |
|
|
* |
|
|
* This method has to be implemented by the descendant. |
|
|
*/ |
|
|
virtual void SetVolume(const instrument_id_t& ID, float Volume) = 0; |
|
|
|
|
|
/** |
|
122 |
* Same as loading the given instrument directly on the given |
* Same as loading the given instrument directly on the given |
123 |
* EngineChannel, but this method will not block, instead it |
* EngineChannel, but this method will not block, instead it |
124 |
* will load the instrument in a separate thread. |
* will load the instrument in a separate thread. |
130 |
static void LoadInstrumentInBackground(instrument_id_t ID, EngineChannel* pEngineChannel); |
static void LoadInstrumentInBackground(instrument_id_t ID, EngineChannel* pEngineChannel); |
131 |
|
|
132 |
/** |
/** |
133 |
|
* Stops the background thread that has been started by |
134 |
|
* LoadInstrumentInBackground. |
135 |
|
*/ |
136 |
|
static void StopBackgroundThread(); |
137 |
|
|
138 |
|
/** |
139 |
* Returns the name of the given instrument as reflected by its |
* Returns the name of the given instrument as reflected by its |
140 |
* file. |
* file. |
141 |
* |
* |
142 |
* This method has to be implemented by the descendant. |
* This method has to be implemented by the descendant. |
143 |
*/ |
*/ |
144 |
virtual String GetInstrumentName(instrument_id_t ID) = 0; |
virtual String GetInstrumentName(instrument_id_t ID) = 0; |
145 |
|
|
146 |
|
/** |
147 |
|
* Returns a textual identifier of the data structure for the |
148 |
|
* given loaded instrument, which usually reflects the name of |
149 |
|
* of the library used to load the instrument (i.e. "libgig"). |
150 |
|
* |
151 |
|
* This method has to be implemented by the descendant. |
152 |
|
*/ |
153 |
|
virtual String GetInstrumentDataStructureName(instrument_id_t ID) = 0; |
154 |
|
|
155 |
|
/** |
156 |
|
* Returns the version of the data structure for the given |
157 |
|
* loaded instrument, which usually reflects the version of the |
158 |
|
* library which was used to load the instrument (i.e. "3.1.0"). |
159 |
|
* |
160 |
|
* This method has to be implemented by the descendant. |
161 |
|
*/ |
162 |
|
virtual String GetInstrumentDataStructureVersion(instrument_id_t ID) = 0; |
163 |
|
|
164 |
|
/** |
165 |
|
* Spawn an appropriate editor for the given instrument that is |
166 |
|
* actually capable to handle the instrument's format and data |
167 |
|
* structure. The instrument editor will be hosted in the |
168 |
|
* sampler's own process to allow immediate live-editing of the |
169 |
|
* instrument while playing the instrument in parallel by the |
170 |
|
* sampler. |
171 |
|
* |
172 |
|
* For this to work, instrument editor applications have to |
173 |
|
* implement the abstract interface class @c InstrumentEditor |
174 |
|
* and have to generate a plugin DLL that has to be placed into |
175 |
|
* the appropriate plugin directory of the sampler. |
176 |
|
* |
177 |
|
* This method has to be implemented by the descendant. |
178 |
|
* |
179 |
|
* @returns pointer to the launched editor |
180 |
|
* @throws InstrumentManagerException - in case no compatible |
181 |
|
* instrument editor is registered to the sampler |
182 |
|
*/ |
183 |
|
virtual InstrumentEditor* LaunchInstrumentEditor(instrument_id_t ID) throw (InstrumentManagerException) = 0; |
184 |
|
|
185 |
|
/** |
186 |
|
* Returns a list of instrument IDs of the provided instrument |
187 |
|
* file in case the provided file's format is supported. |
188 |
|
* |
189 |
|
* @throws InstrumentManagerException if the format of the |
190 |
|
* provided instrument file is not supported |
191 |
|
*/ |
192 |
|
virtual std::vector<instrument_id_t> GetInstrumentFileContent(String File) throw (InstrumentManagerException) = 0; |
193 |
|
|
194 |
|
/** |
195 |
|
* Get detailed informations about the provided instrument file. |
196 |
|
* |
197 |
|
* @throws InstrumentManagerException if the format of the |
198 |
|
* provided instrument file is not supported |
199 |
|
*/ |
200 |
|
virtual instrument_info_t GetInstrumentInfo(instrument_id_t ID) throw (InstrumentManagerException) = 0; |
201 |
}; |
}; |
202 |
|
|
203 |
}; |
} |
204 |
|
|
205 |
#endif // __LS_INSTRUMENTMANAGER_H__ |
#endif // __LS_INSTRUMENTMANAGER_H__ |