Advertisement
BrU32

JS Web Audio API SRC V3 FINAL!!!!!

Jul 23rd, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. <body onload="testFunc()">Volume Control Via Audio API IN JS</body><p>
  2.  
  3. <script>
  4.  
  5. var i=0.6;
  6. var x = document.createElement("METER");
  7. x.min=0.0;
  8. x.max=1.0;
  9. x.value=""+0.0;
  10. x.id='x';
  11. document.body.appendChild(x)
  12. document.refresh();
  13.  
  14. </script>
  15.  
  16. </body>
  17.  
  18. <button onclick="gainNode.gain.value=gainNode.gain.value-0.1;
  19. x.value=gainNode.gain.value;
  20. gainNode.gain.value=x.value;"><</button>
  21.  
  22. <button onclick="gainNode.gain.value=gainNode.gain.value+0.1;
  23. x.value=gainNode.gain.value;
  24. gainNode.gain.value=x.value;">></button>
  25.  
  26. <button onclick="gainNode.gain.value=0.0;
  27. x.value=0.0;">0.0</button>
  28.  
  29. <button onclick="gainNode.gain.value=0.1;
  30. x.value=0.1;">0.1</button>
  31.  
  32. <button onclick="gainNode.gain.value=0.2;
  33. x.value=0.2;">0.2</button>
  34.  
  35. <button onclick="gainNode.gain.value=0.3;
  36. x.value=0.3;">0.3</button>
  37.  
  38. <button onclick="gainNode.gain.value=0.4;
  39. x.value=0.4;">0.4</button>
  40.  
  41. <button onclick="gainNode.gain.value=0.5;
  42. x.value=0.5;">0.5</button>
  43.  
  44. <button onclick="gainNode.gain.value=0.6;
  45. x.value=0.6;">0.6</button>
  46.  
  47. <button onclick="gainNode.gain.value=0.7;
  48. x.value=0.7;">0.7</button>
  49.  
  50. <button onclick="gainNode.gain.value=0.8;
  51. x.value=0.8;">0.8</button>
  52.  
  53. <button onclick="gainNode.gain.value=0.9;
  54. x.value=0.9;">0.9</button>
  55.  
  56. <button onclick="gainNode.gain.value=1.0;
  57. x.value=1.0;">1.0</button>
  58.  
  59. <script>
  60.  
  61. var audioCtx=new AudioContext();
  62. var oscillator = audioCtx.createOscillator();
  63. var oscillatorr = audioCtx.createOscillator();
  64. var gainNode = audioCtx.createGain();
  65. oscillator.connect(gainNode);
  66. gainNode.connect(audioCtx.destination);
  67. var Outt=x.value;
  68. var Freq = ("1.0"+x.value);
  69. var Vol = "0.0";
  70. gainNode.gain.value=parseFloat(""+x.value);
  71. oscillator.type = 'sawtooth';
  72. oscillator.frequency.value = Freq;
  73. oscillator.frequency.value=Freq
  74. oscillator.start();
  75.  
  76. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement