D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
FrankieFabuloso
Full window
Github gist
Play it again JavaScript
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>JS Bin</title> </head> <body> <button class='button1' onmousedown='noise(261.63)'onmouseup='silence()' >C</button> <button class='button2' onmousedown='noise(293.66)'onmouseup='silence()' >D</button> <button class='button1' onmousedown='noise(329.63)'onmouseup='silence()' >E</button> <button class='button2' onmousedown='noise(349.23)'onmouseup='silence()' >F</button> <button class='button1' onmousedown='noise(392.00)'onmouseup='silence()' >G</button> <button class='button1' onmousedown='noise(440.00)'onmouseup='silence()' >A</button> <button class='button2' onmousedown='noise(493.88)'onmouseup='silence()' >B</button> <script id="jsbin-javascript"> var AudioContext = window.AudioContext || window.webkitAudioContext; var audioCtx = new AudioContext(); var oscillator = audioCtx.createOscillator(); var gainNode = audioCtx.createGain(); var finish = audioCtx.destination; oscillator.type = 'square'; oscillator.start(); function noise(value){ oscillator.frequency.value = value; // value in hertz oscillator.connect(audioCtx.destination); } function silence(){ oscillator.disconnect(audioCtx.destination); } </script> <script id="jsbin-source-javascript" type="text/javascript">var AudioContext = window.AudioContext || window.webkitAudioContext; var audioCtx = new AudioContext(); var oscillator = audioCtx.createOscillator(); var gainNode = audioCtx.createGain(); var finish = audioCtx.destination; oscillator.type = 'square'; oscillator.start(); function noise(value){ oscillator.frequency.value = value; // value in hertz oscillator.connect(audioCtx.destination); } function silence(){ oscillator.disconnect(audioCtx.destination); } </script></body> </html>