Advertisement
BrU32

JS Wobble Gen SRC Updated (More Randomness Edition!!)

Feb 24th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <center>
  2. <button>Start Synth</button>
  3. <script>
  4. var context = new AudioContext();
  5. var frequency;
  6. document.querySelector("button").addEventListener("click", GenRandomWobble);
  7. function GenRandomWobble() {
  8. var y=new Date().now
  9. frequency = Math.floor(Math.random() * 100)+10;
  10. var Osc1 = context.createOscillator();
  11. var Osc2 = context.createOscillator();
  12. Osc1.type = ""+Math.random()*4
  13. Osc1.frequency.value = frequency;
  14. Osc1.connect(context.destination);
  15. Osc2.type = ""+Math.random()*4;
  16. Osc2.detune.value = Math.random()*100;
  17. Osc2.connect(context.destination);
  18. var t=new Date().now;
  19. var Timer =Math.floor(Math.random()*t);
  20. Osc1.start(context.currentTime);
  21. Osc1.stop(context.currentTime + Timer);
  22. Osc2.start(context.currentTime);
  23. Osc2.start(context.currentTime);
  24. Osc2.stop(context.currentTime + Timer);
  25. alert('Frequency: '+frequency+ "\n\nSeconds Total: "+Timer);
  26. }
  27. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement