javascripthtmlhtml5-audiopitch-shifting

playbackRate on AUDIO and pitch


Little bit of background:
People like games.
People use the internet.
The internet needs games.
Games use sound.
HTML5 has <audio>.

Okay, all good so far.

Recently I discovered - to my surprise - that IE9 actually supports playbackRate. I eagerly gave it a try. Even more surprising, it actually worked. I tried the same in Chrome, and while it worked it was horribly grating when I set it to 0.5. I've already ditched Firefox because it doesn't support MP3.

Moving on, here's my question: both IE and Chrome apply pitch correction when changing the playbackRate. IE does a great job, Chrome does a horrible one. Either way, I don't want this, I want the sounds to change pitch. With that kind of power I can delete 650 files I had to procedurally generate to have an alternate pitch, and will have far more freedom with my projects. Heck, I could even make a MOD track player in HTML5 (minus the Effects channel) if I really wanted to.

So, is there anything in the HTML5 specification that allows me to turn pitch correction off, and just have the sound be played as if the samples had literally been stretched apart of squeezed together?


Solution

  • No, there's currenly nothing in the HTML5 specification that allows you such fine tuning with audio.

    But.

    Why do you care about "power" and "freedom with projects" when you're already limiting yourself by deciding to ditch Firefox? Incidentally Opera also doesn't support MP3.

    Unless of course it's a personal project where no-one but yourself will be using it and therefore it's a moot point. In which case if you want to target Chrome for example, you could check out the Web Audio API which might have something you want.