Page 1 of 2

Position a sound in 3D Space?

Posted: Mon Oct 31, 2005 9:18 pm
by Straker
So far, I have yet to come across anything that meshes sound with OGRE. I have seen several demos but none with sound.

I cut my teeth on DARKBasic PRO which has a POSITION SOUND command (not to mention a POSITION LISTENER command) which allows extreme flexible and realistic sound positioning in 3D space.

I have searched these forums, PureArea.net, and the OGRE site, but can't seem to find anything like this.

Does anyone know of, or has crafted, such a command for PureBasic's OGRE Interface?

Thanks in advance.

Posted: Mon Oct 31, 2005 9:34 pm
by Brice Manuel
I don't think Ogre has sound capabilities, I thought it was just a rendering engine?

You would need to find a third-party sound engine (or directly access Direct Sound) since PB's sound functions do not support 3D sound.

Posted: Mon Oct 31, 2005 9:39 pm
by Straker
Thanks for the reply. Yes, that is what I figured. But I am sure I can't be the first person to hit this hurdle, which is why I am asking for existing solutions.

Thanks

Posted: Mon Oct 31, 2005 9:50 pm
by Brice Manuel
But I am sure I can't be the first person to hit this hurdle,
Possibly you are since the current implementation of Ogre is not really capable of making a complete game.

Your best bet would be OpenAL, you can find a wrapper lib here:
http://purearea.net/pb/download/userlibs/OpenAL.zip

I have no idea how good this lib is, but I have used OpenAL itself in commercial projects with no issues. http://www.openal.org/ Most PB libs are pretty good so you should be "ok".

Posted: Mon Oct 31, 2005 10:23 pm
by Straker
Thanks. checking that out now.

OGRE does appear to be used to create full games: http://www.ankh-game.de/

What about FMOD? Anyone have luck with that?

BTW - I am looking for a "pure" solution, i.e. cross-platform, preferable something not dependent on DX (like OpenAL)

Posted: Mon Oct 31, 2005 11:45 pm
by Brice Manuel
OGRE does appear to be used to create full games
That wasn't written in PB. I said "current implementation", as in what PB uses. The version PB uses is rather old and does not support all of the features of the current Ogre engine. Hopefully once 4.0 hits, Fred can dedicate some time to catching PB's 3D up. Ogre has progressed quite a bit from what we are stuck with in PB :?
What about FMOD? Anyone have luck with that?
FMOD is nice, but can be costly depending on what you are using it for. AFAIK there are not any full wrappers for PB, only partial wrappers.
BTW - I am looking for a "pure" solution, i.e. cross-platform, preferable something not dependent on DX (like OpenAL)
OpenAL works on Windows, Linux, Mac OS 8/9, Mac OS X, BSD, Solaris, IRIX, XBOX, XBOX 360. With the exception of Amiga (which is dead) OpenAL supports every platform PB does and then some. What other platforms are you wanting? PB only supports Windows, Mac & Linux.

Posted: Wed Nov 02, 2005 1:38 am
by kenmo
You could always program your own 3D sound system:

Calculate the Y angle between the sound and listener positions (which you have to store yourself)
Add this angle and the listener's angle
Pan the sound by the sine of the final angle
(If your game has free all-axis rotation, you have to work Z-rotation into this)

And for the sound volume,

Find the distance between the sound and listener
If the distance is greater than the sound's audible radius, mute it
If not, divide the distance by the radius and "invert" it (it = 1 - it)
Then set the sound's volume according to that 0>1 value.

My apologies if you already know all this and definitely want a sound library.

Posted: Wed Nov 02, 2005 10:04 am
by Froggerprogger
FMOD is a really cool and cross-platform (but possibly expensive, if your program isn't freeware).
With new fmod 4 you can even feed the audioengine with your polygon-world and position your sounds inside it. As many as you want. Further place a listener (the player) that is moving around in this world. fmod calculates and plays all (or an optimal maximal selection of) the sounds, that the listener hears inkl. obstruction/occlusion/doppler, etc.
I don't know, if there's any other audioengine giving you this comfort.
AFAIK there are not any full wrappers for PB, only partial wrappers.
Yes, the wrapper that let you call fmod-commands directly is not out now (due to a bug in pb). But you can access all the functionality using the OpenLibrary() and CallFunction()-commands.

Posted: Thu Nov 03, 2005 7:34 am
by Straker
Thanks for the feedback guys. Clearly my goal was not to re-invent the wheel here, but it seems like it has not yet even been invented. :cry:

FMOD seems to be the best choice, although $$$.

Thanks again everyone.

Posted: Fri Nov 04, 2005 4:42 am
by Rescator
Don't forget about BASS libary, it has more features than FMOD like recording as well as playback, DX8+ support, EAX, 3D and more.

I haven't compared prices, but BASS may be a bit cheaper.
http://www.un4seen.com/

Altough, PureBasic 4.x with OpenAL support would be great :P

Posted: Fri Nov 04, 2005 5:23 pm
by Froggerprogger
@Rescator
I don't want to start a flame, but already fmod 3 can do the things you mentioned.
fmod 4 can even do much, much more. Just take a look at www.fmod.org 'features' and especially their 'news' since fmod 4 at the startpage. I think fmod 4 is without concurrency at the moment.

Posted: Fri Nov 04, 2005 6:56 pm
by Straker
Thanks for the additional info. It doesn't appear that BASS works on Linux though.

Posted: Sat Nov 05, 2005 1:29 am
by Rescator
Yeah that's a shame, as I find BASS very easy. I did try FMOD some time back, but went with BASS as at the time FMOD did not support recording.

I see FMOD Ex finaly does though.
As to licenses, BASS is cheaper.
FMOD cost a bit more for commercial use,
and the license requirements are somewhat stricter than BASS.

The huge bonus point is that FMOD Ex seem very mature now.
And with it being on so many platforms and planned for PS3,
it's definetly worth a look for those that make commercial software or games
for multiple platforms. (i.e 1 sound API to focus on regardless of system)

BASS is similar to FMOD, while FMOD Ex seems to be the big boy in the street right now.

I'm curious about OpenAL though, anyone checked that out yet?
I'm especially curious about it's recording capabilities if any.

Posted: Wed Jan 18, 2006 2:55 am
by Rescator
I cut my teeth on DARKBasic PRO which has a POSITION SOUND command (not to mention a POSITION LISTENER command) which allows extreme flexible and realistic sound positioning in 3D space.
OpenAL has full 3D positioning and altough not directly tied to OpenGL
it is made in a very similar way (only for audio obviously).
OpenAL will automaticaly either use a soundcards native drivers directly,
or via a wrapper use the OS default hardware or software drivers,
so Win32 should be very well covered via OpenAL. /me petitions Fred to add OpenAL support in PB :P

And behold, OpenAL has recording as well it seems. Yay me, now to get this thing working!

If I'm able to use this not just for playback but recording as well,
I may actualy ditch BASS for some of my projects.
OpenAL.dll itself is only around 80KB.
The full redistributiuon install exe is just 350 KB or so and includes the hardware and software wrapper/fallback dll as well.

Obviously OpenAL is just a audio/sound API, and has no direct support for ogg or mp3 and so on.
But the cool thing is that it's open source, free, no royalties or licensing costs etc.
It supports (and let you choose as well it seems);
native OpenAL soundcard drivers (Creative and NVIDIA and others install these along with their cards)
DirectX hardware drivers (not quite as optimized as the soundcards native OpenAL drivers obviously)
DirectX software drivers (no hardware features available just software)

/rant

Posted: Wed Jan 18, 2006 6:12 am
by DarkDragon
http://www.bradan.net/downloads/OpenAL.zip

Haven't I posted this a few months before?