Pondering how to handle sound in a project I'm working on and hoping someone has some ideas, and that the discussion could possibly be usefull to someone else.
I imagine minib3d is going to some day duplicate the emitsound type functionality of Blitz3D but untill then some sort of 3d sound would be nice.
Blitz has handy functions for tweaking sound position such as setchannelpan and setchanneldepth. using those and some distance based volume calculations it shouldn't be all that hard to create a 3d sound system of sorts.
The problem I currently have is that to do that I need to find the distance along the x, y and z planes of the object from the camera, relative to the direction the camera is facing... if you're facing strait ahead and the object is just 10 points to the left it's easy enough, but if you turn 45 degrees right it is now behind and to the left... positionaly it's still -10 on the x axis and 0 on y and z, but you want the sound to come from more like -5 on x and -5 on z... and then when you add in the ability to pitch up and down...
If that still doesn't make sense (and it probably doesn't, sory I'm running on little sleep atm) create a camera, create a box. move the box -10 on the X axis. that's where the object actualy is relative to the camera... now, turn the camera 45 degrees, attach the box to the camera and turn the camera back... when facing 45 degrees right that is where the box should SOUND like it is, behind and to the left instead of straight left (i.e. I want that new x/y/z if the camera is 45 degrees right and the box is at -10 along x)...
Someone may have solved this problem already, or may have some crazy math skills (dare I call them skillz?) and can figure out this rotational conundrum, I'll be happy to share whatever I can come up with as a result.
I've got a 2d sound system I made for another game (very ugly but I'll clean it up) that uses this kind of concept, all I really need to do is add in the depth component (once I can find the coords of course) and it should be ready to share... it won't take the environment into account, so it wouldn't work very well for a FPS type game, but it should be very usable for anything "outside" where you don't have sound altering surfaces between you and a sound source.
The only way I've come up with (and I haven't tested this yet) is to create a pivot for the sound "emiter" and attach it to the camera. then update the pivot's global position to be the same as the actual item you want to have making a sound. then if you get the local coords of the pivot, they should be relative to the camera with it's rotation since that is the parent... I have no idea how fast/slow that would be or if there's just a mathmatical way I could more easily figure it out without having to move a bunch of pivots every frame to have them calc my positions for me... seems wastefull as they will move when you move the camera, then they'll move again when you correct their positon...
I imagine minib3d is going to some day duplicate the emitsound type functionality of Blitz3D but untill then some sort of 3d sound would be nice.
Blitz has handy functions for tweaking sound position such as setchannelpan and setchanneldepth. using those and some distance based volume calculations it shouldn't be all that hard to create a 3d sound system of sorts.
The problem I currently have is that to do that I need to find the distance along the x, y and z planes of the object from the camera, relative to the direction the camera is facing... if you're facing strait ahead and the object is just 10 points to the left it's easy enough, but if you turn 45 degrees right it is now behind and to the left... positionaly it's still -10 on the x axis and 0 on y and z, but you want the sound to come from more like -5 on x and -5 on z... and then when you add in the ability to pitch up and down...
If that still doesn't make sense (and it probably doesn't, sory I'm running on little sleep atm) create a camera, create a box. move the box -10 on the X axis. that's where the object actualy is relative to the camera... now, turn the camera 45 degrees, attach the box to the camera and turn the camera back... when facing 45 degrees right that is where the box should SOUND like it is, behind and to the left instead of straight left (i.e. I want that new x/y/z if the camera is 45 degrees right and the box is at -10 along x)...
Someone may have solved this problem already, or may have some crazy math skills (dare I call them skillz?) and can figure out this rotational conundrum, I'll be happy to share whatever I can come up with as a result.
I've got a 2d sound system I made for another game (very ugly but I'll clean it up) that uses this kind of concept, all I really need to do is add in the depth component (once I can find the coords of course) and it should be ready to share... it won't take the environment into account, so it wouldn't work very well for a FPS type game, but it should be very usable for anything "outside" where you don't have sound altering surfaces between you and a sound source.
The only way I've come up with (and I haven't tested this yet) is to create a pivot for the sound "emiter" and attach it to the camera. then update the pivot's global position to be the same as the actual item you want to have making a sound. then if you get the local coords of the pivot, they should be relative to the camera with it's rotation since that is the parent... I have no idea how fast/slow that would be or if there's just a mathmatical way I could more easily figure it out without having to move a bunch of pivots every frame to have them calc my positions for me... seems wastefull as they will move when you move the camera, then they'll move again when you correct their positon...