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 power" panner the programmer needs to do the formulaic programming to scale this ... or if I am over thinking it and there is a simpler way to do it.
EDIT
There is now a stereoPanner node being introduced.
here's an even simpler (less formulaic?) way to achieve 2D panning:
( full code here )
<input type="range" name="pan" id="pan" min="-1" max="1" step="any" />
<script>
var panner = context.createPanner();
panner.panningModel = 'equalpower';
function pan(event) {
var x = this.valueAsNumber,
y = 0,
z = 1 - Math.abs(x);
panner.setPosition(x,y,z);
}
document.getElementById('pan').addEventListener(pan);
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With