weightedsound.d.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import type { Sound } from "../Audio/sound";
  2. /**
  3. * Wraps one or more Sound objects and selects one with random weight for playback.
  4. */
  5. export declare class WeightedSound {
  6. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7. loop: boolean;
  8. private _coneInnerAngle;
  9. private _coneOuterAngle;
  10. private _volume;
  11. /** A Sound is currently playing. */
  12. isPlaying: boolean;
  13. /** A Sound is currently paused. */
  14. isPaused: boolean;
  15. private _sounds;
  16. private _weights;
  17. private _currentIndex?;
  18. /**
  19. * Creates a new WeightedSound from the list of sounds given.
  20. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  21. * @param sounds Array of Sounds that will be selected from.
  22. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  23. */
  24. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  25. /**
  26. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  27. */
  28. get directionalConeInnerAngle(): number;
  29. /**
  30. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  31. */
  32. set directionalConeInnerAngle(value: number);
  33. /**
  34. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36. */
  37. get directionalConeOuterAngle(): number;
  38. /**
  39. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41. */
  42. set directionalConeOuterAngle(value: number);
  43. /**
  44. * Playback volume.
  45. */
  46. get volume(): number;
  47. /**
  48. * Playback volume.
  49. */
  50. set volume(value: number);
  51. private _onended;
  52. /**
  53. * Suspend playback
  54. */
  55. pause(): void;
  56. /**
  57. * Stop playback
  58. */
  59. stop(): void;
  60. /**
  61. * Start playback.
  62. * @param startOffset Position the clip head at a specific time in seconds.
  63. */
  64. play(startOffset?: number): void;
  65. }