I have followed this tutorial and come up with that code:
context = new AudioContext();
play(frequency) {
const o = this.context.createOscillator();
const g = this.context.createGain();
o.connect(g);
g.connect(this.context.destination);
g.gain.exponentialRampToValueAtTime(
0.00001, this.context.currentTime + 1
);
o.frequency.value = frequency;
o.start(0);
}
This way I can play any notes from tutorial table by passing the values 1175
, 2794
, etc
I decided to create an array of notes and just called my play
function in the loop and it is just didn't work as all the notes just played at once with no delay.
How would you play the array of notes in a sequence?
I also was looking in to that article but still cant figure out how I can adapt my code above to that.