BrU32

JS Web Audio API Gain Volume SRC

Jul 18th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <script>
  2. var audioCtx=new AudioContext();
  3. var oscillator = audioCtx.createOscillator();
  4. var gainNode = audioCtx.createGain();
  5. oscillator.connect(gainNode);
  6. gainNode.connect(audioCtx.destination);
  7. var Outt=prompt('Enter Value (0.1 to 1.0:)');
  8. var WIDTH = window.innerWidth;
  9. var HEIGHT = window.innerHeight;
  10. var FreqMax = 200;
  11. var VolMax = 1.0;
  12. var Freq = 50;
  13. var Vol = Outt;
  14. gainNode.gain.value=parseFloat(Outt);
  15. oscillator.type = 'sawtooth';
  16. oscillator.frequency.value = Freq;oscillator.start();
  17. </script>
  18.  
  19. <button onclick="gainNode.gain.value=0.0;">0.0</button>
  20.  
  21. <button onclick="gainNode.gain.value=0.1;">0.1</button>
  22.  
  23. <button onclick="gainNode.gain.value=0.2;">0.2</button>
  24.  
  25. <button onclick="gainNode.gain.value=0.3;">0.3</button>
  26.  
  27. <button onclick="gainNode.gain.value=0.4;">0.4</button>
  28.  
  29. <button onclick="gainNode.gain.value=0.5;">0.5</button>
  30.  
  31. <button onclick="gainNode.gain.value=0.6;">0.6</button>
  32.  
  33. <button onclick="gainNode.gain.value=0.7;">0.7</button>
  34.  
  35. <button onclick="gainNode.gain.value=0.8;">0.8</button>
  36.  
  37. <button onclick="gainNode.gain.value=0.9;">0.9</button>
  38.  
  39. <button onclick="gainNode.gain.value=1.0;">1.0</button>
Advertisement
Add Comment
Please, Sign In to add comment