WebAudio API: Change Pitch Of Samples (for Example Mp3)
I figured I can stretch a sample using playbackRate
but how do I set the pitch? Im trying to achieve this without using any libraries.
I found something about a doppler pitch effect in the specification but other than that I couldnt find anything truly relevant to my objective. Just a simple pitch shift, is this even possible? If so then how?
Edit: Could it be that playbackRate
changes the pitch as well but the browser applies some sort of correction? I think this might be the case. I have to disable it then if that is the case and possible.
Answer
There is no "simple" pitch shift for samples. There are lots of ways to change the pitch without changing the playback rate - granular resynthesis, phase-shift vocoding - but none of them are trivial, and none are baked into the Web Audio API. (Doppler is being removed, by the way, since it was pretty hacky.) playbackRate is literally the rate at which the samples will be run through - which will affect both "speed" and apparent pitch (of pitched samples).
I implemented a pitch-shifting (granular resynthesis) effect in the Input Effects demo - using the jungle.js library - but this isn't a trivial thing to do. HTML's <audio>
element does stretching, but doesn't specify the algorithm, which leaves it open to a lot of interpretations.
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM