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

Legend:
Removed from v.53  
changed lines
  Added in v.64

  ViewVC Help
Powered by ViewVC