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 Christian Schoenebeck * |
* Copyright (C) 2005, 2006 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program 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 * |
27 |
#include <vector> |
#include <vector> |
28 |
#include <map> |
#include <map> |
29 |
#include "common/global.h" |
#include "common/global.h" |
30 |
#include "common/LinuxSamplerException.h" |
#include "common/Exception.h" |
31 |
#include "engines/common/EngineChannel.h" |
#include "engines/EngineChannel.h" |
32 |
#include "drivers/midi/MidiInputDevice.h" |
#include "drivers/midi/MidiInputDevice.h" |
33 |
#include "drivers/audio/AudioOutputDevice.h" |
#include "drivers/audio/AudioOutputDevice.h" |
34 |
|
|
39 |
|
|
40 |
/** @brief LinuxSampler sampler channel |
/** @brief LinuxSampler sampler channel |
41 |
* |
* |
42 |
* Encapsulates a channel of a specific sampler engine typ, one |
* Encapsulates a channel of a specific sampler engine type, one |
43 |
* connection to a MIDI input device and one connection to an audio |
* connection to a MIDI input device and one connection to an audio |
44 |
* output device. You cannot create an instance of this class on your |
* output device. You cannot create an instance of this class on your |
45 |
* own, you have to use the AddSamplerChannel() method of the Sampler |
* own, you have to use the AddSamplerChannel() method of the Sampler |
51 |
* Assign a sampler engine type to this sampler channel. |
* Assign a sampler engine type to this sampler channel. |
52 |
* |
* |
53 |
* @param EngineType - type of the engine to use |
* @param EngineType - type of the engine to use |
54 |
* @throws LinuxSamplerException - if \a EngineType is invalid |
* @throws Exception - if \a EngineType is invalid |
55 |
*/ |
*/ |
56 |
void SetEngineType(String EngineType) throw (LinuxSamplerException); |
void SetEngineType(String EngineType) throw (Exception); |
57 |
|
|
58 |
/** |
/** |
59 |
* Connect this sampler channel to an audio output device, that |
* Connect this sampler channel to an audio output device, that |
155 |
|
|
156 |
/** Getting MIDI input device port given its index number. */ |
/** Getting MIDI input device port given its index number. */ |
157 |
MidiInputPort* __GetMidiInputDevicePort(int iMidiPort); |
MidiInputPort* __GetMidiInputDevicePort(int iMidiPort); |
|
midi_chan_t __GetMidiChannel(); |
|
158 |
|
|
159 |
Sampler* pSampler; |
Sampler* pSampler; |
160 |
EngineChannel* pEngineChannel; |
EngineChannel* pEngineChannel; |
177 |
* engine, connected to an arbitrary MIDI input device and connected to |
* engine, connected to an arbitrary MIDI input device and connected to |
178 |
* an arbitrary audio output device. Here an example setup: |
* an arbitrary audio output device. Here an example setup: |
179 |
* @code |
* @code |
180 |
* S.Channel. MIDI in S.Engine Audio out |
* S.Channel MIDI in S.Engine Audio out |
181 |
* ------------------------------------------------------------------- |
* ------------------------------------------------------------------- |
182 |
* 0 Alsa -> gig::Engine -> Jack |
* 0 Alsa -> gig::Engine -> Jack |
183 |
* 1 VSTi -> Akai::Engine -> VSTi |
* 1 VSTi -> Akai::Engine -> VSTi |
184 |
* 2 Jack -> DLS::Engine -> Jack |
* 2 Jack -> DLS::Engine -> Jack |
185 |
* 3 Jack -> SF::Engine -> Alsa |
* 3 Jack -> SF::Engine -> Alsa |
186 |
* |
* |
187 |
* ... (and so on) ... |
* ... (and so on) ... |
188 |
* @endcode |
* @endcode |
189 |
* |
* |
190 |
* Note that not all audio and MIDI backends and sampler engines listed |
* Note that not all audio and MIDI backends and sampler engines listed |
191 |
* in the example above are already implemented! |
* in the example above might already been implemented! |
192 |
* |
* |
193 |
* As you can see in the example setup, LinuxSampler is capable to use |
* As you can see in the example setup, LinuxSampler is capable to use |
194 |
* several, different audio output and MIDI input systems |
* several, different audio output and MIDI input systems |
195 |
* simultaniously at the same time. Here the example setup shown in the |
* simultaniously at the same time. Here the example setup shown in the |
196 |
* ascpect of MIDI input and audio output devices / drivers: |
* aspect of MIDI input and audio output devices / drivers: |
197 |
* @code |
* @code |
198 |
* ######################### ######################### |
* ######################### ######################### |
199 |
* # AudioOutputDeviceJack # # AudioOutputDeviceVSTi # |
* # AudioOutputDeviceJack # # AudioOutputDeviceVSTi # |
200 |
* ######################### ######################### |
* ######################### ######################### |
201 |
* ^ ^ ^ |
* ^ ^ ^ |
202 |
* /------------>|Sampler Channel 0|-----/ | | |
* /------------>|Sampler Channel 0|-----/ | | |
203 |
* | /--------->|Sampler Channel 1|---------------------/ |
* | /--------->|Sampler Channel 1|---------------------/ |
204 |
* | | /------>|Sampler Channel 2|---------/ |
* | | /------>|Sampler Channel 2|---------/ |
205 |
* | | | /--->|Sampler Channel 3|------------>######################### |
* | | | /--->|Sampler Channel 3|------------>######################### |
206 |
* | | | | ... (and so on) ... # AudioOutputDeviceAlsa # |
* | | | | ... (and so on) ... # AudioOutputDeviceAlsa # |
207 |
* | | | | ######################### |
* | | | | ######################### |
208 |
* | | | \-----------------------------------------------------\ |
* | | | \-----------------------------------------------------\ |
209 |
* | | \--------------------------------------------\ | |
* | | \--------------------------------------------\ | |
210 |
* | \--------------------\ | | |
* | \--------------------\ | | |
211 |
* | | | | |
* | | | | |
212 |
* ####################### ####################### ####################### |
* ####################### ####################### ####################### |
213 |
* # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack # |
* # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack # |
214 |
* ####################### ####################### ####################### |
* ####################### ####################### ####################### |
217 |
* As you can see in this example setup, one device (that is midi input |
* As you can see in this example setup, one device (that is midi input |
218 |
* driver / audio output driver) can be connected multiple times to |
* driver / audio output driver) can be connected multiple times to |
219 |
* different sampler channels. |
* different sampler channels. |
220 |
|
* |
221 |
|
* It's even possible to create multiple instances of the same driver, for |
222 |
|
* example multiple instances of the Alsa output driver to use multiple |
223 |
|
* sound cards at the same time, or multiple instances of the JACK audio |
224 |
|
* output driver to leverage SMP systems or boxes with several hard discs. |
225 |
*/ |
*/ |
226 |
class Sampler { |
class Sampler { |
227 |
public: |
public: |
293 |
* @param Parameters - eventually needed driver parameters to |
* @param Parameters - eventually needed driver parameters to |
294 |
* create the device |
* create the device |
295 |
* @returns pointer to created audio output device |
* @returns pointer to created audio output device |
296 |
* @throws LinuxSamplerException if device could not be created |
* @throws Exception if device could not be created |
297 |
*/ |
*/ |
298 |
AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (LinuxSamplerException); |
AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (Exception); |
299 |
|
|
300 |
/** |
/** |
301 |
* Create a midi input device. |
* Create a midi input device. |
304 |
* @param Parameters - eventually needed driver parameters to |
* @param Parameters - eventually needed driver parameters to |
305 |
* create the device |
* create the device |
306 |
* @returns pointer to created midi input device |
* @returns pointer to created midi input device |
307 |
* @throws LinuxSamplerException if device could not be created |
* @throws Exception if device could not be created |
308 |
*/ |
*/ |
309 |
MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (LinuxSamplerException); |
MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception); |
310 |
|
|
311 |
/** |
/** |
312 |
* Returns the number of all created audio output devices. |
* Returns the number of all created audio output devices. |
332 |
* Destroy the given audio output device and takes care if there |
* Destroy the given audio output device and takes care if there |
333 |
* are still sampler angines connected to this device, etc. |
* are still sampler angines connected to this device, etc. |
334 |
* |
* |
335 |
* @throws LinuxSamplerException if sampler channels are still |
* @throws Exception if sampler channels are still |
336 |
* connected to the device |
* connected to the device |
337 |
*/ |
*/ |
338 |
void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (LinuxSamplerException); |
void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception); |
339 |
|
|
340 |
/** |
/** |
341 |
* Destroy the given MIDI input device and takes care if there |
* Destroy the given MIDI input device and takes care if there |
342 |
* are still sampler angines connected to this device, etc. |
* are still sampler angines connected to this device, etc. |
343 |
* |
* |
344 |
* @throws LinuxSamplerException if sampler channels are still |
* @throws Exception if sampler channels are still |
345 |
* connected to the device |
* connected to the device |
346 |
|
*/ |
347 |
|
void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception); |
348 |
|
|
349 |
|
/** |
350 |
|
* Gets the current number of all active voices. |
351 |
|
* @returns The current number of all active voices. |
352 |
*/ |
*/ |
353 |
void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (LinuxSamplerException); |
int GetVoiceCount(); |
354 |
|
|
355 |
/** |
/** |
356 |
* Reset the whole sampler. Destroy all engines, sampler |
* Reset the whole sampler. Destroy all engines, sampler |