WebAudio question

Hi all,
I'm suspecting my googling hasn't worked more because I don't know what to google for, rather than because the information isn't out there, so feel free to tell me what to look for, rather than fixing my code.

So I've got a webaudio listener, and I'm trying to pan sounds around it. Using the formula from Aprone's panning tutorial, movement seems to work fine on the player side, but sounds pan strangely. When they should be behind me, they sound off to the left and right for example.

The code I've got is below. A couple of things I don't understand though, and probably should:
- What "format?" is the web audio listener position in? I've read the AudioListener position docs, but there doesn't seem to be anything as simple as a "degrees to position" formula.
- Should I be setting AudioListener.position*, or AudioListener.front*?

The code below - as you'll see - was copied from Stack Overflow. Honestly, I have no clue what I'm doing with these numbers. Once they're set, I'll just forget about it.

If I'm doing something terminally stupid by not understanding the values I'm manipulating, please feel free to direct me somewhere to educate myself. I'm not sure how useful the rest of trig (I don't even know how big the rest of trig is) would be to me, but if folks say I should know it, I'm more than happy to swat up.

// Code modified from
// https://developer.mozilla.org/en-US/docs/Web/API/PannerNode/orientationX
//
// convert degrees to radians and offset the angle so 0 points towards the listener
final double radians = (value - 90) * (pi / 180);
// using cosine and sine here ensures the output values are always normalised
// i.e. they range between -1 and 1
final double x = cos(radians);
final double z = sin(radians);
// we hard-code the Y component to 0, as Y is the axis of rotation
listener.forwardX.value = x;
listener.forwardY.value = 0;
listener.forwardZ.value = z;

Thanks so much in advance.



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector

Reply via email to