Search code examples
javascriptautomationweb-audio-api

WebAudio PannerNode Automation with LFO


Is there an easy way to connect an LFO directly to a panner node to automate x,y, or z? Like osc.connect(pannerNode.position.x)?

Or would it be better to just use a channelSplitter and handle left/right separately?Alternately I could input an LFO into a ScriptProcessorNode and then set the panner's x,y,z with the following, but wasn't sure if there was a better way:

function pan(range) {
  var xDeg = parseInt(range.value);
  var zDeg = xDeg + 90;
  if (zDeg > 90) {
    zDeg = 180 - zDeg;
  }
  var x = Math.sin(xDeg * (Math.PI / 180));
  var z = Math.sin(zDeg * (Math.PI / 180));
  p.setPosition(x, 0, z);
}

How to create very basic left/right equal power panning with createPanner();


Solution

  • No, I'm afraid there is not. I believe there's an open issue on this - that xyz should be audioparams.