Creates an instance of the Playback class.
Protected Optional_Optional_Optional_Optional_Per-playback send-gain allocations owned by the shared routing state machine. Cleanup disconnects every allocation deterministically.
Protected_OptionalgainOptionalpannerReadonlypanRequested position target; initial poses are immediate, subsequent writes use spatialSmoothingTau.
OptionalsourceSpatial exponential time constant in seconds (default 0). Setting 0 snaps pending targets.
Internal
Smooth only while a voice can be heard or resumed. Unplayed and stopped voices take poses immediately, so a replayed voice starts at its requested pose.
Current source position in seconds. Playing HTML media reports its observed cursor, including buffering stalls and native loop wraps. Buffer playback follows the render clock; idle and paused voices retain their committed offset.
Checks if the audio is currently playing.
The last requested normalized occlusion amount, initially 0 (clear direct path).
Gets the output node of this playback's audio graph. This is the final node in the internal chain before connection to destination. Use this to manually wire the playback into custom audio graphs.
The gain node that serves as the output of this playback.
The current pitch-shift factor (1 = no shift). See setPitchShift.
Gets the current playback rate of the audio.
Gets the current lifecycle state without changing playback.
Requested stereo pan target, including during smoothing.
Whether this live voice can enforce native buffer clip boundaries. HTML media cannot.
Panner configuration with requested position/orientation targets; omitted axes retain automation.
Internal
Materialize a source-level biquad recipe and retain filter API compatibility.
Internal
Source preplay path that preserves synchronous native-build failures.
Internal
Snap pending spatial transitions to their requested targets.
Internal
Preflight Sound broadcasts and play options before any mutation.
Internal
Validate a spatial write without changing the voice.
Build and splice an effect into this live playback's pre-panner chain.
Cancels any in-progress fade, emitting fadeCancel if a fade was active.
Cleans up resources used by the Playback instance. This method should be called when the audio is no longer needed to free up resources.
Creates a clone of the current Playback instance with optional overrides for certain properties. This method allows for the creation of a new Playback instance that shares the same audio context and source node but can have different settings such as loop count or pan type. The clone is connected to the origin Sound's primary route and registered with the Sound.
Configures a fade-out to be applied when the playback ends naturally (last loop iteration).
The fade-out duration in milliseconds.
Optionaltype: FadeType
The fade curve type. Defaults to "linear".
Connects this playback's output to an AudioNode or AudioParam. Follows the Web Audio API connection pattern.
The destination node (for chaining).
Disconnects this playback's output from a specific destination or from all destinations.
Optionaldestination: AudioParam | AudioNode
Optional specific destination to disconnect from. If omitted, disconnects from all destinations.
ProtectedemitProtectedemitProtectedemitFades in from silence to the current volume. Optionally stores config to re-trigger the fade on each loop iteration.
The fade duration in milliseconds.
Optionaltype: FadeType
The fade curve type. Defaults to "linear".
Optionaloptions: { perLoop?: boolean; startTime?: number }
Optional. Set perLoop: true to re-trigger fadeIn on each loop.
Resolves when the fade completes.
Optionaltype: FadeTypeFades the volume to a target value, emitting fadeStart and fadeEnd events.
Optionaloptions: { startTime?: number; startValue?: number }Handles the loop event when the audio ends. This method is bound to the 'onended' event of the audio source. It manages looping logic and restarts playback if necessary.
ProtectedmarkProtectedmarkProtectedmarkRemove event listener.
Register event listener.
Cleanup function
Starts playing the audio.
Optionaloptions: PlayOptionsReturns the instance of the Playback class for chaining.
Silently prepares an idle or paused voice at a finite offset in seconds. Buffers resolve immediately. Media elements wait for metadata, a seekable range containing the target, and completed seeking with current audio data. No play(), context resume, or autoplay primer is performed. State is retained. A later preparation, play, seek, stop, or cleanup rejects pending work with AbortError. Cancellation does not roll back a browser seek already requested. Live/unknown-duration media rejects with NotSupportedError; readiness timeout rejects with TimeoutError. Browser media seeking is not sample accurate.
Optionaloptions: { duration?: number; type?: FadeType }End this started buffer activation at an absolute AudioContext time. A deadline before a future onset prevents all onset audio. Past deadlines stop now. Rate changes do not move this render-clock deadline. A later call replaces it; pause, seek, source recreation, stop and cleanup revoke it. Downstream effect tails remain. Legacy numeric repeats and ended-time fade-outs cannot share this per-source deadline.
ProtectedsetConfigure a hard clip end and native loop points, in Sound-relative seconds. Configure while idle or paused. loop(0) ends at R; loop("infinite") wraps R to L. Numeric repeats and per-loop fades are unsupported with explicit bounds.
Renders obstruction for this voice independently of volume, fades, and positioning. The caller owns geometry, materials, and policy; Cacophony only renders the amount. Finite amounts clamp to [0, 1]; non-finite amounts throw RangeError. A dedicated pre-panner low-pass opens to Nyquist at 0 and closes logarithmically to 800 Hz at 1, with attenuation from 0 to -18 dB. Resetting to 0 is transparent. Nodes are allocated on the first nonzero amount and reused, including after reset.
0 for a clear path, 1 for maximum obstruction.
Linear transition duration in milliseconds, default 50; 0 applies immediately.
Sets the pitch-shift factor for this playback, resurrecting the dormant phase-vocoder worklet (Jean Laroche & Mark Dolson, "New Phase-Vocoder Techniques for Pitch-Shifting, Harmonizing and Other Exotic Effects", 1999 IEEE WASPAA — peak-based pitch shift with Identity Phase-Locking).
On first use (factor !== 1) the phase-vocoder AudioWorkletNode is built and
added as an ordinary entry at the tail of the pre-panner effect chain:
source → [filters] → phase vocoder → panner → gainNode. The factor is
forwarded to the node's pitchFactor AudioParam (1 = no shift, 2 = +1
octave, 0.5 = -1 octave).
Pitch multiplier (> 0).
Fades out then stops the playback.
The fade-out duration in milliseconds.
Optionaltype: FadeType
The fade curve type. Defaults to "linear".
Resolves when the fade completes and playback is stopped.
The base interface for any sound-producing entity, including individual sounds, groups, and playbacks. BaseSound