-
Notifications
You must be signed in to change notification settings - Fork 0
/
joinradios.js
31 lines (26 loc) · 915 Bytes
/
joinradios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var source, swnl = document.createElement("input");
var ac = new AudioContext();
swnl.type = 'button';
swnl.addEventListener('click', onclc);
document.body.appendChild(document.createElement("br"));
document.body.appendChild(swnl);
function onclc(){
var audioElement = document.getElementById("mplayer");
audioElement.play();
source = ac.createMediaElementSource(audioElement);
console.log('source');
console.log(source);
//source.connect(ac.destination);
//var splitter = ac.createChannelSplitter(2);
//source.connect(splitter);
var merger = ac.createChannelMerger(2);
// Reduce the volume of the left channel only
var gain = ac.createGain();
gain.value = 0.1;
//splitter.connect(gain, 0);
source.connect(gain, 0);
gain.connect(merger, 0, 1);
source.connect(merger, 0, 0);
console.log("Start playing");
merger.connect(ac.destination);
}