babylon.sound.d.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. declare module BABYLON {
  2. class Sound {
  3. public maxDistance: number;
  4. public autoplay: boolean;
  5. public loop: boolean;
  6. public useBabylonJSAttenuation: boolean;
  7. public soundTrackId: number;
  8. private _position;
  9. private _localDirection;
  10. private _volume;
  11. private _isLoaded;
  12. private _isReadyToPlay;
  13. private _isPlaying;
  14. private _isDirectional;
  15. private _audioEngine;
  16. private _readyToPlayCallback;
  17. private _audioBuffer;
  18. private _soundSource;
  19. private _soundPanner;
  20. private _soundGain;
  21. private _coneInnerAngle;
  22. private _coneOuterAngle;
  23. private _coneOuterGain;
  24. private _scene;
  25. private _name;
  26. private _connectedMesh;
  27. /**
  28. * Create a sound and attach it to a scene
  29. * @param name Name of your sound
  30. * @param url Url to the sound to load async
  31. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  32. * @param options Objects to provide with the current available options: autoplay, loop, distanceMax
  33. */
  34. constructor(name: string, url: string, scene: Scene, readyToPlayCallback?: () => void, options?: any);
  35. public connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36. /**
  37. * Transform this sound into a directional source
  38. * @param coneInnerAngle Size of the inner cone in degree
  39. * @param coneOuterAngle Size of the outer cone in degree
  40. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41. */
  42. public setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43. public setPosition(newPosition: Vector3): void;
  44. public setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45. private _updateDirection();
  46. public updateDistanceFromListener(): void;
  47. /**
  48. * Play the sound
  49. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  50. */
  51. public play(time?: number): void;
  52. /**
  53. * Stop the sound
  54. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  55. */
  56. public stop(time?: number): void;
  57. public pause(): void;
  58. public setVolume(newVolume: number): void;
  59. public getVolume(): number;
  60. public attachToMesh(meshToConnectTo: AbstractMesh): void;
  61. private _onRegisterAfterWorldMatrixUpdate(connectedMesh);
  62. private _soundLoaded(audioData);
  63. }
  64. }