Advertisement
BrU32

JS Oscillator Web Audio API 2 Ch Mixer SRC

Nov 12th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 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 x1 = document.createElement("METER");
  7. x1.min=0.0;
  8. x1.max=1.0;
  9. x1.value=""+0.0;
  10. x1.id='x';
  11. document.body.appendChild(x1)
  12. document.refresh();
  13.  
  14. </script>
  15.  
  16. </body>
  17.  
  18. <button onclick="gainNode.gain.value=gainNode.gain.value-0.1;
  19. x1.value=gainNode.gain.value;
  20. gainNode.gain.value=x1.value;"><</button>
  21.  
  22. <button onclick="gainNode.gain.value=gainNode.gain.value+0.1;
  23. x1.value=gainNode.gain.value;
  24. gainNode.gain.value=x1.value;">></button>
  25.  
  26. <button onclick="gainNode.gain.value=0.0;
  27. x1.value=0.0;">0.0</button>
  28.  
  29. <button onclick="gainNode.gain.value=0.1;
  30. x1.value=0.1;">0.1</button>
  31.  
  32. <button onclick="gainNode.gain.value=0.2;
  33. x1.value=0.2;">0.2</button>
  34.  
  35. <button onclick="gainNode.gain.value=0.3;
  36. x1.value=0.3;">0.3</button>
  37.  
  38. <button onclick="gainNode.gain.value=0.4;
  39. x1.value=0.4;">0.4</button>
  40.  
  41. <button onclick="gainNode.gain.value=0.5;
  42. x1.value=0.5;">0.5</button>
  43.  
  44. <button onclick="gainNode.gain.value=0.6;
  45. x1.value=0.6;">0.6</button>
  46.  
  47. <button onclick="gainNode.gain.value=0.7;
  48. x1.value=0.7;">0.7</button>
  49.  
  50. <button onclick="gainNode.gain.value=0.8;
  51. x1.value=0.8;">0.8</button>
  52.  
  53. <button onclick="gainNode.gain.value=0.9;
  54. x1.value=0.9;">0.9</button>
  55.  
  56. <button onclick="gainNode.gain.value=1.0;
  57. x1.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>
  77. <body onload="testFunc()">Volume Control Via Audio API IN JS</body><p>
  78.  
  79. <script>
  80.  
  81. var i=0.6;
  82. var x = document.createElement("METER");
  83. x.min=0.0;
  84. x.max=1.0;
  85. x.value=""+0.0;
  86. x.id='x';
  87. document.body.appendChild(x)
  88. document.refresh();
  89.  
  90. </script>
  91.  
  92. </body>
  93.  
  94. <button onclick="gainNode.gain.value=gainNode.gain.value-0.1;
  95. x.value=gainNode.gain.value;
  96. gainNode.gain.value=x.value;"><</button>
  97.  
  98. <button onclick="gainNode.gain.value=gainNode.gain.value+0.1;
  99. x.value=gainNode.gain.value;
  100. gainNode.gain.value=x.value;">></button>
  101.  
  102. <button onclick="gainNode.gain.value=0.0;
  103. x.value=0.0;">0.0</button>
  104.  
  105. <button onclick="gainNode.gain.value=0.1;
  106. x.value=0.1;">0.1</button>
  107.  
  108. <button onclick="gainNode.gain.value=0.2;
  109. x.value=0.2;">0.2</button>
  110.  
  111. <button onclick="gainNode.gain.value=0.3;
  112. x.value=0.3;">0.3</button>
  113.  
  114. <button onclick="gainNode.gain.value=0.4;
  115. x.value=0.4;">0.4</button>
  116.  
  117. <button onclick="gainNode.gain.value=0.5;
  118. x.value=0.5;">0.5</button>
  119.  
  120. <button onclick="gainNode.gain.value=0.6;
  121. x.value=0.6;">0.6</button>
  122.  
  123. <button onclick="gainNode.gain.value=0.7;
  124. x.value=0.7;">0.7</button>
  125.  
  126. <button onclick="gainNode.gain.value=0.8;
  127. x.value=0.8;">0.8</button>
  128.  
  129. <button onclick="gainNode.gain.value=0.9;
  130. x.value=0.9;">0.9</button>
  131.  
  132. <button onclick="gainNode.gain.value=1.0;
  133. x.value=1.0;">1.0</button>
  134.  
  135. <script>
  136.  
  137. var audioCtx=new AudioContext();
  138. // var ctx=document.getElementById('audio');
  139. // ctx.type="mpeg"
  140. //ctx.src="test.mp3"
  141. // ctx.play();
  142. var oscillator = audioCtx.createOscillator();
  143. var oscillatorr = audioCtx.createOscillator();
  144. var gainNode = audioCtx.createGain();
  145. var gainNode1=audioCtx.createGain()p;
  146. oscillator.connect(gainNode);
  147. oscillatorr.connect(gainNode1);
  148. gainNode.connect(audioCtx.destination);
  149. gainNode1.connect(audioCtx.destination);
  150. var Outt=x.value;
  151. var Freq = ("1133330"+x.value);
  152. var Vol = "0.0";
  153. gainNode.gain.value=parseFloat(""+x1.value);
  154. gainNode1.gain.value=parseFloat(""+x.value);
  155.  
  156.  
  157. oscillator.type = 'sawtooth';
  158. oscillator.frequency.value = Freq;
  159. oscillator.frequency.value=Freq
  160. oscillator.start();
  161.  
  162. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement