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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 64 - (hide annotations) (download) (as text)
Thu May 6 20:06:20 2004 UTC (19 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 11766 byte(s)
* src/Sampler.cpp: fixed 3 stupid but fatal bugs that left in the rush (in
  method SamplerChannels(), CreateAudioOutputDevice() and
  CreateMidiInputDevice())
* src/network/lscpserver.cpp: implemented LSCP command
  'SET CHANNEL MIDI_INPUT_CHANNEL'
* src/Sampler.h: moved enums 'audio_output_type_t', 'midi_input_type_t'
  and 'engine_type_t' into the respective base classes
  ('AudioOutputDevice', 'MidiInputDevice', 'Engine')

1 schoenebeck 53 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5 schoenebeck 61 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 53 * *
7     * 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 *
9     * the Free Software Foundation; either version 2 of the License, or *
10     * (at your option) any later version. *
11     * *
12     * This program is distributed in the hope that it will be useful, *
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15     * GNU General Public License for more details. *
16     * *
17     * You should have received a copy of the GNU General Public License *
18     * along with this program; if not, write to the Free Software *
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20     * MA 02111-1307 USA *
21     ***************************************************************************/
22    
23     #ifndef __LS_SAMPLER_H__
24     #define __LS_SAMPLER_H__
25    
26     #include <vector>
27     #include <map>
28     #include "common/global.h"
29     #include "common/LinuxSamplerException.h"
30     #include "engines/common/Engine.h"
31     #include "mididriver/MidiInputDevice.h"
32     #include "audiodriver/AudioOutputDevice.h"
33    
34     namespace LinuxSampler {
35    
36     // just symbol prototyping
37     class Sampler;
38    
39 schoenebeck 57 /** 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 schoenebeck 53 class SamplerChannel {
48     public:
49 schoenebeck 57 /**
50     * Deploy a sampler engine of the given type for this sampler
51     * channnel. If there was already a sampler engine deployed on
52     * this sampler channel, then the old engine will automatically
53     * be destroyed.
54     *
55     * @param EngineType - type of the engine to deploy
56     */
57 schoenebeck 64 void LoadEngine(Engine::type_t EngineType);
58 schoenebeck 57
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 schoenebeck 64 void SetAudioOutputDevice(AudioOutputDevice::type_t AudioType);
71 schoenebeck 57
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 schoenebeck 64 void SetMidiInputDevice(MidiInputDevice::type_t MidiType, MidiInputDevice::midi_chan_t MidiChannel = MidiInputDevice::midi_chan_all);
87 schoenebeck 57
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();
112    
113     /**
114     * Returns the index number of this sampler channel within the
115     * Sampler instance.
116     */
117     uint Index();
118    
119     protected:
120 schoenebeck 53 SamplerChannel(Sampler* pS);
121     ~SamplerChannel();
122 schoenebeck 57
123 schoenebeck 53 Sampler* pSampler;
124     Engine* pEngine;
125     MidiInputDevice* pMidiInputDevice;
126     AudioOutputDevice* pAudioOutputDevice;
127     int iIndex;
128 schoenebeck 57
129     friend class Sampler;
130 schoenebeck 53 };
131    
132 schoenebeck 57 /** 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 schoenebeck 53 class Sampler {
181     public:
182 schoenebeck 57 /**
183     * Constructor. Create a LinuxSampler instance.
184     */
185 schoenebeck 53 Sampler();
186 schoenebeck 57
187     /**
188     * Destructor.
189     */
190 schoenebeck 53 ~Sampler();
191 schoenebeck 57
192     /**
193     * Returns the number of sampler channels currently allocated.
194     */
195     uint SamplerChannels();
196    
197     /**
198     * Create and add a new sampler channel to this Sampler instance.
199     *
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 schoenebeck 64 AudioOutputDevice* CreateAudioOutputDevice(AudioOutputDevice::type_t AudioType);
236 schoenebeck 57
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 schoenebeck 64 AudioOutputDevice* GetAudioOutputDevice(AudioOutputDevice::type_t AudioType);
245 schoenebeck 57
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 schoenebeck 64 MidiInputDevice* CreateMidiInputDevice(MidiInputDevice::type_t MidiType);
253 schoenebeck 57
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 schoenebeck 64 MidiInputDevice* GetMidiInputDevice(MidiInputDevice::type_t MidiType);
262 schoenebeck 57
263 schoenebeck 53 protected:
264 schoenebeck 64 typedef std::map<AudioOutputDevice::type_t, AudioOutputDevice*> AudioOutputDeviceMap;
265     typedef std::map<MidiInputDevice::type_t, MidiInputDevice*> MidiInputDeviceMap;
266 schoenebeck 53
267     std::vector<SamplerChannel*> vSamplerChannels; ///< contains all created sampler channels
268     AudioOutputDeviceMap AudioOutputDevices; ///< contains all created audio output devices
269     MidiInputDeviceMap MidiInputDevices;
270    
271     friend class SamplerChannel;
272     };
273     }
274    
275     #endif // __LS_SAMPLER_H__

  ViewVC Help
Powered by ViewVC