Only 1 listener?

Blitz3D Forums/Blitz3D Programming/Only 1 listener?

SLotman(Posted 2008) [#1]
I am making a game where I have two viewports, one for each player... but I can only create 1 sound listener?

I tried creating two, sometimes blitz complains about "sound listener already created" and sometimes it runs the program, but the sound appears to be heard only from 1 point.

Moving the position of the sound listener back and forth the position of player1 and player2 gives me a "cracking sound"...

Is there any way I can have more than 1 sound listener, or at least hear all my 3D sounds? Or is my project doomed for 2D sounds?

And please, no Bass or FMOD. I need a free solution, best if it doesnt involve any external lib...


GfK(Posted 2008) [#2]
Two lots of 3D sounds coming out of the same speakers is going to sound like a jumbled mess. How do you know which sounds belong to which viewport?

Its not hard to fake your own 3D sounds by manipulating the volume and panning of a sound channel. If you were desperate enough to want to do it.


Gabriel(Posted 2008) [#3]
I'm pretty sure FMod and Bass don't support multiple listeners anyway. As GFK says, it's kind of pointless. A better solution, I think is to maintain a single, static listener and then fake the position of your emitters so that the relative position from the listener matches that of the noise relative to the player you want to hear it. That way, both players hear their sounds in the correct relative positions. They're not going to care where their opponents sounds come from, but they are going to expect to hear them, so their expectations for that will be met too.


SLotman(Posted 2008) [#4]
The thing is: if a sound is close to any camera, I want it to play at normal volume, if itīs distant from both, should play lower, and if itīs far away from both, shouldnt play at all...

I thought that creating two sound listeners, that blitz would do this...

Manually setting the volume isnt a very good solution either, would be if there was only sounds that played once, but since players can have a "shield" which emits a constant sound... having to compute distance from every "sound" played every frame, and changing itīs volume according to distance isnt a very good option :P


SLotman(Posted 2008) [#5]
Gabriel:hmmmm, maybe that could be the solution... Iīll try to code it and see if it works, thanks!

The only thing Iīll have to figure out is how to actually fake the position, so both players can hear things... maybe getting the distance from the sound to the second player and emiting the sound a second time from the same distance from the listener...?


GfK(Posted 2008) [#6]
having to compute distance from every "sound" played every frame, and changing itīs volume according to distance isnt a very good option :P
...and how do you think 3D sounds work?


SLotman(Posted 2008) [#7]
...and how do you think 3D sounds work?

The same way, but at least some of it should be done in hardware... :P~

Anyway, the faking thing worked out nicely :)

I just computed the distance from the sound emitter to the 2nd player, and emited the sound with that distance from the listener :)


Nate the Great(Posted 2008) [#8]
you could make your own sound using the inverse square of the distance of each sound as the volume