fix: apply detune transpose before stretch processing and when detune returns to zero#1100
Merged
mdydek merged 2 commits intoJun 11, 2026
Merged
Conversation
… returns to zero In processWithPitchCorrection, setTransposeSemitones was called after stretch_->process() and only when detune != 0. As a result: - a freshly created source with detune set played its first render quantum untransposed, an audible pitch glitch on every play/seek while detuned, since each start() goes through a new source - when detune went back to 0 the previous transpose was never cleared, so the source kept playing transposed Set the transpose unconditionally before processing instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
|
thank you for the contribution |
mdydek
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
None.
Introduced changes
In
AudioBufferBaseSourceNode::processWithPitchCorrection,stretch_->setTransposeSemitones(detune)is called afterstretch_->process()and only whendetune != 0. This causes two audible bugs on pitch-corrected sources:First render quantum plays untransposed. A freshly created source with
detunealready set renders its first quantum before the transpose is ever applied to the stretcher. Since everystart()/seek goes through a new source node, this produces an audible pitch glitch at the original pitch on every play/seek while detuned. Easy to hear with sustained tonal material (e.g. several stems playing pitch-shifted: each seek briefly "dips" to the original key).Stale transpose when detune returns to 0. Because the setter is guarded by
detune != 0.0f, once the param goes back to zero the previously set transpose is never cleared — the source keeps playing transposed even thoughdetuneis 0.Fix: set the transpose unconditionally and before
stretch_->process()so the stretcher always processes with the current detune value.setTransposeSemitonesis cheap (it just updates the frequency multiplier), so calling it every quantum is fine.We've been shipping this change as a
patch-packagepatch in a production audio app (multi-stem playback with real-time pitch shifting) since 0.10.x and it eliminates both glitches.Checklist
🤖 Generated with Claude Code