1 /** 2 Plays 3D sound in 3D space. 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.audiostreamplayer3d; 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.spatial; 24 import godot.audiostream; 25 import godot.node; 26 /** 27 Plays 3D sound in 3D space. 28 29 Plays a sound effect with directed sound effects, dampens with distance if needed, generates effect of hearable position in space. 30 */ 31 @GodotBaseClass struct AudioStreamPlayer3D 32 { 33 enum string _GODOT_internal_name = "AudioStreamPlayer3D"; 34 public: 35 @nogc nothrow: 36 union { godot_object _godot_object; Spatial _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct _classBinding 41 { 42 __gshared: 43 @GodotName("set_stream") GodotMethod!(void, AudioStream) setStream; 44 @GodotName("get_stream") GodotMethod!(AudioStream) getStream; 45 @GodotName("set_unit_db") GodotMethod!(void, double) setUnitDb; 46 @GodotName("get_unit_db") GodotMethod!(double) getUnitDb; 47 @GodotName("set_unit_size") GodotMethod!(void, double) setUnitSize; 48 @GodotName("get_unit_size") GodotMethod!(double) getUnitSize; 49 @GodotName("set_max_db") GodotMethod!(void, double) setMaxDb; 50 @GodotName("get_max_db") GodotMethod!(double) getMaxDb; 51 @GodotName("set_pitch_scale") GodotMethod!(void, double) setPitchScale; 52 @GodotName("get_pitch_scale") GodotMethod!(double) getPitchScale; 53 @GodotName("play") GodotMethod!(void, double) play; 54 @GodotName("seek") GodotMethod!(void, double) seek; 55 @GodotName("stop") GodotMethod!(void) stop; 56 @GodotName("is_playing") GodotMethod!(bool) isPlaying; 57 @GodotName("get_playback_position") GodotMethod!(double) getPlaybackPosition; 58 @GodotName("set_bus") GodotMethod!(void, String) setBus; 59 @GodotName("get_bus") GodotMethod!(String) getBus; 60 @GodotName("set_autoplay") GodotMethod!(void, bool) setAutoplay; 61 @GodotName("is_autoplay_enabled") GodotMethod!(bool) isAutoplayEnabled; 62 @GodotName("_set_playing") GodotMethod!(void, bool) _setPlaying; 63 @GodotName("_is_active") GodotMethod!(bool) _isActive; 64 @GodotName("set_max_distance") GodotMethod!(void, double) setMaxDistance; 65 @GodotName("get_max_distance") GodotMethod!(double) getMaxDistance; 66 @GodotName("set_area_mask") GodotMethod!(void, long) setAreaMask; 67 @GodotName("get_area_mask") GodotMethod!(long) getAreaMask; 68 @GodotName("set_emission_angle") GodotMethod!(void, double) setEmissionAngle; 69 @GodotName("get_emission_angle") GodotMethod!(double) getEmissionAngle; 70 @GodotName("set_emission_angle_enabled") GodotMethod!(void, bool) setEmissionAngleEnabled; 71 @GodotName("is_emission_angle_enabled") GodotMethod!(bool) isEmissionAngleEnabled; 72 @GodotName("set_emission_angle_filter_attenuation_db") GodotMethod!(void, double) setEmissionAngleFilterAttenuationDb; 73 @GodotName("get_emission_angle_filter_attenuation_db") GodotMethod!(double) getEmissionAngleFilterAttenuationDb; 74 @GodotName("set_attenuation_filter_cutoff_hz") GodotMethod!(void, double) setAttenuationFilterCutoffHz; 75 @GodotName("get_attenuation_filter_cutoff_hz") GodotMethod!(double) getAttenuationFilterCutoffHz; 76 @GodotName("set_attenuation_filter_db") GodotMethod!(void, double) setAttenuationFilterDb; 77 @GodotName("get_attenuation_filter_db") GodotMethod!(double) getAttenuationFilterDb; 78 @GodotName("set_attenuation_model") GodotMethod!(void, long) setAttenuationModel; 79 @GodotName("get_attenuation_model") GodotMethod!(AudioStreamPlayer3D.AttenuationModel) getAttenuationModel; 80 @GodotName("set_out_of_range_mode") GodotMethod!(void, long) setOutOfRangeMode; 81 @GodotName("get_out_of_range_mode") GodotMethod!(AudioStreamPlayer3D.OutOfRangeMode) getOutOfRangeMode; 82 @GodotName("set_doppler_tracking") GodotMethod!(void, long) setDopplerTracking; 83 @GodotName("get_doppler_tracking") GodotMethod!(AudioStreamPlayer3D.DopplerTracking) getDopplerTracking; 84 @GodotName("set_stream_paused") GodotMethod!(void, bool) setStreamPaused; 85 @GodotName("get_stream_paused") GodotMethod!(bool) getStreamPaused; 86 @GodotName("_bus_layout_changed") GodotMethod!(void) _busLayoutChanged; 87 } 88 bool opEquals(in AudioStreamPlayer3D other) const { return _godot_object.ptr is other._godot_object.ptr; } 89 AudioStreamPlayer3D opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 90 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 91 mixin baseCasts; 92 static AudioStreamPlayer3D _new() 93 { 94 static godot_class_constructor constructor; 95 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AudioStreamPlayer3D"); 96 if(constructor is null) return typeof(this).init; 97 return cast(AudioStreamPlayer3D)(constructor()); 98 } 99 @disable new(size_t s); 100 /// 101 enum AttenuationModel : int 102 { 103 /** 104 Linear dampening of loudness according to distance. 105 */ 106 attenuationInverseDistance = 0, 107 /** 108 Squared dampening of loudness according to distance. 109 */ 110 attenuationInverseSquareDistance = 1, 111 /** 112 Logarithmic dampening of loudness according to distance. 113 */ 114 attenuationLogarithmic = 2, 115 } 116 /// 117 enum OutOfRangeMode : int 118 { 119 /** 120 Mix this audio in, even when it's out of range. 121 */ 122 outOfRangeMix = 0, 123 /** 124 Pause this audio when it gets out of range. 125 */ 126 outOfRangePause = 1, 127 } 128 /// 129 enum DopplerTracking : int 130 { 131 /** 132 Disables doppler tracking. 133 */ 134 dopplerTrackingDisabled = 0, 135 /** 136 Executes doppler tracking in idle step. 137 */ 138 dopplerTrackingIdleStep = 1, 139 /** 140 Executes doppler tracking in physics step. 141 */ 142 dopplerTrackingPhysicsStep = 2, 143 } 144 /// 145 enum Constants : int 146 { 147 outOfRangeMix = 0, 148 dopplerTrackingDisabled = 0, 149 attenuationInverseDistance = 0, 150 dopplerTrackingIdleStep = 1, 151 outOfRangePause = 1, 152 attenuationInverseSquareDistance = 1, 153 attenuationLogarithmic = 2, 154 dopplerTrackingPhysicsStep = 2, 155 } 156 /** 157 158 */ 159 void setStream(AudioStream stream) 160 { 161 checkClassBinding!(typeof(this))(); 162 ptrcall!(void)(_classBinding.setStream, _godot_object, stream); 163 } 164 /** 165 166 */ 167 Ref!AudioStream getStream() const 168 { 169 checkClassBinding!(typeof(this))(); 170 return ptrcall!(AudioStream)(_classBinding.getStream, _godot_object); 171 } 172 /** 173 174 */ 175 void setUnitDb(in double unit_db) 176 { 177 checkClassBinding!(typeof(this))(); 178 ptrcall!(void)(_classBinding.setUnitDb, _godot_object, unit_db); 179 } 180 /** 181 182 */ 183 double getUnitDb() const 184 { 185 checkClassBinding!(typeof(this))(); 186 return ptrcall!(double)(_classBinding.getUnitDb, _godot_object); 187 } 188 /** 189 190 */ 191 void setUnitSize(in double unit_size) 192 { 193 checkClassBinding!(typeof(this))(); 194 ptrcall!(void)(_classBinding.setUnitSize, _godot_object, unit_size); 195 } 196 /** 197 198 */ 199 double getUnitSize() const 200 { 201 checkClassBinding!(typeof(this))(); 202 return ptrcall!(double)(_classBinding.getUnitSize, _godot_object); 203 } 204 /** 205 206 */ 207 void setMaxDb(in double max_db) 208 { 209 checkClassBinding!(typeof(this))(); 210 ptrcall!(void)(_classBinding.setMaxDb, _godot_object, max_db); 211 } 212 /** 213 214 */ 215 double getMaxDb() const 216 { 217 checkClassBinding!(typeof(this))(); 218 return ptrcall!(double)(_classBinding.getMaxDb, _godot_object); 219 } 220 /** 221 222 */ 223 void setPitchScale(in double pitch_scale) 224 { 225 checkClassBinding!(typeof(this))(); 226 ptrcall!(void)(_classBinding.setPitchScale, _godot_object, pitch_scale); 227 } 228 /** 229 230 */ 231 double getPitchScale() const 232 { 233 checkClassBinding!(typeof(this))(); 234 return ptrcall!(double)(_classBinding.getPitchScale, _godot_object); 235 } 236 /** 237 Plays the audio from the given position 'from_position', in seconds. 238 */ 239 void play(in double from_position = 0) 240 { 241 checkClassBinding!(typeof(this))(); 242 ptrcall!(void)(_classBinding.play, _godot_object, from_position); 243 } 244 /** 245 Sets the position from which audio will be played, in seconds. 246 */ 247 void seek(in double to_position) 248 { 249 checkClassBinding!(typeof(this))(); 250 ptrcall!(void)(_classBinding.seek, _godot_object, to_position); 251 } 252 /** 253 Stops the audio. 254 */ 255 void stop() 256 { 257 checkClassBinding!(typeof(this))(); 258 ptrcall!(void)(_classBinding.stop, _godot_object); 259 } 260 /** 261 262 */ 263 bool isPlaying() const 264 { 265 checkClassBinding!(typeof(this))(); 266 return ptrcall!(bool)(_classBinding.isPlaying, _godot_object); 267 } 268 /** 269 Returns the position in the $(D AudioStream). 270 */ 271 double getPlaybackPosition() 272 { 273 checkClassBinding!(typeof(this))(); 274 return ptrcall!(double)(_classBinding.getPlaybackPosition, _godot_object); 275 } 276 /** 277 278 */ 279 void setBus(StringArg0)(in StringArg0 bus) 280 { 281 checkClassBinding!(typeof(this))(); 282 ptrcall!(void)(_classBinding.setBus, _godot_object, bus); 283 } 284 /** 285 286 */ 287 String getBus() const 288 { 289 checkClassBinding!(typeof(this))(); 290 return ptrcall!(String)(_classBinding.getBus, _godot_object); 291 } 292 /** 293 294 */ 295 void setAutoplay(in bool enable) 296 { 297 checkClassBinding!(typeof(this))(); 298 ptrcall!(void)(_classBinding.setAutoplay, _godot_object, enable); 299 } 300 /** 301 302 */ 303 bool isAutoplayEnabled() 304 { 305 checkClassBinding!(typeof(this))(); 306 return ptrcall!(bool)(_classBinding.isAutoplayEnabled, _godot_object); 307 } 308 /** 309 310 */ 311 void _setPlaying(in bool enable) 312 { 313 Array _GODOT_args = Array.empty_array; 314 _GODOT_args.append(enable); 315 String _GODOT_method_name = String("_set_playing"); 316 this.callv(_GODOT_method_name, _GODOT_args); 317 } 318 /** 319 320 */ 321 bool _isActive() const 322 { 323 Array _GODOT_args = Array.empty_array; 324 String _GODOT_method_name = String("_is_active"); 325 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 326 } 327 /** 328 329 */ 330 void setMaxDistance(in double metres) 331 { 332 checkClassBinding!(typeof(this))(); 333 ptrcall!(void)(_classBinding.setMaxDistance, _godot_object, metres); 334 } 335 /** 336 337 */ 338 double getMaxDistance() const 339 { 340 checkClassBinding!(typeof(this))(); 341 return ptrcall!(double)(_classBinding.getMaxDistance, _godot_object); 342 } 343 /** 344 345 */ 346 void setAreaMask(in long mask) 347 { 348 checkClassBinding!(typeof(this))(); 349 ptrcall!(void)(_classBinding.setAreaMask, _godot_object, mask); 350 } 351 /** 352 353 */ 354 long getAreaMask() const 355 { 356 checkClassBinding!(typeof(this))(); 357 return ptrcall!(long)(_classBinding.getAreaMask, _godot_object); 358 } 359 /** 360 361 */ 362 void setEmissionAngle(in double degrees) 363 { 364 checkClassBinding!(typeof(this))(); 365 ptrcall!(void)(_classBinding.setEmissionAngle, _godot_object, degrees); 366 } 367 /** 368 369 */ 370 double getEmissionAngle() const 371 { 372 checkClassBinding!(typeof(this))(); 373 return ptrcall!(double)(_classBinding.getEmissionAngle, _godot_object); 374 } 375 /** 376 377 */ 378 void setEmissionAngleEnabled(in bool enabled) 379 { 380 checkClassBinding!(typeof(this))(); 381 ptrcall!(void)(_classBinding.setEmissionAngleEnabled, _godot_object, enabled); 382 } 383 /** 384 385 */ 386 bool isEmissionAngleEnabled() const 387 { 388 checkClassBinding!(typeof(this))(); 389 return ptrcall!(bool)(_classBinding.isEmissionAngleEnabled, _godot_object); 390 } 391 /** 392 393 */ 394 void setEmissionAngleFilterAttenuationDb(in double db) 395 { 396 checkClassBinding!(typeof(this))(); 397 ptrcall!(void)(_classBinding.setEmissionAngleFilterAttenuationDb, _godot_object, db); 398 } 399 /** 400 401 */ 402 double getEmissionAngleFilterAttenuationDb() const 403 { 404 checkClassBinding!(typeof(this))(); 405 return ptrcall!(double)(_classBinding.getEmissionAngleFilterAttenuationDb, _godot_object); 406 } 407 /** 408 409 */ 410 void setAttenuationFilterCutoffHz(in double degrees) 411 { 412 checkClassBinding!(typeof(this))(); 413 ptrcall!(void)(_classBinding.setAttenuationFilterCutoffHz, _godot_object, degrees); 414 } 415 /** 416 417 */ 418 double getAttenuationFilterCutoffHz() const 419 { 420 checkClassBinding!(typeof(this))(); 421 return ptrcall!(double)(_classBinding.getAttenuationFilterCutoffHz, _godot_object); 422 } 423 /** 424 425 */ 426 void setAttenuationFilterDb(in double db) 427 { 428 checkClassBinding!(typeof(this))(); 429 ptrcall!(void)(_classBinding.setAttenuationFilterDb, _godot_object, db); 430 } 431 /** 432 433 */ 434 double getAttenuationFilterDb() const 435 { 436 checkClassBinding!(typeof(this))(); 437 return ptrcall!(double)(_classBinding.getAttenuationFilterDb, _godot_object); 438 } 439 /** 440 441 */ 442 void setAttenuationModel(in long model) 443 { 444 checkClassBinding!(typeof(this))(); 445 ptrcall!(void)(_classBinding.setAttenuationModel, _godot_object, model); 446 } 447 /** 448 449 */ 450 AudioStreamPlayer3D.AttenuationModel getAttenuationModel() const 451 { 452 checkClassBinding!(typeof(this))(); 453 return ptrcall!(AudioStreamPlayer3D.AttenuationModel)(_classBinding.getAttenuationModel, _godot_object); 454 } 455 /** 456 457 */ 458 void setOutOfRangeMode(in long mode) 459 { 460 checkClassBinding!(typeof(this))(); 461 ptrcall!(void)(_classBinding.setOutOfRangeMode, _godot_object, mode); 462 } 463 /** 464 465 */ 466 AudioStreamPlayer3D.OutOfRangeMode getOutOfRangeMode() const 467 { 468 checkClassBinding!(typeof(this))(); 469 return ptrcall!(AudioStreamPlayer3D.OutOfRangeMode)(_classBinding.getOutOfRangeMode, _godot_object); 470 } 471 /** 472 473 */ 474 void setDopplerTracking(in long mode) 475 { 476 checkClassBinding!(typeof(this))(); 477 ptrcall!(void)(_classBinding.setDopplerTracking, _godot_object, mode); 478 } 479 /** 480 481 */ 482 AudioStreamPlayer3D.DopplerTracking getDopplerTracking() const 483 { 484 checkClassBinding!(typeof(this))(); 485 return ptrcall!(AudioStreamPlayer3D.DopplerTracking)(_classBinding.getDopplerTracking, _godot_object); 486 } 487 /** 488 489 */ 490 void setStreamPaused(in bool pause) 491 { 492 checkClassBinding!(typeof(this))(); 493 ptrcall!(void)(_classBinding.setStreamPaused, _godot_object, pause); 494 } 495 /** 496 497 */ 498 bool getStreamPaused() const 499 { 500 checkClassBinding!(typeof(this))(); 501 return ptrcall!(bool)(_classBinding.getStreamPaused, _godot_object); 502 } 503 /** 504 505 */ 506 void _busLayoutChanged() 507 { 508 Array _GODOT_args = Array.empty_array; 509 String _GODOT_method_name = String("_bus_layout_changed"); 510 this.callv(_GODOT_method_name, _GODOT_args); 511 } 512 /** 513 The $(D AudioStream) object to be played. 514 */ 515 @property AudioStream stream() 516 { 517 return getStream(); 518 } 519 /// ditto 520 @property void stream(AudioStream v) 521 { 522 setStream(v); 523 } 524 /** 525 Decides if audio should get quieter with distance linearly, quadratically or logarithmically. 526 */ 527 @property AudioStreamPlayer3D.AttenuationModel attenuationModel() 528 { 529 return getAttenuationModel(); 530 } 531 /// ditto 532 @property void attenuationModel(long v) 533 { 534 setAttenuationModel(v); 535 } 536 /** 537 Base sound level unaffected by dampening, in dB. 538 */ 539 @property double unitDb() 540 { 541 return getUnitDb(); 542 } 543 /// ditto 544 @property void unitDb(double v) 545 { 546 setUnitDb(v); 547 } 548 /** 549 Factor for the attenuation effect. 550 */ 551 @property double unitSize() 552 { 553 return getUnitSize(); 554 } 555 /// ditto 556 @property void unitSize(double v) 557 { 558 setUnitSize(v); 559 } 560 /** 561 Sets the absolute maximum of the soundlevel, in dB. 562 */ 563 @property double maxDb() 564 { 565 return getMaxDb(); 566 } 567 /// ditto 568 @property void maxDb(double v) 569 { 570 setMaxDb(v); 571 } 572 /** 573 Changes the pitch and the tempo of the audio. 574 */ 575 @property double pitchScale() 576 { 577 return getPitchScale(); 578 } 579 /// ditto 580 @property void pitchScale(double v) 581 { 582 setPitchScale(v); 583 } 584 /** 585 If `true`, audio is playing. 586 */ 587 @property bool playing() 588 { 589 return isPlaying(); 590 } 591 /// ditto 592 @property void playing(bool v) 593 { 594 _setPlaying(v); 595 } 596 /** 597 If `true` audio plays when added to scene tree. Default value: `false`. 598 */ 599 @property bool autoplay() 600 { 601 return isAutoplayEnabled(); 602 } 603 /// ditto 604 @property void autoplay(bool v) 605 { 606 setAutoplay(v); 607 } 608 /** 609 610 */ 611 @property bool streamPaused() 612 { 613 return getStreamPaused(); 614 } 615 /// ditto 616 @property void streamPaused(bool v) 617 { 618 setStreamPaused(v); 619 } 620 /** 621 Sets the distance from which the 'out_of_range_mode' takes effect. Has no effect if set to 0. 622 */ 623 @property double maxDistance() 624 { 625 return getMaxDistance(); 626 } 627 /// ditto 628 @property void maxDistance(double v) 629 { 630 setMaxDistance(v); 631 } 632 /** 633 Decides if audio should pause when source is outside of 'max_distance' range. 634 */ 635 @property AudioStreamPlayer3D.OutOfRangeMode outOfRangeMode() 636 { 637 return getOutOfRangeMode(); 638 } 639 /// ditto 640 @property void outOfRangeMode(long v) 641 { 642 setOutOfRangeMode(v); 643 } 644 /** 645 Bus on which this audio is playing. 646 */ 647 @property String bus() 648 { 649 return getBus(); 650 } 651 /// ditto 652 @property void bus(String v) 653 { 654 setBus(v); 655 } 656 /** 657 Areas in which this sound plays. 658 */ 659 @property long areaMask() 660 { 661 return getAreaMask(); 662 } 663 /// ditto 664 @property void areaMask(long v) 665 { 666 setAreaMask(v); 667 } 668 /** 669 If `true` the audio should be dampened according to the direction of the sound. 670 */ 671 @property bool emissionAngleEnabled() 672 { 673 return isEmissionAngleEnabled(); 674 } 675 /// ditto 676 @property void emissionAngleEnabled(bool v) 677 { 678 setEmissionAngleEnabled(v); 679 } 680 /** 681 The angle in which the audio reaches cameras undampened. 682 */ 683 @property double emissionAngleDegrees() 684 { 685 return getEmissionAngle(); 686 } 687 /// ditto 688 @property void emissionAngleDegrees(double v) 689 { 690 setEmissionAngle(v); 691 } 692 /** 693 dampens audio if camera is outside of 'emission_angle_degrees' and 'emission_angle_enabled' is set by this factor, in dB. 694 */ 695 @property double emissionAngleFilterAttenuationDb() 696 { 697 return getEmissionAngleFilterAttenuationDb(); 698 } 699 /// ditto 700 @property void emissionAngleFilterAttenuationDb(double v) 701 { 702 setEmissionAngleFilterAttenuationDb(v); 703 } 704 /** 705 Dampens audio above this frequency, in Hz. 706 */ 707 @property double attenuationFilterCutoffHz() 708 { 709 return getAttenuationFilterCutoffHz(); 710 } 711 /// ditto 712 @property void attenuationFilterCutoffHz(double v) 713 { 714 setAttenuationFilterCutoffHz(v); 715 } 716 /** 717 Amount how much the filter affects the loudness, in dB. 718 */ 719 @property double attenuationFilterDb() 720 { 721 return getAttenuationFilterDb(); 722 } 723 /// ditto 724 @property void attenuationFilterDb(double v) 725 { 726 setAttenuationFilterDb(v); 727 } 728 /** 729 Decides in which step the Doppler effect should be calculated. 730 */ 731 @property AudioStreamPlayer3D.DopplerTracking dopplerTracking() 732 { 733 return getDopplerTracking(); 734 } 735 /// ditto 736 @property void dopplerTracking(long v) 737 { 738 setDopplerTracking(v); 739 } 740 }