rserota / wad

Web Audio DAW. Use the Web Audio API for dynamic sound synthesis. It's like jQuery for your ears.
MIT License
1.9k stars 160 forks source link

Dramatically improving audio on iOS #41

Closed mulhoon closed 9 years ago

mulhoon commented 9 years ago

Hi Raphael,

Following on from my discussion on #39 I've made a discovery. I noticed the audio on iOS using headphones is muffled compared to the same code on Macbook using headphone. I discovered if you add...

that.panning.node.panningModel = 'equalpower';

to the setUpPanningOnPlay function, it becomes crystal clear again and prevents distorting on the iPhone speaker. Whoopee!

See more here https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/panningModel

Hope this helps, Nic

rserota commented 9 years ago

This is a great find! Thanks for raising this issue.

It seems like the document you linked is slightly out of date, but I think the version of web audio in safari for iOS is also out of date, so this makes sense. On the latest version of Chrome, equalpower is the default panning model, but this is evidently not true in your case.

I've updated wad.js so that you can specify a panningModel argument on the constructor, or on play. If not set, it will default to 'equalpower'. This should help the panner behave more consistently across different devices/browsers.