Indie dev efficiency4 min read

Web Audio detune Changes Sound Length? Check the Combined Rate

Convert cents into a rate multiplier and compare fixed playbackRate and detune settings before assuming pitch changes preserve duration.

Web Audio detune Changes Sound Length? Check the Combined Rate
Headphones with a waveform and a game audio file concept
AI-generated audio concept, not a measured spectrum or waveform.

Changing detune alters the pitch, but the sound also finishes sooner. Confirm that playback uses an AudioBufferSourceNode and log playbackRate, detune and loop state. A duration-preserving pitch feature in another audio component does not establish the behavior of this node.

Convert cents into a multiplier

The official reference describes detune in cents, with positive and negative 1200 cents corresponding to an octave up or down. The Web Audio specification defines the combined rate as playbackRate × 2^(detune / 1200). Here detune participates in playback speed. It is not a separate duration-preserving pitch processor.

Compare four constant settings

Reuse one decoded buffer with a fresh source node for each play. Disable looping and parameter automation. Compare (playbackRate=1, detune=0), (1,1200), (1,-1200) and (0.5,1200). Their calculated combined rates are 1, 2, 0.5 and 1. For full playback without an earlier stop, divide source duration by that rate to estimate output duration. These are parameter calculations, not browser measurements claimed by this article.

Keep source slicing separate

Record the start offset, source-content duration and audible duration independently. For a slice, the related diagnostic guide covers the source-time units of offset and duration. Automation or additional processors require measurements along the actual timeline rather than one constant-rate calculation. Use the SFX Generator to obtain candidate game sounds and confirm content, pitch and duration in the receiving player.

Recommended tools

Ready to try "Web Audio detune Changes Sound Length? Check the Combined Rate"?

Use our online tools to apply this tutorial to your indie game project right away.