28 |
#include "common/global.h" |
#include "common/global.h" |
29 |
#include "common/LinuxSamplerException.h" |
#include "common/LinuxSamplerException.h" |
30 |
#include "engines/common/Engine.h" |
#include "engines/common/Engine.h" |
31 |
#include "mididriver/MidiInputDevice.h" |
#include "drivers/midi/MidiInputDevice.h" |
32 |
#include "audiodriver/AudioOutputDevice.h" |
#include "drivers/audio/AudioOutputDevice.h" |
33 |
|
|
34 |
namespace LinuxSampler { |
namespace LinuxSampler { |
35 |
|
|
40 |
* |
* |
41 |
* Encapsulates one sampler engine, one connection to a MIDI input |
* Encapsulates one sampler engine, one connection to a MIDI input |
42 |
* device and one connection to an audio output device. You cannot |
* device and one connection to an audio output device. You cannot |
43 |
* create an instance of this class on you own, you have to use the |
* create an instance of this class on your own, you have to use the |
44 |
* AddSamplerChannel() method of the Sampler object to create a new |
* AddSamplerChannel() method of the Sampler object to create a new |
45 |
* sampler channel. |
* sampler channel. |
46 |
*/ |
*/ |
54 |
* |
* |
55 |
* @param EngineType - type of the engine to deploy |
* @param EngineType - type of the engine to deploy |
56 |
*/ |
*/ |
57 |
void LoadEngine(Engine::type_t EngineType); |
void LoadEngine(Engine::type_t EngineType); // TODO: to be changed to 'void LoadEngine(String EngineType) throws (LinuxSamplerException);' |
58 |
|
|
59 |
/** |
/** |
60 |
* Connect this sampler channel to an audio output device (that |
* Connect this sampler channel to an audio output device, that |
61 |
* is audio output driver) of the given type. If the audio |
* is an instance of an audio output driver. If this sampler |
62 |
* output for the desired audio output system is not yet |
* channel was already connected to an audio output device, then |
63 |
* created, then it will be created automatically, but with |
* the old connection will automatically be removed before. |
|
* default settings though. If this sampler channel was already |
|
|
* connected to an audio output device, then the old connection |
|
|
* will automatically be removed before. |
|
64 |
* |
* |
65 |
* @param AudioType - audio output system to connect to |
* @param pDevice - audio output device to connect to |
66 |
*/ |
*/ |
67 |
void SetAudioOutputDevice(AudioOutputDevice::type_t AudioType); |
void SetAudioOutputDevice(AudioOutputDevice* pDevice); |
68 |
|
|
69 |
/** |
/** |
70 |
* Connect this sampler channel to and MIDI input device (that |
* Connect this sampler channel to and MIDI input device. |
|
* is MIDI input driver) of the given type. If the MIDI input |
|
|
* driver for the desired MIDI input system is not yet created, |
|
|
* then it will be created automatically, but with default |
|
|
* settings though. If this sampler channel was already |
|
|
* connected to a MIDI input device, then the old connection |
|
|
* will automatically be removed before. |
|
71 |
* |
* |
72 |
* @param MidiType - MIDI input system to connect to |
* @param pDevice - MIDI input device to connect to |
73 |
|
*/ |
74 |
|
void SetMidiInputDevice(MidiInputDevice *pDevice); |
75 |
|
|
76 |
|
/** |
77 |
|
* Connect this sampler channel to and MIDI input port. |
78 |
|
* |
79 |
|
* @param MidiPort - MIDI port to connect to |
80 |
|
*/ |
81 |
|
void SetMidiInputPort(int MidiPort); |
82 |
|
|
83 |
|
/** |
84 |
|
* Connect this sampler channel to and MIDI input channel. |
85 |
|
* |
86 |
|
* @param MidiChannel - MIDI channel to connect to |
87 |
|
*/ |
88 |
|
void SetMidiInputChannel(MidiInputDevice::MidiInputPort::midi_chan_t MidiChannel); |
89 |
|
|
90 |
|
/** |
91 |
|
* Connect this sampler channel to a MIDI input triplet. |
92 |
|
* |
93 |
|
* @param pDevice - MIDI input device to connect to |
94 |
|
* @param MidiPort - MIDI port to connect to |
95 |
* @param MidiChannel - optional: MIDI channel on which the |
* @param MidiChannel - optional: MIDI channel on which the |
96 |
* sampler channel should listen to |
* sampler channel should listen to |
97 |
* (default: listen on all MIDI channels) |
* (default: listen on all MIDI channels) |
98 |
*/ |
*/ |
99 |
void SetMidiInputDevice(MidiInputDevice::type_t MidiType, MidiInputDevice::midi_chan_t MidiChannel = MidiInputDevice::midi_chan_all); |
void SetMidiInput(MidiInputDevice* pDevice, int MidiPort, MidiInputDevice::MidiInputPort::midi_chan_t MidiChannel = MidiInputDevice::MidiInputPort::midi_chan_all); |
100 |
|
|
101 |
/** |
/** |
102 |
* Returns the engine that was deployed on this sampler channel. |
* Returns the engine that was deployed on this sampler channel. |
106 |
Engine* GetEngine(); |
Engine* GetEngine(); |
107 |
|
|
108 |
/** |
/** |
109 |
* Returns the MIDI input device to which this sampler channel |
* Returns the MIDI input channel to which this sampler |
110 |
* is currently connected to. |
* channel is currently connected to. |
111 |
* |
* |
112 |
* @returns pointer to MIDI input device or NULL if not |
* @returns The MIDI input channel on which the sampler |
113 |
* connected |
* channel is listening to. |
114 |
*/ |
*/ |
115 |
MidiInputDevice* GetMidiInputDevice(); |
MidiInputDevice::MidiInputPort::midi_chan_t GetMidiInputChannel(); |
116 |
|
|
117 |
|
/** |
118 |
|
* Returns the MIDI input port number to which this sampler |
119 |
|
* channel is currently connected to. |
120 |
|
* |
121 |
|
* @returns MIDI input port number or -1 if not connected |
122 |
|
*/ |
123 |
|
int GetMidiInputPort(); |
124 |
|
|
125 |
/** |
/** |
126 |
* Returns the audio output device to which this sampler channel |
* Returns the audio output device to which this sampler channel |
132 |
AudioOutputDevice* GetAudioOutputDevice(); |
AudioOutputDevice* GetAudioOutputDevice(); |
133 |
|
|
134 |
/** |
/** |
135 |
|
* Returns the MIDI input device to which this sampler channel |
136 |
|
* is currently connected to. |
137 |
|
* |
138 |
|
* @returns pointer to MIDI input device or NULL if not |
139 |
|
* connected |
140 |
|
*/ |
141 |
|
MidiInputDevice* GetMidiInputDevice(); |
142 |
|
|
143 |
|
/** |
144 |
* Returns the index number of this sampler channel within the |
* Returns the index number of this sampler channel within the |
145 |
* Sampler instance. |
* Sampler instance. |
146 |
*/ |
*/ |
150 |
SamplerChannel(Sampler* pS); |
SamplerChannel(Sampler* pS); |
151 |
~SamplerChannel(); |
~SamplerChannel(); |
152 |
|
|
153 |
|
/** Getting MIDI input device port given its index number. */ |
154 |
|
MidiInputDevice::MidiInputPort* GetMidiInputDevicePort(int MidiPort); |
155 |
|
|
156 |
Sampler* pSampler; |
Sampler* pSampler; |
157 |
Engine* pEngine; |
Engine* pEngine; |
|
MidiInputDevice* pMidiInputDevice; |
|
158 |
AudioOutputDevice* pAudioOutputDevice; |
AudioOutputDevice* pAudioOutputDevice; |
159 |
|
MidiInputDevice* pMidiInputDevice; |
160 |
|
int midiPort; |
161 |
|
MidiInputDevice::MidiInputPort::midi_chan_t midiChannel; |
162 |
int iIndex; |
int iIndex; |
163 |
|
|
164 |
friend class Sampler; |
friend class Sampler; |
230 |
uint SamplerChannels(); |
uint SamplerChannels(); |
231 |
|
|
232 |
/** |
/** |
233 |
* Create and add a new sampler channel to this Sampler instance. |
* Create and add a new sampler channel to this Sampler |
234 |
|
* instance. For race condition reasons the new channel will use |
235 |
|
* an index past the last already existing sampler channel |
236 |
|
* index (in case the index limit was not reached yet, otherwise |
237 |
|
* a free index starting from 0 is searched). |
238 |
* |
* |
239 |
* @returns pointer to new sampler channel |
* @returns pointer to new sampler channel |
240 |
*/ |
*/ |
249 |
SamplerChannel* GetSamplerChannel(uint uiSamplerChannel); |
SamplerChannel* GetSamplerChannel(uint uiSamplerChannel); |
250 |
|
|
251 |
/** |
/** |
252 |
|
* Returns all created sampler channels. |
253 |
|
*/ |
254 |
|
std::map<uint, SamplerChannel*> GetSamplerChannels(); |
255 |
|
|
256 |
|
/** |
257 |
* Destroy and remove the given sampler channel from this |
* Destroy and remove the given sampler channel from this |
258 |
* Sampler instance. |
* Sampler instance. |
259 |
* |
* |
271 |
void RemoveSamplerChannel(uint uiSamplerChannel); |
void RemoveSamplerChannel(uint uiSamplerChannel); |
272 |
|
|
273 |
/** |
/** |
274 |
* Create an audio output device of the given type. |
* Returns the names of all available audio output drivers. |
275 |
|
*/ |
276 |
|
std::vector<String> AvailableAudioOutputDrivers(); |
277 |
|
|
278 |
|
/** |
279 |
|
* Create an audio output device. |
280 |
* |
* |
281 |
* @param AudioType - desired audio output system to use |
* @param AudioDriver - name of the audio driver |
282 |
|
* @param Parameters - eventually needed driver parameters to |
283 |
|
* create the device |
284 |
* @returns pointer to created audio output device |
* @returns pointer to created audio output device |
285 |
|
* @throws LinuxSamplerException if device could not be created |
286 |
*/ |
*/ |
287 |
AudioOutputDevice* CreateAudioOutputDevice(AudioOutputDevice::type_t AudioType); |
AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (LinuxSamplerException); |
288 |
|
|
289 |
/** |
/** |
290 |
* Returns the audio output device of the given type. |
* Create a midi input device. |
291 |
* |
* |
292 |
* @param AudioType - desired audio output system to use |
* @param MidiDriver - name of the midi driver |
293 |
* @returns pointer to audio output device or NULL if device of |
* @param Parameters - eventually needed driver parameters to |
294 |
* desired type is not yet created |
* create the device |
295 |
|
* @returns pointer to created midi input device |
296 |
|
* @throws LinuxSamplerException if device could not be created |
297 |
*/ |
*/ |
298 |
AudioOutputDevice* GetAudioOutputDevice(AudioOutputDevice::type_t AudioType); |
MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (LinuxSamplerException); |
299 |
|
|
300 |
/** |
/** |
301 |
* Create a MIDI input device of the given type. |
* Returns the number of all created audio output devices. |
302 |
|
*/ |
303 |
|
uint AudioOutputDevices(); |
304 |
|
|
305 |
|
/** |
306 |
|
* Returns the number of all created MIDI input devices. |
307 |
|
*/ |
308 |
|
uint MidiInputDevices(); |
309 |
|
|
310 |
|
/** |
311 |
|
* Returns all created audio output devices. |
312 |
|
*/ |
313 |
|
std::map<uint, AudioOutputDevice*> GetAudioOutputDevices(); |
314 |
|
|
315 |
|
/** |
316 |
|
* Returns all created MIDI input devices. |
317 |
|
*/ |
318 |
|
std::map<uint, MidiInputDevice*> GetMidiInputDevices(); |
319 |
|
|
320 |
|
/** |
321 |
|
* Destroy the given audio output device and takes care if there |
322 |
|
* are still sampler angines connected to this device, etc. |
323 |
* |
* |
324 |
* @param MidiType - desired MIDI input system to use |
* @throws LinuxSamplerException if sampler channels are still |
325 |
* @returns pointer to created MIDI input device |
* connected to the device |
326 |
*/ |
*/ |
327 |
MidiInputDevice* CreateMidiInputDevice(MidiInputDevice::type_t MidiType); |
void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (LinuxSamplerException); |
328 |
|
|
329 |
/** |
/** |
330 |
* Returns the MIDI input device of the given type. |
* Destroy the given MIDI input device and takes care if there |
331 |
|
* are still sampler angines connected to this device, etc. |
332 |
* |
* |
333 |
* @param MidiType - desired MIDI input system to use |
* @throws LinuxSamplerException if sampler channels are still |
334 |
* @returns pointer to MIDI input device or NULL if device of |
* connected to the device |
|
* desired type is not yet created |
|
335 |
*/ |
*/ |
336 |
MidiInputDevice* GetMidiInputDevice(MidiInputDevice::type_t MidiType); |
void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (LinuxSamplerException); |
337 |
|
|
338 |
protected: |
protected: |
339 |
typedef std::map<AudioOutputDevice::type_t, AudioOutputDevice*> AudioOutputDeviceMap; |
typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap; |
340 |
typedef std::map<MidiInputDevice::type_t, MidiInputDevice*> MidiInputDeviceMap; |
typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap; |
341 |
|
typedef std::map<uint, SamplerChannel*> SamplerChannelMap; |
342 |
std::vector<SamplerChannel*> vSamplerChannels; ///< contains all created sampler channels |
|
343 |
AudioOutputDeviceMap AudioOutputDevices; ///< contains all created audio output devices |
SamplerChannelMap mSamplerChannels; ///< contains all created sampler channels |
344 |
MidiInputDeviceMap MidiInputDevices; |
AudioOutputDeviceMap mAudioOutputDevices; ///< contains all created audio output devices |
345 |
|
MidiInputDeviceMap mMidiInputDevices; ///< contains all created MIDI input devices |
346 |
|
|
347 |
friend class SamplerChannel; |
friend class SamplerChannel; |
348 |
}; |
}; |