Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <center>
- <button>Start Synth</button>
- <script>
- var context = new AudioContext();
- var frequency;
- document.querySelector("button").addEventListener("click", GenRandomWobble);
- function GenRandomWobble() {
- var y=new Date().now
- frequency = Math.floor(Math.random() * 100)+10;
- var Osc1 = context.createOscillator();
- var Osc2 = context.createOscillator();
- Osc1.type = ""+Math.random()*4
- Osc1.frequency.value = frequency;
- Osc1.connect(context.destination);
- Osc2.type = ""+Math.random()*4;
- Osc2.detune.value = Math.random()*100;
- Osc2.connect(context.destination);
- var t=new Date().now;
- var Timer =Math.floor(Math.random()*t);
- Osc1.start(context.currentTime);
- Osc1.stop(context.currentTime + Timer);
- Osc2.start(context.currentTime);
- Osc2.start(context.currentTime);
- Osc2.stop(context.currentTime + Timer);
- alert('Frequency: '+frequency+ "\n\nSeconds Total: "+Timer);
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement