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

回眸只為那壹抹淺笑 提交于 2019-12-17 18:37:49

问题


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?


回答1:


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!




回答2:


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();


来源:https://stackoverflow.com/questions/31274895/changing-speed-of-audio-using-the-web-audio-api-without-changing-pitch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!