TECHNOLOGY

AudioBufferSourceNode: replay requires a new one-shot source node

In this article
THE QUICK TAKE

The Web Audio interface permits an AudioBuffer to be reused across playback sources, while the source node's start lifecycle is not restartable. Creating a new source for another play is therefore different from redownloading or redecoding the waveform. A source also has its own connection, scheduled start, stop and completion handling. Those per-play properties should not be stored as if they belonged permanently to the audio asset. The asset identity and the active playback instance answer.

An AudioBufferSourceNode is a one-shot playback source, even when its AudioBuffer contains an asset that the application wants to replay. A voice interface that keeps the source node as its reusable cache can fail on the next play request. Cache the decoded audio separately from the per-play source lifecycle.

The audio contract

The Web Audio interface permits an AudioBuffer to be reused across playback sources, while the source node’s start lifecycle is not restartable. Creating a new source for another play is therefore different from redownloading or redecoding the waveform. A source also has its own connection, scheduled start, stop and completion handling. Those per-play properties should not be stored as if they belonged permanently to the audio asset. The asset identity and the active playback instance answer different application questions.

Implementation details

Keep decoded buffers in an asset cache and create a source node for each intended play. Assign playback identity so stop and completion events affect the correct instance. Connect the node through the selected output graph and clean up per-play resources according to the lifecycle. If overlapping playback is forbidden, enforce that policy explicitly before starting a successor. Do not reuse an old source merely because its buffer property still refers to valid audio. Avoid reissuing model requests just to compensate for a client-side source-node lifecycle error.

A constructed validation case

Decode one controlled audio asset and play it repeatedly through newly created source nodes. Verify that decoding is not unnecessarily repeated and that stop events target the selected playback instance. Add the deliberately incorrect attempt to restart the same source as a negative case. Test rapid replay and cancellation so stale completion events cannot clear the state of a newer play. Acceptance requires reusable asset data with independent, correctly tracked source lifecycles, rather than one reusable source object whose behavior depends on whether it was previously started.

Operational limits

A decoded buffer cache has its own memory and privacy policy. Correct one-shot source handling does not justify retaining every generated conversation indefinitely. Keep asset retention, playback scheduling and model generation as distinct lifecycle decisions when designing a voice client’s replay feature.

Primary references

Webaudio Spec; Mdn Audio Source.

This is a proposed voice-system validation, not an executed Retrivium benchmark. Preserve the implementation version and unresolved outcomes; interface documentation does not establish the quality or timing of a deployed voice service.

CosyVoice2 streaming assembly: token offsets and vocoder tails prevent duplicate audio; StyleTTS2 long-form inference: previous style is explicit session state.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles