1 |
persson |
1777 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
schoenebeck |
2434 |
* Copyright (C) 2008 - 2013 Andreas Persson * |
4 |
persson |
1777 |
* * |
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 |
iliev |
1907 |
* Device Parameter 'CHANNELS' |
52 |
|
|
*/ |
53 |
|
|
class ParameterChannelsPlugin : public ParameterChannels { |
54 |
|
|
public: |
55 |
|
|
ParameterChannelsPlugin() : ParameterChannels() { } |
56 |
|
|
ParameterChannelsPlugin(String s) : ParameterChannels(s) { } |
57 |
schoenebeck |
2434 |
virtual bool Fix() OVERRIDE { return true; } |
58 |
persson |
2354 |
void ForceSetValue(int channels); |
59 |
iliev |
1907 |
}; |
60 |
|
|
|
61 |
|
|
/** |
62 |
persson |
1777 |
* Device Parameter 'FRAGMENTSIZE' |
63 |
|
|
* |
64 |
|
|
* Used to set the audio fragment size / period size. |
65 |
|
|
*/ |
66 |
|
|
class ParameterFragmentSize : public DeviceCreationParameterInt { |
67 |
|
|
public: |
68 |
|
|
ParameterFragmentSize(); |
69 |
|
|
ParameterFragmentSize(String s) throw (Exception); |
70 |
schoenebeck |
2434 |
String Description() OVERRIDE; |
71 |
|
|
bool Fix() OVERRIDE; |
72 |
|
|
bool Mandatory() OVERRIDE; |
73 |
|
|
std::map<String,DeviceCreationParameter*> DependsAsParameters() OVERRIDE; |
74 |
|
|
optional<int> DefaultAsInt(std::map<String,String> Parameters) OVERRIDE; |
75 |
|
|
optional<int> RangeMinAsInt(std::map<String,String> Parameters) OVERRIDE; |
76 |
|
|
optional<int> RangeMaxAsInt(std::map<String,String> Parameters) OVERRIDE; |
77 |
|
|
std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters) OVERRIDE; |
78 |
|
|
void OnSetValue(int i) throw (Exception) OVERRIDE; |
79 |
persson |
1777 |
static String Name(); |
80 |
|
|
}; |
81 |
|
|
|
82 |
|
|
// derived abstract methods from class 'AudioOutputDevice' |
83 |
schoenebeck |
2434 |
void Play() OVERRIDE; |
84 |
|
|
bool IsPlaying() OVERRIDE; |
85 |
|
|
void Stop() OVERRIDE; |
86 |
|
|
uint MaxSamplesPerCycle() OVERRIDE; |
87 |
|
|
uint SampleRate() OVERRIDE; |
88 |
|
|
String Driver() OVERRIDE; |
89 |
|
|
AudioChannel* CreateChannel(uint ChannelNr) OVERRIDE; |
90 |
|
|
bool isAutonomousDevice() OVERRIDE; |
91 |
persson |
1777 |
static String Name(); |
92 |
|
|
static String Version(); |
93 |
|
|
static String Description(); |
94 |
schoenebeck |
1934 |
static bool isAutonomousDriver(); |
95 |
persson |
1777 |
|
96 |
|
|
/** |
97 |
|
|
* This should be called by the plugin implementation to let |
98 |
|
|
* the engines render audio. The buffers where the data is |
99 |
|
|
* rendered can be set with Channel(index)->getBuffer(). |
100 |
|
|
* |
101 |
|
|
* @param Samples - number of sample points to be rendered |
102 |
|
|
* @returns 0 on success or the last error return code of one |
103 |
|
|
* engine |
104 |
|
|
*/ |
105 |
|
|
int Render(uint Samples) { return RenderAudio(Samples); } |
106 |
|
|
|
107 |
persson |
2354 |
void AddChannels(int newChannels); |
108 |
|
|
void RemoveChannel(AudioChannel* pChannel); |
109 |
|
|
|
110 |
persson |
1777 |
private: |
111 |
|
|
uint uiSampleRate; |
112 |
|
|
uint uiMaxSamplesPerCycle; |
113 |
|
|
}; |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
#endif |