/[svn]/linuxsampler/trunk/src/Sampler.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/Sampler.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 56 by schoenebeck, Mon Apr 26 17:15:51 2004 UTC revision 57 by schoenebeck, Sun May 2 17:45:43 2004 UTC
# Line 58  namespace LinuxSampler { Line 58  namespace LinuxSampler {
58      // just symbol prototyping      // just symbol prototyping
59      class Sampler;      class Sampler;
60    
61        /** LinuxSampler sampler channel
62         *
63         * Encapsulates one sampler engine, one connection to a MIDI input
64         * device and one connection to an audio output device. You cannot
65         * create an instance of this class on you own, you have to use the
66         * AddSamplerChannel() method of the Sampler object to create a new
67         * sampler channel.
68         */
69      class SamplerChannel {      class SamplerChannel {
70          public:          public:
71              SamplerChannel(Sampler* pS);              /**
72             ~SamplerChannel();               * Deploy a sampler engine of the given type for this sampler
73              void               LoadEngine(engine_type_t EngineType);               * channnel. If there was already a sampler engine deployed on
74              void               SetAudioOutputDevice(audio_output_type_t AudioType);               * this sampler channel, then the old engine will automatically
75              void               SetMidiInputDevice(midi_input_type_t MidiType, MidiInputDevice::midi_chan_t MidiChannel = MidiInputDevice::midi_chan_all);               * be destroyed.
76              Engine*            GetEngine();               *
77              MidiInputDevice*   GetMidiInputDevice();               * @param EngineType - type of the engine to deploy
78                 */
79                void LoadEngine(engine_type_t EngineType);
80    
81                /**
82                 * Connect this sampler channel to an audio output device (that
83                 * is audio output driver) of the given type. If the audio
84                 * output for the desired audio output system is not yet
85                 * created, then it will be created automatically, but with
86                 * default settings though. If this sampler channel was already
87                 * connected to an audio output device, then the old connection
88                 * will automatically be removed before.
89                 *
90                 * @param AudioType - audio output system to connect to
91                 */
92                void SetAudioOutputDevice(audio_output_type_t AudioType);
93    
94                /**
95                 * Connect this sampler channel to and MIDI input device (that
96                 * is MIDI input driver) of the given type. If the MIDI input
97                 * driver for the desired MIDI input system is not yet created,
98                 * then it will be created automatically, but with default
99                 * settings though. If this sampler channel was already
100                 * connected to a MIDI input device, then the old connection
101                 * will automatically be removed before.
102                 *
103                 * @param MidiType    - MIDI input system to connect to
104                 * @param MidiChannel - optional: MIDI channel on which the
105                 *                      sampler channel should listen to
106                 *                      (default: listen on all MIDI channels)
107                 */
108                void SetMidiInputDevice(midi_input_type_t MidiType, MidiInputDevice::midi_chan_t MidiChannel = MidiInputDevice::midi_chan_all);
109    
110                /**
111                 * Returns the engine that was deployed on this sampler channel.
112                 *
113                 * @returns  pointer to engine or NULL if no engine deployed
114                 */
115                Engine* GetEngine();
116    
117                /**
118                 * Returns the MIDI input device to which this sampler channel
119                 * is currently connected to.
120                 *
121                 * @returns  pointer to MIDI input device or NULL if not
122                 *           connected
123                 */
124                MidiInputDevice* GetMidiInputDevice();
125    
126                /**
127                 * Returns the audio output device to which this sampler channel
128                 * is currently connected to.
129                 *
130                 * @returns  pointer to audio output device or NULL if not
131                 *           connected
132                 */
133              AudioOutputDevice* GetAudioOutputDevice();              AudioOutputDevice* GetAudioOutputDevice();
134              uint               Index();  
135                /**
136                 * Returns the index number of this sampler channel within the
137                 * Sampler instance.
138                 */
139                uint Index();
140    
141          protected:          protected:
142                SamplerChannel(Sampler* pS);
143               ~SamplerChannel();
144    
145              Sampler*           pSampler;              Sampler*           pSampler;
146              Engine*            pEngine;              Engine*            pEngine;
147              MidiInputDevice*   pMidiInputDevice;              MidiInputDevice*   pMidiInputDevice;
148              AudioOutputDevice* pAudioOutputDevice;              AudioOutputDevice* pAudioOutputDevice;
149              int                iIndex;              int                iIndex;
150    
151                friend class Sampler;
152      };      };
153    
154        /** LinuxSampler main class
155         *
156         * This is the toplevel class for a LinuxSampler instance.
157         *
158         * LinuxSampler can have arbitrary numbers of sampler channels. Each
159         * sampler channel can individually be deployed with it's own sampler
160         * engine, connected to an arbitrary MIDI input device and connected to
161         * an arbitrary audio output device. Here an example setup:
162         *
163         *  S.Channel.      MIDI in         S.Engine                Audio out
164         *  -------------------------------------------------------------------
165         *  0               Alsa    ->      gig::Engine     ->      Jack
166         *  1               VSTi    ->      Akai::Engine    ->      VSTi
167         *  2               Jack    ->      DLS::Engine     ->      Jack
168         *  3               Jack    ->      SF::Engine      ->      Alsa
169         *
170         *  ... (and so on) ...
171         *
172         * Note that not all audio and MIDI backends and sampler engines listed
173         * in the example above are already implemented!
174         *
175         * As you can see in the example setup, LinuxSampler is capable to use
176         * several, different audio output and MIDI input systems
177         * simultaniously at the same time. Here the example setup shown in the
178         * ascpect of MIDI input and audio output devices / drivers:
179         *
180         *                            ######################### #########################
181         *                            # AudioOutputDeviceJack # # AudioOutputDeviceVSTi #
182         *                            ######################### #########################
183         *                                          ^   ^           ^
184         *    /------------>|Sampler Channel 0|-----/   |           |
185         *    |  /--------->|Sampler Channel 1|---------------------/
186         *    |  |    /---->|Sampler Channel 2|---------/
187         *    |  |    |  /->|Sampler Channel 3|------------>#########################
188         *    |  |    |  |  ... (and so on) ...             # AudioOutputDeviceAlsa #
189         *    |  |    |  |                                  #########################
190         *    |  |    |  \----------------------------------------------------\
191         *    |  |    \-------------------------------------------\           |
192         *    |  \--------------------\                           |           |
193         *    |                       |                           |           |
194         *  ####################### ####################### #######################
195         *  # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack #
196         *  ####################### ####################### #######################
197         *
198         * As you can see in this example setup, one device (that is midi input
199         * driver / audio output driver) can be connected multiple times to
200         * different sampler channels.
201         */
202      class Sampler {      class Sampler {
203          public:          public:
204                /**
205                 * Constructor. Create a LinuxSampler instance.
206                 */
207              Sampler();              Sampler();
208    
209                /**
210                 * Destructor.
211                 */
212             ~Sampler();             ~Sampler();
213              uint               SamplerChannels();  
214              SamplerChannel*    AddSamplerChannel();              /**
215              SamplerChannel*    GetSamplerChannel(uint uiSamplerChannel);               * Returns the number of sampler channels currently allocated.
216              void               RemoveSamplerChannel(SamplerChannel* pSamplerChannel);               */
217              void               RemoveSamplerChannel(uint uiSamplerChannel);              uint SamplerChannels();
218    
219                /**
220                 * Create and add a new sampler channel to this Sampler instance.
221                 *
222                 * @returns  pointer to new sampler channel
223                 */
224                SamplerChannel* AddSamplerChannel();
225    
226                /**
227                 * Returns the sampler channel of the given sampler channel
228                 * index.
229                 *
230                 * @returns  pointer to sought sampler channel
231                 */
232                SamplerChannel* GetSamplerChannel(uint uiSamplerChannel);
233    
234                /**
235                 * Destroy and remove the given sampler channel from this
236                 * Sampler instance.
237                 *
238                 * @param pSamplerChannel - pointer to sampler channel to remove
239                 */
240                void RemoveSamplerChannel(SamplerChannel* pSamplerChannel);
241    
242                /**
243                 * Destroy and remove the given sampler channel from this
244                 * Sampler instance.
245                 *
246                 * @param uiSamplerChannel - index of the sampler channel to
247                 *                           remove
248                 */
249                void RemoveSamplerChannel(uint uiSamplerChannel);
250    
251                /**
252                 * Create an audio output device of the given type.
253                 *
254                 * @param AudioType - desired audio output system to use
255                 * @returns  pointer to created audio output device
256                 */
257              AudioOutputDevice* CreateAudioOutputDevice(audio_output_type_t AudioType);              AudioOutputDevice* CreateAudioOutputDevice(audio_output_type_t AudioType);
258    
259                /**
260                 * Returns the audio output device of the given type.
261                 *
262                 * @param AudioType - desired audio output system to use
263                 * @returns  pointer to audio output device or NULL if device of
264                 *           desired type is not yet created
265                 */
266              AudioOutputDevice* GetAudioOutputDevice(audio_output_type_t AudioType);              AudioOutputDevice* GetAudioOutputDevice(audio_output_type_t AudioType);
267              MidiInputDevice*   CreateMidiInputDevice(midi_input_type_t MidiType);  
268              MidiInputDevice*   GetMidiInputDevice(midi_input_type_t MidiType);              /**
269                 * Create a MIDI input device of the given type.
270                 *
271                 * @param MidiType - desired MIDI input system to use
272                 * @returns  pointer to created MIDI input device
273                 */
274                MidiInputDevice* CreateMidiInputDevice(midi_input_type_t MidiType);
275    
276                /**
277                 * Returns the MIDI input device of the given type.
278                 *
279                 * @param MidiType - desired MIDI input system to use
280                 * @returns  pointer to MIDI input device or NULL if device of
281                 *           desired type is not yet created
282                 */
283                MidiInputDevice* GetMidiInputDevice(midi_input_type_t MidiType);
284    
285          protected:          protected:
286              typedef std::map<audio_output_type_t, AudioOutputDevice*> AudioOutputDeviceMap;              typedef std::map<audio_output_type_t, AudioOutputDevice*> AudioOutputDeviceMap;
287              typedef std::map<midi_input_type_t, MidiInputDevice*> MidiInputDeviceMap;              typedef std::map<midi_input_type_t, MidiInputDevice*> MidiInputDeviceMap;

Legend:
Removed from v.56  
changed lines
  Added in v.57

  ViewVC Help
Powered by ViewVC