soundTrack.d.ts 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import type { Sound } from "./sound";
  2. import type { Analyser } from "./analyser";
  3. import type { Nullable } from "../types";
  4. import type { Scene } from "../scene";
  5. /**
  6. * Options allowed during the creation of a sound track.
  7. */
  8. export interface ISoundTrackOptions {
  9. /**
  10. * The volume the sound track should take during creation
  11. */
  12. volume?: number;
  13. /**
  14. * Define if the sound track is the main sound track of the scene
  15. */
  16. mainTrack?: boolean;
  17. }
  18. /**
  19. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  20. * It will be also used in a future release to apply effects on a specific track.
  21. * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#using-sound-tracks
  22. */
  23. export declare class SoundTrack {
  24. /**
  25. * The unique identifier of the sound track in the scene.
  26. */
  27. id: number;
  28. /**
  29. * The list of sounds included in the sound track.
  30. */
  31. soundCollection: Array<Sound>;
  32. private _outputAudioNode;
  33. private _scene;
  34. private _connectedAnalyser;
  35. private _options;
  36. private _isInitialized;
  37. /**
  38. * Creates a new sound track.
  39. * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#using-sound-tracks
  40. * @param scene Define the scene the sound track belongs to
  41. * @param options
  42. */
  43. constructor(scene?: Nullable<Scene>, options?: ISoundTrackOptions);
  44. private _initializeSoundTrackAudioGraph;
  45. /**
  46. * Release the sound track and its associated resources
  47. */
  48. dispose(): void;
  49. /**
  50. * Adds a sound to this sound track
  51. * @param sound define the sound to add
  52. * @ignoreNaming
  53. */
  54. addSound(sound: Sound): void;
  55. /**
  56. * Removes a sound to this sound track
  57. * @param sound define the sound to remove
  58. * @ignoreNaming
  59. */
  60. removeSound(sound: Sound): void;
  61. /**
  62. * Set a global volume for the full sound track.
  63. * @param newVolume Define the new volume of the sound track
  64. */
  65. setVolume(newVolume: number): void;
  66. /**
  67. * Switch the panning model to HRTF:
  68. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  69. * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
  70. */
  71. switchPanningModelToHRTF(): void;
  72. /**
  73. * Switch the panning model to Equal Power:
  74. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  75. * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#creating-a-spatial-3d-sound
  76. */
  77. switchPanningModelToEqualPower(): void;
  78. /**
  79. * Connect the sound track to an audio analyser allowing some amazing
  80. * synchronization between the sounds/music and your visualization (VuMeter for instance).
  81. * @see https://doc.babylonjs.com/features/featuresDeepDive/audio/playingSoundsMusic#using-the-analyser
  82. * @param analyser The analyser to connect to the engine
  83. */
  84. connectToAnalyser(analyser: Analyser): void;
  85. }