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

TypeError (iOS) #37

Closed mulhoon closed 9 years ago

mulhoon commented 9 years ago

Great script! I'm really enjoying using it. Thanks for the great work.

I've come across an error on iOS

465: TypeError: undefined is not a function (evaluating 'b.createStereoPanner()')

But it works fine if I use the wad.js version from the demo... http://www.codecur.io/javascripts/wad.js

Thanks Nic

rserota commented 9 years ago

The latest version of wad.js uses 3d panning if you specify panning with an array, or it will use stereo panning if you specify panning as a single float (from -1 to 1). However, stereo panning was added to the web audio API fairly recently, so if the web audio implementation in iOS safari is not up to date (or your particular version of safari is not up to date) then using stereo panning will cause problems. The version of wad.js used in the demo is pretty old, so it will try to use 3d panning always, even if you only pass a single float.

You may just want to use 3d panning if stereo panning won't work at all, e.g. specify panned-left as [-5, 0, 5], and panned-right as [5, 0, 5].

I hope that helps? Thanks for using wad.js, and especially thanks for testing it out on iOS. The feedback is useful.

notthetup commented 9 years ago

I might be worthwhile to have a fallback for the stereoPanner to use the 3D panner if it's not available in the implementation.

For eg. : https://github.com/Sonoport/soundmodels/blob/master/src/lib/effects/Panner.js#L27

mulhoon commented 9 years ago

Ok, I solved it by specifying panning as [0, 0, 0] as I don't require panning at the moment. I'm not too sure how these numbers work. Are they X, Y and Z?

rserota commented 9 years ago

@mulhoon That's right, the numbers are X, Y, and Z. The numbers are all relative to the audio listener, which is at [0, 0, 0]. It still throws an error even without setting panning? That's no good.

@notthetup yes, this situation needs to be handled more gracefully. Thanks for sharing that link.

rserota commented 9 years ago

Wad.js will now automatically fallback to using 3d panning when stereo panning is unavailable. It'll also log a message to the console explaining that stereo panning is unavailable.