1 /**
2 Server interface for low level audio access.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.audioserver;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.audioeffect;
23 import godot.audiobuslayout;
24 /**
25 Server interface for low level audio access.
26 
27 AudioServer is a low level server interface for audio access. It is in charge of creating sample data (playable audio) as well as its playback via a voice interface.
28 */
29 @GodotBaseClass struct AudioServerSingleton
30 {
31 	enum string _GODOT_internal_name = "AudioServer";
32 public:
33 @nogc nothrow:
34 	union { godot_object _godot_object; GodotObject _GODOT_base; }
35 	alias _GODOT_base this;
36 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
37 	package(godot) __gshared bool _classBindingInitialized = false;
38 	package(godot) static struct _classBinding
39 	{
40 		__gshared:
41 		godot_object _singleton;
42 		immutable char* _singletonName = "AudioServer";
43 		@GodotName("set_bus_count") GodotMethod!(void, long) setBusCount;
44 		@GodotName("get_bus_count") GodotMethod!(long) getBusCount;
45 		@GodotName("remove_bus") GodotMethod!(void, long) removeBus;
46 		@GodotName("add_bus") GodotMethod!(void, long) addBus;
47 		@GodotName("move_bus") GodotMethod!(void, long, long) moveBus;
48 		@GodotName("set_bus_name") GodotMethod!(void, long, String) setBusName;
49 		@GodotName("get_bus_name") GodotMethod!(String, long) getBusName;
50 		@GodotName("get_bus_index") GodotMethod!(long, String) getBusIndex;
51 		@GodotName("set_bus_volume_db") GodotMethod!(void, long, double) setBusVolumeDb;
52 		@GodotName("get_bus_volume_db") GodotMethod!(double, long) getBusVolumeDb;
53 		@GodotName("set_bus_send") GodotMethod!(void, long, String) setBusSend;
54 		@GodotName("get_bus_send") GodotMethod!(String, long) getBusSend;
55 		@GodotName("set_bus_solo") GodotMethod!(void, long, bool) setBusSolo;
56 		@GodotName("is_bus_solo") GodotMethod!(bool, long) isBusSolo;
57 		@GodotName("set_bus_mute") GodotMethod!(void, long, bool) setBusMute;
58 		@GodotName("is_bus_mute") GodotMethod!(bool, long) isBusMute;
59 		@GodotName("set_bus_bypass_effects") GodotMethod!(void, long, bool) setBusBypassEffects;
60 		@GodotName("is_bus_bypassing_effects") GodotMethod!(bool, long) isBusBypassingEffects;
61 		@GodotName("add_bus_effect") GodotMethod!(void, long, AudioEffect, long) addBusEffect;
62 		@GodotName("remove_bus_effect") GodotMethod!(void, long, long) removeBusEffect;
63 		@GodotName("get_bus_effect_count") GodotMethod!(long, long) getBusEffectCount;
64 		@GodotName("get_bus_effect") GodotMethod!(AudioEffect, long, long) getBusEffect;
65 		@GodotName("swap_bus_effects") GodotMethod!(void, long, long, long) swapBusEffects;
66 		@GodotName("set_bus_effect_enabled") GodotMethod!(void, long, long, bool) setBusEffectEnabled;
67 		@GodotName("is_bus_effect_enabled") GodotMethod!(bool, long, long) isBusEffectEnabled;
68 		@GodotName("get_bus_peak_volume_left_db") GodotMethod!(double, long, long) getBusPeakVolumeLeftDb;
69 		@GodotName("get_bus_peak_volume_right_db") GodotMethod!(double, long, long) getBusPeakVolumeRightDb;
70 		@GodotName("lock") GodotMethod!(void) lock;
71 		@GodotName("unlock") GodotMethod!(void) unlock;
72 		@GodotName("get_speaker_mode") GodotMethod!(AudioServer.SpeakerMode) getSpeakerMode;
73 		@GodotName("get_mix_rate") GodotMethod!(double) getMixRate;
74 		@GodotName("get_device_list") GodotMethod!(Array) getDeviceList;
75 		@GodotName("get_device") GodotMethod!(String) getDevice;
76 		@GodotName("set_device") GodotMethod!(void, String) setDevice;
77 		@GodotName("capture_get_device_list") GodotMethod!(Array) captureGetDeviceList;
78 		@GodotName("capture_get_device") GodotMethod!(String) captureGetDevice;
79 		@GodotName("capture_set_device") GodotMethod!(void, String) captureSetDevice;
80 		@GodotName("set_bus_layout") GodotMethod!(void, AudioBusLayout) setBusLayout;
81 		@GodotName("generate_bus_layout") GodotMethod!(AudioBusLayout) generateBusLayout;
82 	}
83 	bool opEquals(in AudioServerSingleton other) const { return _godot_object.ptr is other._godot_object.ptr; }
84 	AudioServerSingleton opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
85 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
86 	mixin baseCasts;
87 	static AudioServerSingleton _new()
88 	{
89 		static godot_class_constructor constructor;
90 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AudioServer");
91 		if(constructor is null) return typeof(this).init;
92 		return cast(AudioServerSingleton)(constructor());
93 	}
94 	@disable new(size_t s);
95 	/// 
96 	enum SpeakerMode : int
97 	{
98 		/**
99 		Two or fewer speakers are detected.
100 		*/
101 		speakerModeStereo = 0,
102 		/**
103 		
104 		*/
105 		speakerSurround31 = 1,
106 		/**
107 		A 5.1 channel surround setup detected.
108 		*/
109 		speakerSurround51 = 2,
110 		/**
111 		A 7.1 channel surround setup detected.
112 		*/
113 		speakerSurround71 = 3,
114 	}
115 	/// 
116 	enum Constants : int
117 	{
118 		speakerModeStereo = 0,
119 		speakerSurround31 = 1,
120 		speakerSurround51 = 2,
121 		speakerSurround71 = 3,
122 	}
123 	/**
124 	Adds and removes busses to make the number of busses match `amount`.
125 	*/
126 	void setBusCount(in long amount)
127 	{
128 		checkClassBinding!(typeof(this))();
129 		ptrcall!(void)(_classBinding.setBusCount, _godot_object, amount);
130 	}
131 	/**
132 	Returns the number of available busses.
133 	*/
134 	long getBusCount() const
135 	{
136 		checkClassBinding!(typeof(this))();
137 		return ptrcall!(long)(_classBinding.getBusCount, _godot_object);
138 	}
139 	/**
140 	Removes the bus at index `index`.
141 	*/
142 	void removeBus(in long index)
143 	{
144 		checkClassBinding!(typeof(this))();
145 		ptrcall!(void)(_classBinding.removeBus, _godot_object, index);
146 	}
147 	/**
148 	Adds a bus at `at_position`.
149 	*/
150 	void addBus(in long at_position = -1)
151 	{
152 		checkClassBinding!(typeof(this))();
153 		ptrcall!(void)(_classBinding.addBus, _godot_object, at_position);
154 	}
155 	/**
156 	Moves the bus from index `index` to index `to_index`.
157 	*/
158 	void moveBus(in long index, in long to_index)
159 	{
160 		checkClassBinding!(typeof(this))();
161 		ptrcall!(void)(_classBinding.moveBus, _godot_object, index, to_index);
162 	}
163 	/**
164 	Sets the name of the bus at index `bus_idx` to `name`.
165 	*/
166 	void setBusName(StringArg1)(in long bus_idx, in StringArg1 name)
167 	{
168 		checkClassBinding!(typeof(this))();
169 		ptrcall!(void)(_classBinding.setBusName, _godot_object, bus_idx, name);
170 	}
171 	/**
172 	Returns the name of the bus with the index `bus_idx`.
173 	*/
174 	String getBusName(in long bus_idx) const
175 	{
176 		checkClassBinding!(typeof(this))();
177 		return ptrcall!(String)(_classBinding.getBusName, _godot_object, bus_idx);
178 	}
179 	/**
180 	Returns the index of the bus with the name `bus_name`.
181 	*/
182 	long getBusIndex(StringArg0)(in StringArg0 bus_name) const
183 	{
184 		checkClassBinding!(typeof(this))();
185 		return ptrcall!(long)(_classBinding.getBusIndex, _godot_object, bus_name);
186 	}
187 	/**
188 	Sets the volume of the bus at index `bus_idx` to `volume_db`.
189 	*/
190 	void setBusVolumeDb(in long bus_idx, in double volume_db)
191 	{
192 		checkClassBinding!(typeof(this))();
193 		ptrcall!(void)(_classBinding.setBusVolumeDb, _godot_object, bus_idx, volume_db);
194 	}
195 	/**
196 	Returns the volume of the bus at index `bus_idx` in dB.
197 	*/
198 	double getBusVolumeDb(in long bus_idx) const
199 	{
200 		checkClassBinding!(typeof(this))();
201 		return ptrcall!(double)(_classBinding.getBusVolumeDb, _godot_object, bus_idx);
202 	}
203 	/**
204 	Connects the output of the bus at `bus_idx` to the bus named `send`.
205 	*/
206 	void setBusSend(StringArg1)(in long bus_idx, in StringArg1 send)
207 	{
208 		checkClassBinding!(typeof(this))();
209 		ptrcall!(void)(_classBinding.setBusSend, _godot_object, bus_idx, send);
210 	}
211 	/**
212 	Returns the name of the bus that the bus at index `bus_idx` sends to.
213 	*/
214 	String getBusSend(in long bus_idx) const
215 	{
216 		checkClassBinding!(typeof(this))();
217 		return ptrcall!(String)(_classBinding.getBusSend, _godot_object, bus_idx);
218 	}
219 	/**
220 	If `true` the bus at index `bus_idx` is in solo mode.
221 	*/
222 	void setBusSolo(in long bus_idx, in bool enable)
223 	{
224 		checkClassBinding!(typeof(this))();
225 		ptrcall!(void)(_classBinding.setBusSolo, _godot_object, bus_idx, enable);
226 	}
227 	/**
228 	If `true` the bus at index `bus_idx` is in solo mode.
229 	*/
230 	bool isBusSolo(in long bus_idx) const
231 	{
232 		checkClassBinding!(typeof(this))();
233 		return ptrcall!(bool)(_classBinding.isBusSolo, _godot_object, bus_idx);
234 	}
235 	/**
236 	If `true` the bus at index `bus_idx` is muted.
237 	*/
238 	void setBusMute(in long bus_idx, in bool enable)
239 	{
240 		checkClassBinding!(typeof(this))();
241 		ptrcall!(void)(_classBinding.setBusMute, _godot_object, bus_idx, enable);
242 	}
243 	/**
244 	If `true` the bus at index `bus_idx` is muted.
245 	*/
246 	bool isBusMute(in long bus_idx) const
247 	{
248 		checkClassBinding!(typeof(this))();
249 		return ptrcall!(bool)(_classBinding.isBusMute, _godot_object, bus_idx);
250 	}
251 	/**
252 	If `true` the bus at index `bus_idx` is bypassing effects.
253 	*/
254 	void setBusBypassEffects(in long bus_idx, in bool enable)
255 	{
256 		checkClassBinding!(typeof(this))();
257 		ptrcall!(void)(_classBinding.setBusBypassEffects, _godot_object, bus_idx, enable);
258 	}
259 	/**
260 	If `true` the bus at index `bus_idx` is bypassing effects.
261 	*/
262 	bool isBusBypassingEffects(in long bus_idx) const
263 	{
264 		checkClassBinding!(typeof(this))();
265 		return ptrcall!(bool)(_classBinding.isBusBypassingEffects, _godot_object, bus_idx);
266 	}
267 	/**
268 	Adds an $(D AudioEffect) effect to the bus `bus_idx` at `at_position`.
269 	*/
270 	void addBusEffect(in long bus_idx, AudioEffect effect, in long at_position = -1)
271 	{
272 		checkClassBinding!(typeof(this))();
273 		ptrcall!(void)(_classBinding.addBusEffect, _godot_object, bus_idx, effect, at_position);
274 	}
275 	/**
276 	Removes the effect at index `effect_idx` from the bus at index `bus_idx`.
277 	*/
278 	void removeBusEffect(in long bus_idx, in long effect_idx)
279 	{
280 		checkClassBinding!(typeof(this))();
281 		ptrcall!(void)(_classBinding.removeBusEffect, _godot_object, bus_idx, effect_idx);
282 	}
283 	/**
284 	Returns the number of effects on the bus at `bus_idx`.
285 	*/
286 	long getBusEffectCount(in long bus_idx)
287 	{
288 		checkClassBinding!(typeof(this))();
289 		return ptrcall!(long)(_classBinding.getBusEffectCount, _godot_object, bus_idx);
290 	}
291 	/**
292 	Returns the $(D AudioEffect) at position `effect_idx` in bus `bus_idx`.
293 	*/
294 	Ref!AudioEffect getBusEffect(in long bus_idx, in long effect_idx)
295 	{
296 		checkClassBinding!(typeof(this))();
297 		return ptrcall!(AudioEffect)(_classBinding.getBusEffect, _godot_object, bus_idx, effect_idx);
298 	}
299 	/**
300 	Swaps the position of two effects in bus `bus_idx`.
301 	*/
302 	void swapBusEffects(in long bus_idx, in long effect_idx, in long by_effect_idx)
303 	{
304 		checkClassBinding!(typeof(this))();
305 		ptrcall!(void)(_classBinding.swapBusEffects, _godot_object, bus_idx, effect_idx, by_effect_idx);
306 	}
307 	/**
308 	If `true` the effect at index `effect_idx` on the bus at index `bus_idx` is enabled.
309 	*/
310 	void setBusEffectEnabled(in long bus_idx, in long effect_idx, in bool enabled)
311 	{
312 		checkClassBinding!(typeof(this))();
313 		ptrcall!(void)(_classBinding.setBusEffectEnabled, _godot_object, bus_idx, effect_idx, enabled);
314 	}
315 	/**
316 	If `true` the effect at index `effect_idx` on the bus at index `bus_idx` is enabled.
317 	*/
318 	bool isBusEffectEnabled(in long bus_idx, in long effect_idx) const
319 	{
320 		checkClassBinding!(typeof(this))();
321 		return ptrcall!(bool)(_classBinding.isBusEffectEnabled, _godot_object, bus_idx, effect_idx);
322 	}
323 	/**
324 	Returns the peak volume of the left speaker at bus index `bus_idx` and channel index `channel`.
325 	*/
326 	double getBusPeakVolumeLeftDb(in long bus_idx, in long channel) const
327 	{
328 		checkClassBinding!(typeof(this))();
329 		return ptrcall!(double)(_classBinding.getBusPeakVolumeLeftDb, _godot_object, bus_idx, channel);
330 	}
331 	/**
332 	Returns the peak volume of the right speaker at bus index `bus_idx` and channel index `channel`.
333 	*/
334 	double getBusPeakVolumeRightDb(in long bus_idx, in long channel) const
335 	{
336 		checkClassBinding!(typeof(this))();
337 		return ptrcall!(double)(_classBinding.getBusPeakVolumeRightDb, _godot_object, bus_idx, channel);
338 	}
339 	/**
340 	Locks the audio drivers mainloop. Remember to unlock it afterwards.
341 	*/
342 	void lock()
343 	{
344 		checkClassBinding!(typeof(this))();
345 		ptrcall!(void)(_classBinding.lock, _godot_object);
346 	}
347 	/**
348 	Unlocks the audiodriver's main loop. After locking it always unlock it.
349 	*/
350 	void unlock()
351 	{
352 		checkClassBinding!(typeof(this))();
353 		ptrcall!(void)(_classBinding.unlock, _godot_object);
354 	}
355 	/**
356 	Returns the speaker configuration.
357 	*/
358 	AudioServer.SpeakerMode getSpeakerMode() const
359 	{
360 		checkClassBinding!(typeof(this))();
361 		return ptrcall!(AudioServer.SpeakerMode)(_classBinding.getSpeakerMode, _godot_object);
362 	}
363 	/**
364 	Returns the sample rate at the output of the audioserver.
365 	*/
366 	double getMixRate() const
367 	{
368 		checkClassBinding!(typeof(this))();
369 		return ptrcall!(double)(_classBinding.getMixRate, _godot_object);
370 	}
371 	/**
372 	
373 	*/
374 	Array getDeviceList()
375 	{
376 		checkClassBinding!(typeof(this))();
377 		return ptrcall!(Array)(_classBinding.getDeviceList, _godot_object);
378 	}
379 	/**
380 	
381 	*/
382 	String getDevice()
383 	{
384 		checkClassBinding!(typeof(this))();
385 		return ptrcall!(String)(_classBinding.getDevice, _godot_object);
386 	}
387 	/**
388 	
389 	*/
390 	void setDevice(StringArg0)(in StringArg0 device)
391 	{
392 		checkClassBinding!(typeof(this))();
393 		ptrcall!(void)(_classBinding.setDevice, _godot_object, device);
394 	}
395 	/**
396 	
397 	*/
398 	Array captureGetDeviceList()
399 	{
400 		checkClassBinding!(typeof(this))();
401 		return ptrcall!(Array)(_classBinding.captureGetDeviceList, _godot_object);
402 	}
403 	/**
404 	
405 	*/
406 	String captureGetDevice()
407 	{
408 		checkClassBinding!(typeof(this))();
409 		return ptrcall!(String)(_classBinding.captureGetDevice, _godot_object);
410 	}
411 	/**
412 	
413 	*/
414 	void captureSetDevice(StringArg0)(in StringArg0 name)
415 	{
416 		checkClassBinding!(typeof(this))();
417 		ptrcall!(void)(_classBinding.captureSetDevice, _godot_object, name);
418 	}
419 	/**
420 	Overwrites the currently used $(D AudioBusLayout).
421 	*/
422 	void setBusLayout(AudioBusLayout bus_layout)
423 	{
424 		checkClassBinding!(typeof(this))();
425 		ptrcall!(void)(_classBinding.setBusLayout, _godot_object, bus_layout);
426 	}
427 	/**
428 	Generates an $(D AudioBusLayout) using the available busses and effects.
429 	*/
430 	Ref!AudioBusLayout generateBusLayout() const
431 	{
432 		checkClassBinding!(typeof(this))();
433 		return ptrcall!(AudioBusLayout)(_classBinding.generateBusLayout, _godot_object);
434 	}
435 }
436 /// Returns: the AudioServerSingleton
437 @property @nogc nothrow pragma(inline, true)
438 AudioServerSingleton AudioServer()
439 {
440 	checkClassBinding!AudioServerSingleton();
441 	return AudioServerSingleton(AudioServerSingleton._classBinding._singleton);
442 }