Description
Describe the feature
Basically the title - it would be nice to have an easy way to change the playback rate of a source node without affecting the pitch.
Is there a prototype?
Alas, I have no clue how to implement something like at this point.
Describe the feature in more detail
In my particular case, I'm working on a web app that needs synthesized audio alignment and preview. By itself it's very simple - there's no audio know-how involved at all. But users have requested an ability to change the playback rate so they could align and preview the audio data much quicker. Initially I tried simply changing sourceNode.playbackRate.value
- after all, changing the value of an attribute with the same name on <audio>
and <video>
works just fine. But as you can guess, it didn't produce the desired result.
There are also quite a few other instances when people ask for something like this:
- This issue that shows that at least some interest has been shown here for such functionality: Interdependence between playbackRate and detune #723
- A StackOverflow question with a decent amount of votes: Changing Speed of Audio Using the Web Audio API Without Changing Pitch (and even thought there are answers, they are quite far from being simple - especially when you have to work with thirdparty audio libraries that don't have that ability built into them)
- A request for MDN to provide an example of how it could be done: How to preserve an audio's pitch after changing AudioBufferSourceNode.playbackRate? mdn/webaudio-examples#53
- An issue in an audio-related project that I'm using: Alter playback speed? naomiaro/waveform-playlist#19 (has been open for years because there's no easy way to do this)
- A Chromium bug with the WontFix resolution because "Changing this will require a change in the spec": Implement "preserve pitch" on Web Audio API when changing playbackRate
- A relevant Chrome Web Audio FAQ entry, albeit about the reverse problem: Can I change pitch without changing speed?
- A 6 year old issue in the old W3C bugtracker: Enable in WebAudio to change the tempo of audio without changing the pitch
One of those is from my own experience, the others are all from just the first page of a Google search. I'm sure I'd be able to find quite a few more if I spent more time on it.
Given that there already is such a functionality when it comes to playbackRate
of <audio>
and <video>
, I'd think that it shouldn't be that hard from the implementation perspective to add it to AudioBufferSourceNode
as well.