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