Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 591
JaredCubilla Avatar asked Jul 07 '15 16:07

JaredCubilla


People also ask

What is audio API setting?

The Web Audio API provides a powerful and versatile system for controlling audio on the Web, allowing developers to choose audio sources, add effects to audio, create audio visualizations, apply spatial effects (such as panning) and much more.


2 Answers

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 2. 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!

like image 199
Rachel Gallen Avatar answered Sep 26 '22 12:09

Rachel Gallen


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);
source.connect(shift);
shift.toMaster();
source.start();
like image 24
Jacob Avatar answered Sep 24 '22 12:09

Jacob