Advertisement
BrU32

JS Canvas Web Audio API AUS DD Instrument Sample SRC

Nov 12th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. <button onclick="InstrumFx1();">FX</button>
  2. <script>
  3. function InstrumFx1(){
  4. var i=0;
  5. for(var i=0;i<5;i++){
  6. var audioCtx=new AudioContext();
  7. var oscillator = audioCtx.createOscillator();
  8. var gainNode = audioCtx.createGain();
  9. oscillator.connect(gainNode);
  10. gainNode.gain.value=0;
  11. gainNode.connect(audioCtx.destination);
  12. oscillator.type='2';
  13. oscillator.frequency.value=85+i;
  14. oscillator.start(i);
  15. if (gainNode.gain.value==1){
  16. gainNode.gain.value=0;
  17. }else{
  18. gainNode.gain.value=1;
  19. }
  20. gainNode.gain.value=i;
  21. }
  22. }
  23. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement