Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>WebAudio example of biquad filter node</title>
</head>
<body>
  <audio src="https://mainline.i3s.unice.fr/mooc/drums.mp3" id="pannerPlayer" controls loop crossorigin="anonymous"></audio>
        <br>
        <label for="pannerSlider">Balance</label>
        <input type="range" min="-1" max="1" step="0.1" value="0" id="pannerSlider" />
</body>
</html>
 
// This line is a trick to initialize the AudioContext
// that will work on all recent browsers
var ctx = window.AudioContext || window.webkitAudioContext;
var audioContext;
var player, pannerSlider, pannerNode;
window.onload = function() {
  
   // get the AudioContext
   audioContext = new ctx();
    // the audio element
   playerPanner = document.querySelector('#pannerPlayer');
    playerPanner.onplay = (e) => {audioContext.resume();}
   pannerSlider = document.querySelector('#pannerSlider');
  buildAudioGraphPanner();
  
  // input listener on the gain slider
  pannerSlider.oninput = function(evt){
    pannerNode.pan.value = evt.target.value;
  }; 
};
function buildAudioGraphPanner() {
    // create source and gain node
    var source = audioContext.createMediaElementSource(playerPanner);
    pannerNode = audioContext.createStereoPanner();
  
    // connect nodes together
    source.connect(pannerNode);
    pannerNode.connect(audioContext.destination);
}
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
micbuffapro
0viewers