summaryrefslogtreecommitdiffstats
path: root/soundserver/soundserver.idl
blob: 7c2cc41908100ffd7e2cd11c7fec733ebc7b5d62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#include "artsflow.idl"
#include "kmedia2.idl"
#include "core.idl"

module Arts {

/**
 * One entry of the sample storage - initially, you'll need to fill the entry.
 *
 * To do so, call write repeatedly to fill it with data, and finish() when
 * you are done. After that you can use the filename attribute to get the
 * name of the file on the server that has stored the data. You can use
 * this filename for other things (i.e. SimpleSoundServer::play).
 */
interface SampleStorageEntry {
	readonly attribute string name;
	readonly attribute string filename;
	readonly attribute boolean completed;

	void write(sequence<byte> data);
	void finish();
};

/**
 * Interface for storing files on the sound server
 */
interface SampleStorage {
	void constructor(string directory, boolean clearOnInit);

	/**
	 * creates a new entry which you can use to store a sample - if you just
	 * create an entry, it will be private to you, i.e. you can use it, and
	 * as soon as you don't need it any longer, it will be freed
	 *
	 * if you want that the entry stays in the storage, you need to add it,
	 * and it will stay then until you remove it
	 */
	SampleStorageEntry createEntry(string name);

	/**
	 * add an entry (which will make it accessible via findEntry) - remember
	 * to eventually call removeEntry, or the entry will stay there forever
	 */
	void addEntry(SampleStorageEntry entry);

	/**
	 * removes an entry, that is, the entry will only stay there until
	 * nobody needs it any more and then get freed
	 */
	void removeEntry(SampleStorageEntry entry);

	/**
	 * finds an entry by name
	 */
	SampleStorageEntry findEntry(string name);
};

/**
 * Producer of byte sound
 *
 * This is used inside the sound server interface
 */
interface ByteSoundProducer : SynthModule
{
	readonly attribute long samplingRate;
	readonly attribute long channels;
	readonly attribute long bits;

	async out byte stream outdata;
};

/**
 * V2 version of the ByteSoundProducer interface that implements the title
 * attribute
 */
interface ByteSoundProducerV2 : ByteSoundProducer
{
	readonly attribute string title;
};

/**
 * Receiver of byte sound
 */
interface ByteSoundReceiver : SynthModule
{
	readonly attribute long samplingRate;
	readonly attribute long channels;
	readonly attribute long bits;
	readonly attribute string title;

	async in byte stream indata;
};

/**
 * This is a very simple sound server interface
 *
 * WARNING: This currently inherits a KMedia2 PlayObjectFactory for test
 *          purposes, but don't rely on that
 */

interface SimpleSoundServer : PlayObjectFactory
{
	readonly attribute StereoEffectStack outstack;

	/**
	 * tries to play the sound in "filename"
	 *
	 * returns an ID when success 0 when it fails
	 */
	long play(string filename);

	/**
	 * returns true if the sound in ID is still playing
	 */
	//boolean isPlaying(long ID);

	/**
	 * stops a playing sound by ID
	 */
	//void stop(long ID);

	/**
	 * specifies the minimum amount of milliseconds that have to be buffered
	 * to allow safe streaming (without interruptions) from/to external apps
	 *
	 * this depends on the realtime parameters the sound server itself uses
	 * to talk to the hardware
	 */
	readonly attribute float minStreamBufferTime;

	/**
	 * specifies the amount of milliseconds the server itself spends with
	 * the hardware (buffering latency) - so if you stream into the server,
	 * you should have a yourStreamBufferTime >= minStreamBufferTime, and
	 * the total latency is
	 *
	 *  totalLatency = yourStreamBufferTime + serverBufferTime
	 */
	readonly attribute float serverBufferTime;

	/**
	 * attaches a byte sound producer (read: a client which produces/mixes
	 * an audio stream itself and just wants playback via the soundserver)
	 */
	void attach(ByteSoundProducer producer);

	/**
	 * detaches a previous attached byte sound producer
	 */
	void detach(ByteSoundProducer producer);

	/**
	 * attaches a byte sound receiver (a client that records an
	 * audio stream from the soundserver)
	 */
	void attachRecorder(ByteSoundReceiver receiver);

	/**
	 * detaches a previous attached byte sound receiver
	 */
	void detachRecorder(ByteSoundReceiver receiver);

	object createObject(string name);
};

enum RealtimeStatus { rtRealtime, rtNoSupport, rtNoWrapper, rtNoRealtime };

/**
 * This is an enhanced sound server interface which can be used to
 * query status information or suspend the soundserver right away
 */
interface SoundServer : SimpleSoundServer
{
	readonly attribute RealtimeStatus realtimeStatus;

	/**
	 * Returns how many seconds you have to wait _now_ for the soundserver
	 * to suspend. A value of -1 signals that the sound server is busy and
	 * will not suspend automatically at the moment.
	 */
	readonly attribute long secondsUntilSuspend;

	/**
	 * Makes the soundserver suspend now _if_ it is not busy playing, that
	 * is, if it is "suspendable". Returns true if successful.
	 */
	boolean suspend();

	/**
	 * Asks the soundserver if it is suspended.  Returns true if so.
	 */
	boolean suspended();

	/**
	 * Permanently terminates the sound server - this is not intended to be
	 * widely used. However, it provides a way to "kill" the sound server,
	 * even if you don't reside on the same host with it, and even if you
	 * don't know the process id, and so on. In the future it also offers
	 * the possibility for interested apps to be informed before the server
	 * goes away, and for important apps to block termination.
	 *
	 * Returns true if successful.
	 */
	boolean terminate();
};

/**
 * This is an even more enhanced sound server interface that supports changing
 * the autosuspend time, and returning more information about the server
 * settings.
 */
interface SoundServerV2 : SoundServer, PlayObjectFactoryV2
{
	/**
	 * Time in seconds after which server will suspend if idle.
	 */
	attribute long autoSuspendSeconds;

	/**
	 * Multiplier for size of network buffers. Default is 1,
	 * which is fragment size * fragment count. (expressed
	 * as milliseconds).
	 */
	attribute long bufferSizeMultiplier;

	/**
	 * Current CPU usage in percent
	 */
	readonly attribute float cpuUsage;

	/**
	 * AudioSubSystem parameters
	 */
	readonly attribute string audioMethod;
	readonly attribute long samplingRate;
	readonly attribute long channels;
	readonly attribute long bits;
	readonly attribute boolean fullDuplex;
	readonly attribute string audioDevice;
	readonly attribute long fragments;
	readonly attribute long fragmentSize;

	/**
	 * version
	 */
	readonly attribute string version;

	/**
	 * global output volume for the sound server
	 */
	readonly attribute StereoVolumeControl outVolume;

	/**
	 * for storing samples on the sound server
	 */
	readonly attribute SampleStorage sampleStorage;

	/**
	 * this method checks for new object implementations (you can call this
	 * if you have implemented and installed new components in C++ or with
	 * artsbuilder, to make the soundserver use them without restart)
	 */
	void checkNewObjects();
};

/**
 * A KMedia2 Wave PlayObject
 */
interface WavPlayObject : PlayObject, SynthModule
{
	out audio stream left,right;
};

/**
 * An advanced KMedia2 PlayObject based on GSL datahandles
 */
interface GSLPlayObject : PlayObject, PitchablePlayObject, SynthModule
{
	attribute boolean done;

	out audio stream left,right;
};

/**
 * Helper interface to ensure that artsd gets initialized properly when
 * multiple artsd processes are started at the same time.
 */
interface SoundServerStartup
{
	void lock();
	void unlock();
};

};