rserota / wad

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

Safari throwing an error on wad play due to missing detune property in soundSource #80

Closed precociousmouse closed 6 years ago

precociousmouse commented 6 years ago

Hey there, am having an issue with safari and safari on iOS. When the code runs, it throws an error:

TypeError: undefined is not an object (evaluating 'this.soundSource.detune.value = arg.detune || this.detune')

on line 692 of wad.js. After a quick check of logging 'this' just before the error line I discovered that in chrome, soundSource contains a detune parameter, but in safari soundSource doesn't contain it.

Any thoughts of a workaround for this issue?

rserota commented 6 years ago

Is this issue happening only in safari? Have you tested your code in other browsers?

Also, can you post a minimal example of some code that reproduces the issue you're having?

precociousmouse commented 6 years ago

Hey there, I only really need it to work in chrome and safari (across android and iOS also). Chrome on desktop and android work fine, safari on desktop throws the error (symptoms are the same on iOS so I think it's the same issue).

I have attached a zip with a stripped down version of the code, and a screenshot of the console logging what the issue is (including the soundSource object logged from wad.js and showing the properties)

wad_error.zip

rserota commented 6 years ago

Your code looks reasonable. After a little research, it seems like safari just doesn't support detune, which would cause problems for you even if you aren't using detune in your own code. I should be able to create a fix for this when I get a few minutes.

precociousmouse commented 6 years ago

great, glad it wasn't me ;)

rserota commented 6 years ago

So, it seems that Safari DOES support detune, but only for oscillators, not audio clips. Chrome will support detune in both cases. Anyway, if you pull down version 2.7.2, Wad.js should now just silently ignore detune when it's not available, instead of crashing. Thanks for raising this issue.