Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gkucmierz/4722566a0917ed205cc939549bda6065 to your computer and use it in GitHub Desktop.

Select an option

Save gkucmierz/4722566a0917ed205cc939549bda6065 to your computer and use it in GitHub Desktop.
// gold coin (krugerrand) oscilations generator
let context = new (window.AudioContext || window.webkitAudioContext)();
[4823, 10852, 18540].map(freq => {
let osc = context.createOscillator(); // instantiate an oscillator
osc.type = 'sine'; // this is the default - also square, sawtooth, triangle
osc.frequency.value = freq;
osc.connect(context.destination); // connect it to the destination
osc.start(); // start the oscillator
osc.stop(context.currentTime + 2); // stop 2 seconds after the current time
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment