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

前端 未结 3 1985
情歌与酒
情歌与酒 2020-12-09 13:54

I am looking at the web audio API spec and the panning node uses three values to create a 3D spectrum for sound. I was wondering if in order to create a basic 2D \"equal pow

3条回答
  •  Happy的楠姐
    2020-12-09 13:58

    I can still get a panning effect by changing only the first argument to setPosition() and keeping other arguments zero.

    
    
    
    
    
    
      Choose your MP3 file:


    LR

    But to get a natural panning effect, you need to specify the third argument as well.

    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);
    }
    

提交回复
热议问题