1 /**
2 Plays back audio.
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.audiostreamplayer;
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.classdb;
23 import godot.node;
24 import godot.audiostream;
25 /**
26 Plays back audio.
27 
28 Plays background audio.
29 */
30 @GodotBaseClass struct AudioStreamPlayer
31 {
32 	enum string _GODOT_internal_name = "AudioStreamPlayer";
33 public:
34 @nogc nothrow:
35 	union { godot_object _godot_object; Node _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct _classBinding
40 	{
41 		__gshared:
42 		@GodotName("set_stream") GodotMethod!(void, AudioStream) setStream;
43 		@GodotName("get_stream") GodotMethod!(AudioStream) getStream;
44 		@GodotName("set_volume_db") GodotMethod!(void, double) setVolumeDb;
45 		@GodotName("get_volume_db") GodotMethod!(double) getVolumeDb;
46 		@GodotName("set_pitch_scale") GodotMethod!(void, double) setPitchScale;
47 		@GodotName("get_pitch_scale") GodotMethod!(double) getPitchScale;
48 		@GodotName("play") GodotMethod!(void, double) play;
49 		@GodotName("seek") GodotMethod!(void, double) seek;
50 		@GodotName("stop") GodotMethod!(void) stop;
51 		@GodotName("is_playing") GodotMethod!(bool) isPlaying;
52 		@GodotName("get_playback_position") GodotMethod!(double) getPlaybackPosition;
53 		@GodotName("set_bus") GodotMethod!(void, String) setBus;
54 		@GodotName("get_bus") GodotMethod!(String) getBus;
55 		@GodotName("set_autoplay") GodotMethod!(void, bool) setAutoplay;
56 		@GodotName("is_autoplay_enabled") GodotMethod!(bool) isAutoplayEnabled;
57 		@GodotName("set_mix_target") GodotMethod!(void, long) setMixTarget;
58 		@GodotName("get_mix_target") GodotMethod!(AudioStreamPlayer.MixTarget) getMixTarget;
59 		@GodotName("_set_playing") GodotMethod!(void, bool) _setPlaying;
60 		@GodotName("_is_active") GodotMethod!(bool) _isActive;
61 		@GodotName("_bus_layout_changed") GodotMethod!(void) _busLayoutChanged;
62 		@GodotName("set_stream_paused") GodotMethod!(void, bool) setStreamPaused;
63 		@GodotName("get_stream_paused") GodotMethod!(bool) getStreamPaused;
64 	}
65 	bool opEquals(in AudioStreamPlayer other) const { return _godot_object.ptr is other._godot_object.ptr; }
66 	AudioStreamPlayer opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
67 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
68 	mixin baseCasts;
69 	static AudioStreamPlayer _new()
70 	{
71 		static godot_class_constructor constructor;
72 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AudioStreamPlayer");
73 		if(constructor is null) return typeof(this).init;
74 		return cast(AudioStreamPlayer)(constructor());
75 	}
76 	@disable new(size_t s);
77 	/// 
78 	enum MixTarget : int
79 	{
80 		/**
81 		The audio will be played only on the first channel.
82 		*/
83 		mixTargetStereo = 0,
84 		/**
85 		The audio will be played on all surround channels.
86 		*/
87 		mixTargetSurround = 1,
88 		/**
89 		The audio will be played on the second channel, which is usually the center.
90 		*/
91 		mixTargetCenter = 2,
92 	}
93 	/// 
94 	enum Constants : int
95 	{
96 		mixTargetStereo = 0,
97 		mixTargetSurround = 1,
98 		mixTargetCenter = 2,
99 	}
100 	/**
101 	
102 	*/
103 	void setStream(AudioStream stream)
104 	{
105 		checkClassBinding!(typeof(this))();
106 		ptrcall!(void)(_classBinding.setStream, _godot_object, stream);
107 	}
108 	/**
109 	
110 	*/
111 	Ref!AudioStream getStream() const
112 	{
113 		checkClassBinding!(typeof(this))();
114 		return ptrcall!(AudioStream)(_classBinding.getStream, _godot_object);
115 	}
116 	/**
117 	
118 	*/
119 	void setVolumeDb(in double volume_db)
120 	{
121 		checkClassBinding!(typeof(this))();
122 		ptrcall!(void)(_classBinding.setVolumeDb, _godot_object, volume_db);
123 	}
124 	/**
125 	
126 	*/
127 	double getVolumeDb() const
128 	{
129 		checkClassBinding!(typeof(this))();
130 		return ptrcall!(double)(_classBinding.getVolumeDb, _godot_object);
131 	}
132 	/**
133 	
134 	*/
135 	void setPitchScale(in double pitch_scale)
136 	{
137 		checkClassBinding!(typeof(this))();
138 		ptrcall!(void)(_classBinding.setPitchScale, _godot_object, pitch_scale);
139 	}
140 	/**
141 	
142 	*/
143 	double getPitchScale() const
144 	{
145 		checkClassBinding!(typeof(this))();
146 		return ptrcall!(double)(_classBinding.getPitchScale, _godot_object);
147 	}
148 	/**
149 	Plays the audio from the given position 'from_position', in seconds.
150 	*/
151 	void play(in double from_position = 0)
152 	{
153 		checkClassBinding!(typeof(this))();
154 		ptrcall!(void)(_classBinding.play, _godot_object, from_position);
155 	}
156 	/**
157 	Sets the position from which audio will be played, in seconds.
158 	*/
159 	void seek(in double to_position)
160 	{
161 		checkClassBinding!(typeof(this))();
162 		ptrcall!(void)(_classBinding.seek, _godot_object, to_position);
163 	}
164 	/**
165 	Stops the audio.
166 	*/
167 	void stop()
168 	{
169 		checkClassBinding!(typeof(this))();
170 		ptrcall!(void)(_classBinding.stop, _godot_object);
171 	}
172 	/**
173 	
174 	*/
175 	bool isPlaying() const
176 	{
177 		checkClassBinding!(typeof(this))();
178 		return ptrcall!(bool)(_classBinding.isPlaying, _godot_object);
179 	}
180 	/**
181 	Returns the position in the $(D AudioStream) in seconds.
182 	*/
183 	double getPlaybackPosition()
184 	{
185 		checkClassBinding!(typeof(this))();
186 		return ptrcall!(double)(_classBinding.getPlaybackPosition, _godot_object);
187 	}
188 	/**
189 	
190 	*/
191 	void setBus(StringArg0)(in StringArg0 bus)
192 	{
193 		checkClassBinding!(typeof(this))();
194 		ptrcall!(void)(_classBinding.setBus, _godot_object, bus);
195 	}
196 	/**
197 	
198 	*/
199 	String getBus() const
200 	{
201 		checkClassBinding!(typeof(this))();
202 		return ptrcall!(String)(_classBinding.getBus, _godot_object);
203 	}
204 	/**
205 	
206 	*/
207 	void setAutoplay(in bool enable)
208 	{
209 		checkClassBinding!(typeof(this))();
210 		ptrcall!(void)(_classBinding.setAutoplay, _godot_object, enable);
211 	}
212 	/**
213 	
214 	*/
215 	bool isAutoplayEnabled()
216 	{
217 		checkClassBinding!(typeof(this))();
218 		return ptrcall!(bool)(_classBinding.isAutoplayEnabled, _godot_object);
219 	}
220 	/**
221 	
222 	*/
223 	void setMixTarget(in long mix_target)
224 	{
225 		checkClassBinding!(typeof(this))();
226 		ptrcall!(void)(_classBinding.setMixTarget, _godot_object, mix_target);
227 	}
228 	/**
229 	
230 	*/
231 	AudioStreamPlayer.MixTarget getMixTarget() const
232 	{
233 		checkClassBinding!(typeof(this))();
234 		return ptrcall!(AudioStreamPlayer.MixTarget)(_classBinding.getMixTarget, _godot_object);
235 	}
236 	/**
237 	
238 	*/
239 	void _setPlaying(in bool enable)
240 	{
241 		Array _GODOT_args = Array.empty_array;
242 		_GODOT_args.append(enable);
243 		String _GODOT_method_name = String("_set_playing");
244 		this.callv(_GODOT_method_name, _GODOT_args);
245 	}
246 	/**
247 	
248 	*/
249 	bool _isActive() const
250 	{
251 		Array _GODOT_args = Array.empty_array;
252 		String _GODOT_method_name = String("_is_active");
253 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool);
254 	}
255 	/**
256 	
257 	*/
258 	void _busLayoutChanged()
259 	{
260 		Array _GODOT_args = Array.empty_array;
261 		String _GODOT_method_name = String("_bus_layout_changed");
262 		this.callv(_GODOT_method_name, _GODOT_args);
263 	}
264 	/**
265 	
266 	*/
267 	void setStreamPaused(in bool pause)
268 	{
269 		checkClassBinding!(typeof(this))();
270 		ptrcall!(void)(_classBinding.setStreamPaused, _godot_object, pause);
271 	}
272 	/**
273 	
274 	*/
275 	bool getStreamPaused() const
276 	{
277 		checkClassBinding!(typeof(this))();
278 		return ptrcall!(bool)(_classBinding.getStreamPaused, _godot_object);
279 	}
280 	/**
281 	The $(D AudioStream) object to be played.
282 	*/
283 	@property AudioStream stream()
284 	{
285 		return getStream();
286 	}
287 	/// ditto
288 	@property void stream(AudioStream v)
289 	{
290 		setStream(v);
291 	}
292 	/**
293 	Volume of sound, in dB.
294 	*/
295 	@property double volumeDb()
296 	{
297 		return getVolumeDb();
298 	}
299 	/// ditto
300 	@property void volumeDb(double v)
301 	{
302 		setVolumeDb(v);
303 	}
304 	/**
305 	Changes the pitch and the tempo of the audio.
306 	*/
307 	@property double pitchScale()
308 	{
309 		return getPitchScale();
310 	}
311 	/// ditto
312 	@property void pitchScale(double v)
313 	{
314 		setPitchScale(v);
315 	}
316 	/**
317 	If `true` audio is playing.
318 	*/
319 	@property bool playing()
320 	{
321 		return isPlaying();
322 	}
323 	/// ditto
324 	@property void playing(bool v)
325 	{
326 		_setPlaying(v);
327 	}
328 	/**
329 	If `true` audio plays when added to scene tree. Default value: `false`.
330 	*/
331 	@property bool autoplay()
332 	{
333 		return isAutoplayEnabled();
334 	}
335 	/// ditto
336 	@property void autoplay(bool v)
337 	{
338 		setAutoplay(v);
339 	}
340 	/**
341 	
342 	*/
343 	@property bool streamPaused()
344 	{
345 		return getStreamPaused();
346 	}
347 	/// ditto
348 	@property void streamPaused(bool v)
349 	{
350 		setStreamPaused(v);
351 	}
352 	/**
353 	If the audio configuration has more than two speakers, this sets the target channels. See `MIX_TARGET_*` constants.
354 	*/
355 	@property AudioStreamPlayer.MixTarget mixTarget()
356 	{
357 		return getMixTarget();
358 	}
359 	/// ditto
360 	@property void mixTarget(long v)
361 	{
362 		setMixTarget(v);
363 	}
364 	/**
365 	Bus on which this audio is playing.
366 	*/
367 	@property String bus()
368 	{
369 		return getBus();
370 	}
371 	/// ditto
372 	@property void bus(String v)
373 	{
374 		setBus(v);
375 	}
376 }