/[svn]/linuxsampler/trunk/src/drivers/audio/AudioOutputDevicePlugin.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/drivers/audio/AudioOutputDevicePlugin.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1907 - (show annotations) (download) (as text)
Sat May 16 17:04:37 2009 UTC (14 years, 11 months ago) by iliev
File MIME type: text/x-c++hdr
File size: 4486 byte(s)
* The number of audio channels and MIDI input ports in plugin audio/MIDI
  devices is now fixed and can not be changed once the device is created

1 /***************************************************************************
2 * *
3 * Copyright (C) 2008 Andreas Persson *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
18 * MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef LS_AUDIOOUTPUTDEVICEPLUGIN_H
22 #define LS_AUDIOOUTPUTDEVICEPLUGIN_H
23
24 #include "AudioOutputDevice.h"
25
26 namespace LinuxSampler {
27
28 /** Plugin audio output driver
29 *
30 * Implements audio output when LinuxSampler is running as a
31 * plugin.
32 *
33 * The plugin implementation is given access to the Render
34 * function, which should be called to render audio.
35 */
36 class AudioOutputDevicePlugin : public AudioOutputDevice {
37 public:
38 AudioOutputDevicePlugin(std::map<String,DeviceCreationParameter*> Parameters);
39
40 /**
41 * Audio channel implementation for the plugin audio driver.
42 */
43 class AudioChannelPlugin : public AudioChannel {
44 protected:
45 AudioChannelPlugin(uint ChannelNr);
46
47 friend class AudioOutputDevicePlugin;
48 };
49
50 /**
51 * Device Parameter 'CHANNELS'
52 */
53 class ParameterChannelsPlugin : public ParameterChannels {
54 public:
55 ParameterChannelsPlugin() : ParameterChannels() { }
56 ParameterChannelsPlugin(String s) : ParameterChannels(s) { }
57 virtual bool Fix() { return true; }
58 };
59
60 /**
61 * Device Parameter 'FRAGMENTSIZE'
62 *
63 * Used to set the audio fragment size / period size.
64 */
65 class ParameterFragmentSize : public DeviceCreationParameterInt {
66 public:
67 ParameterFragmentSize();
68 ParameterFragmentSize(String s) throw (Exception);
69 String Description();
70 bool Fix();
71 bool Mandatory();
72 std::map<String,DeviceCreationParameter*> DependsAsParameters();
73 optional<int> DefaultAsInt(std::map<String,String> Parameters);
74 optional<int> RangeMinAsInt(std::map<String,String> Parameters);
75 optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
76 std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
77 void OnSetValue(int i) throw (Exception);
78 static String Name();
79 };
80
81 // derived abstract methods from class 'AudioOutputDevice'
82 void Play();
83 bool IsPlaying();
84 void Stop();
85 uint MaxSamplesPerCycle();
86 uint SampleRate();
87 String Driver();
88 AudioChannel* CreateChannel(uint ChannelNr);
89 static String Name();
90 static String Version();
91 static String Description();
92
93 /**
94 * This should be called by the plugin implementation to let
95 * the engines render audio. The buffers where the data is
96 * rendered can be set with Channel(index)->getBuffer().
97 *
98 * @param Samples - number of sample points to be rendered
99 * @returns 0 on success or the last error return code of one
100 * engine
101 */
102 int Render(uint Samples) { return RenderAudio(Samples); }
103
104 private:
105 uint uiSampleRate;
106 uint uiMaxSamplesPerCycle;
107 };
108 }
109
110 #endif

  ViewVC Help
Powered by ViewVC