Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari has issues with frequency get/set #146

Open
jlyman opened this issue Oct 22, 2020 · 2 comments · May be fixed by #147
Open

Safari has issues with frequency get/set #146

jlyman opened this issue Oct 22, 2020 · 2 comments · May be fixed by #147

Comments

@jlyman
Copy link

jlyman commented Oct 22, 2020

I've hit an issue where I can't change the frequency of a Sound after creating it in Safari. Works just fine in other browsers that I've tested so far (FF 79+ and Chrome 84+) but Safari v14 the following would result in null or no change in the sound:

const sound = new Pizzicato.Sound({
  source: "wave",
  options: {
    frequency: 400,
  },
});

console.log('Frequency: ', sound.frequency);
sound.frequency = 500;

I've created a fiddle to compare it amongst the different browsers: https://jsfiddle.net/7fgs8d0h/

As I've been writing this up it occurred to me that this may potentially be occurring on other properties like volume, though I haven't tested it.

Could I be missing something obvious here? Thanks in advance for any assistance!

@jlyman
Copy link
Author

jlyman commented Oct 24, 2020

Additional information: from testing on a few different devices, it looks like this may be due to a more recent change to Safari. The macOS Safari v14 and the mobile Safari on iOS 14.0.1 both exhibit this issue, but on an older iPad I have with iOS 12.4.8 doesn't have any issue with this. I'm going to look into the release notes to see if I can spot anything.

@jlyman
Copy link
Author

jlyman commented Oct 24, 2020

Ah okay, I believe I've found the issue. Looks like the name of the OscillatorNode in WebKit has been moved to a prefixed version, WebKitOscillatorNode. The issue for it notes the following:

Move non standard OscillatorNode API to new WebKitOscillatorNode interface, so that the unprefixed OscillatorNode is fully spec-compliant.

Now I'm not too familiar with the internals of the Web Audio API (okay, not familiar at all!) but in the Utils method that checks if something is an oscillator node, adding a check for the prefixed WebKit version seems to fix things for me. I'll put forward a PR with this change to see what others think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant