Changing Speed of Audio Using the Web Audio API Without Changing Pitch

Is it possible to change the tempo of audio (in the form of loaded MP3 files) without changing the pitch using the Web Audio API?

I’m aware of the playbackRate property on the AudioBufferSourceNode, but that also changes pitch. I’m also aware of the playbackRate property for <audio> and <video> elements, but I need to use the Web Audio API.

I’m very new to the Web Audio API. Is there anything I can do?

There is a way to do this – its called granular synthesis (link points to a pd theory link, but the theory is universal). The idea of granular synthesis is that a sound is sampled at the original speed, but it is played at a different speed from each sample point, however with the advantage that the pitch is not altered.

These Github Web Audio Granular Synthesiser links may help you (the first one is better): 1. Web-Audio-Granular-synthesis
Another link on Github2

Failing any success with WebAudio, there is the alternative; bring the mp3 into Audacity and change the tempo that way, and then use the new file! 😉

Believe me, I understand your pain, I spent weeks in uni trying to do exactly the same thing with pd-extended. Came near to tearing my hair out. My professor introduced me to the concept of granular synthesis – saved the day!

Good luck!

That’s not natively (easily) supported by the current version of WebAudio, but it’s possible using Tone.js:

let semitones = 3;
let source = new Tone.Player(AudioBuffer);
let shift = new Tone.PitchShift(semitones);

There is now a property called playbackRate on the audio and video elements that do just this. I don’t need modify the audio data itself, just play it back more slowly – so this is perfect for my scenario.

var myAudio = document.createElement('audio');
myAudio.playbackRate = 0.5;

More Info:

Read More:   Is onclose always called after onerror for WebSocket

Live Example:,output

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Similar Posts