MarcTheSpark
MarcTheSpark

Reputation: 543

Does web audio oscillator type not work in Chrome, Firefox?

I seem to just get sine waves no matter what.

oscillator = context.createOscillator();
oscillator.type = 1;

I notice that this example I found online works on Safari, gives me just a sine wave on chrome, and doesn't work on firefox (maybe because it uses oscillator.noteOn instead of oscillator.start?):

http://middleearmedia.com/web-audio-api-oscillators/

Upvotes: 0

Views: 422

Answers (1)

cwilso
cwilso

Reputation: 13908

You need to use start(), and .type is a string type:

oscillator = context.createOscillator();
oscillator.type = "sawtooth";
oscillator.start(0);

See http://updates.html5rocks.com/2014/07/Web-Audio-Changes-in-m36.

Upvotes: 4

Related Questions