Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <body onload="testFunc()">Volume Control Via Audio API IN JS</body><p>
- <script>
- var i=0.6;
- var x = document.createElement("METER");
- x.min=0.0;
- x.max=1.0;
- x.value=""+0.0;
- x.id='x';
- document.body.appendChild(x)
- document.refresh();
- </script>
- </body>
- <button onclick="gainNode.gain.value=gainNode.gain.value-0.1;
- x.value=gainNode.gain.value;
- gainNode.gain.value=x.value;"><</button>
- <button onclick="gainNode.gain.value=gainNode.gain.value+0.1;
- x.value=gainNode.gain.value;
- gainNode.gain.value=x.value;">></button>
- <button onclick="gainNode.gain.value=0.0;
- x.value=0.0;">0.0</button>
- <button onclick="gainNode.gain.value=0.1;
- x.value=0.1;">0.1</button>
- <button onclick="gainNode.gain.value=0.2;
- x.value=0.2;">0.2</button>
- <button onclick="gainNode.gain.value=0.3;
- x.value=0.3;">0.3</button>
- <button onclick="gainNode.gain.value=0.4;
- x.value=0.4;">0.4</button>
- <button onclick="gainNode.gain.value=0.5;
- x.value=0.5;">0.5</button>
- <button onclick="gainNode.gain.value=0.6;
- x.value=0.6;">0.6</button>
- <button onclick="gainNode.gain.value=0.7;
- x.value=0.7;">0.7</button>
- <button onclick="gainNode.gain.value=0.8;
- x.value=0.8;">0.8</button>
- <button onclick="gainNode.gain.value=0.9;
- x.value=0.9;">0.9</button>
- <button onclick="gainNode.gain.value=1.0;
- x.value=1.0;">1.0</button>
- <script>
- var audioCtx=new AudioContext();
- var oscillator = audioCtx.createOscillator();
- var oscillatorr = audioCtx.createOscillator();
- var gainNode = audioCtx.createGain();
- oscillator.connect(gainNode);
- gainNode.connect(audioCtx.destination);
- var Outt=x.value;
- var Freq = ("1.0"+x.value);
- var Vol = "0.0";
- gainNode.gain.value=parseFloat(""+x.value);
- oscillator.type = 'sawtooth';
- oscillator.frequency.value = Freq;
- oscillator.frequency.value=Freq
- oscillator.start();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement