Skip to content

Commit

Permalink
Fix identification of OscillatorNode objects in Safari v14+. Fixes al…
Browse files Browse the repository at this point in the history
  • Loading branch information
jlyman committed Oct 24, 2020
1 parent 688f4d5 commit 9cd8f88
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Pizzicato.Util = {
},

isOscillator: function(audioNode) {
return (audioNode && audioNode.toString() === "[object OscillatorNode]");
return (audioNode && (audioNode.toString() === "[object OscillatorNode]" || audioNode.toString() === "[object WebKitOscillatorNode]"));
},

isAudioBufferSourceNode: function(audioNode) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Sound.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('Sound', function() {
it('should create by default a sinewave sound with 440 frequency', function() {
var sound = new Pizzicato.Sound();

expect(toString.call(sound.getSourceNode())).toBe('[object OscillatorNode]');
expect(['[object OscillatorNode]', '[object WebKitOscillatorNode]']).toContain(toString.call(sound.getSourceNode()));
expect(sound.getSourceNode().frequency.value).toBe(440);
expect(sound.getSourceNode().type).toBe('sine');
});
Expand Down Expand Up @@ -79,7 +79,7 @@ describe('Sound', function() {

it('should create an oscillator node', function() {
var sound = new Pizzicato.Sound({ source: 'wave' });
expect(toString.call(sound.getSourceNode())).toBe('[object OscillatorNode]');
expect(['[object OscillatorNode]', '[object WebKitOscillatorNode]']).toContain(toString.call(sound.getSourceNode()));
});

it('should execute callback function', function(done) {
Expand Down

0 comments on commit 9cd8f88

Please sign in to comment.