How do I add Sound? *Please help a noob

kinggori

07-02-2007 21:01:14

Thanks for the great work guys :D

I followed the OgreAL instructions and everything built without any errors.

Now I'm totally lost though, how do I add sound to my ogre game? Say for instance I want to add background music. Where/how would I add it?

Can someone please explain the steps required and help this noob out?

Thanks a bunch!

t0tAl_mElTd0wN

08-02-2007 00:06:23

I think at some point I'll post a tutorial on the Ogre Wiki about this, once I figure out the API more myself.

Look through this documentation as you read over this: http://www.mooproductions.org/ogreal/api/0.2/index.html

Everything should be created from a SoundManager. There is only ever one of these, and it should be treated as you treat Ogre::Root.

Now, you want to create a "listener". This will be treated just like any other Ogre scene object. Think of it as your camera's microphone, which will be piped into your speakers. Attach this listener to a node along with your camera. Now your camera has a built-in microphone, and you will hear (through your computer's speakers) whatever OgreAL::Sounds are playing nearby.

Next, to create a sound, you can do one of two things. Both of them will use your SoundManager to create the sounds. You can either play a sound file, or a sound streaming from a file. I'm not entirely sure what the difference is yet - I'll leave that to CaseyB to explain. Either way, your OgreAL::Sound will be created by using OgreAL::SoundManager::getSingletonPtr()->createSound(). Doxygen has those functions well documented, so the parameters should be pretty self explanatory.

Next, you'll want to attach (just like any other object) that newly created sound to an Ogre Node.

CaseyB, correct me if I'm wrong, but I believe that just by moving those nodes around, your sounds will sound like they're moving around as well.

But use that doxygen documentation a lot. It's not a super complex API, but it seems to do a good job.

CaseyB

08-02-2007 01:07:11

CaseyB, correct me if I'm wrong, but I believe that just by moving those nodes around, your sounds will sound like they're moving around as well.No need! That's exactly correct! :D The only thing that I could add is that you should check out the demos that come with it to see the process in a working example!

The only things returned from the SoundManager are Sounds whether you call SoundManager::createSound(), or SoundManager::createSoundStream, so once you create a sound you interact with it the same way no matter what. The distinction between Sounds and SoundStreams is hidden away in the SoundManager, but it goes like this: A Sound loads the entire file into memory at once while a SoundStream only loads small chunks in and swaps then with new chunks when it's done with the ones it has, hence the streaming. This is useful when you have long sound files, like background music or something so you don't eat up a lot of memory with just one file.

kinggori

08-02-2007 01:26:37

thanks for your reply guys

I will try following the instructions
the demos don't run :(

kinggori

08-02-2007 01:43:07

so here is how i tried running the demo:

i went to
OgreAL --> Demos --> Basic_Demo --> Basic_Demo.sln in VS05 -->F5

I get the pop up:
"The application has failed to start because OgraMain_d_dll was not found. Re-installing the application may fix this problem"

CaseyB

08-02-2007 02:43:52

Go to OgreAL->Demos->bin->{Debug|Release} and run the executable from there. The dll should be in there with the exe's.

kinggori

08-02-2007 02:49:11

I get the same error

looking at the folder there is a file called OgreAL_d.dll but there is no file called OgreMain_d.dll

derutydragon

08-02-2007 03:34:54

I'm getting an error almost identical to that in Codeblocks! Except its with OgreMain_d.lib ! Although how to help you with that I'm totally useless :D

CaseyB

08-02-2007 03:39:21

but there is no file called OgreMain_d.dllOH! Right, I should explain this in the getting set up tutorial! There is a resources.cfg file, in there too that you need to modify. There is a like that says"Path/to/your/ogrenew/samples/common/bin/{Release|Debug}You need to modify that to point to where the Ogre dll's are on your system! Sorry about not having that in the setup guide already!

kinggori

08-02-2007 03:47:32

thanks for your reply CaseyB

Here is my resources.cfg in OgreAL\Demos\bin\Debug

# Resource locations to be added to the default path
[General]
FileSystem=../../Media
FileSystem=../../Media/Audio
FileSystem=../../Media/Gui
FileSystem=../../Media/Materials/Scripts
FileSystem=../../Media/Materials/Textures
FileSystem=../../Media/Models
Zip=../../Media/Materials/Textures/cubemapsJS.zip
Zip=../../Media/Materials/bguires.zip


what should i add/change here?

CaseyB

08-02-2007 03:50:45

D'oh :oops: Plugins.cfg! Sorry!

kinggori

08-02-2007 03:55:33

Thanks for your reply CaseyB. I truly appreciate your help

On my computer the files are stored in
C:\mydev\OgreAL\Demos\bin\Debug
what would be the relatuve path in my case? or can i just add the full path?


Here is my Plugins.cfg:

# Defines plugins to load

# Define plugin folder
PluginFolder=Path/to/your/ogrenew/Samples/Common/bin/Debug

# Define plugins
Plugin=RenderSystem_Direct3D9
Plugin=RenderSystem_GL

CaseyB

08-02-2007 03:57:38

It would be the full path to the Ogre dlls like OgreMain.dll, not the OgreAL dlls

kinggori

08-02-2007 04:07:38

in the folder
C:\mydev\OgreAL\Demos\bin\Debug
i opened the file Plugins.cfg

and changed it to :

# Defines plugins to load

# Define plugin folder
PluginFolder=C:\mydev\ogrenew\Samples\Common\bin\Debug

# Define plugins
Plugin=RenderSystem_Direct3D9
Plugin=RenderSystem_GL


where
C:\mydev\ogrenew\Samples\Common\bin\Debug
has the OgreMain_d.dll file (i can see it there)

then i tried running C:\mydev\OgreAL\Demos\bin\Debug\Basic_Demo.exe

it still gives me the same error :cry:

kinggori

08-02-2007 04:13:50

i'm starting to think that maybe i didn't run the installation properly?

CaseyB

08-02-2007 04:20:29

Did you download the Ogre SDK or are you building from source? If you installed from the SDK it should have added two entries to your System Path, if you are building from source, you'll need to do that yourself.

t0tAl_mElTd0wN

08-02-2007 04:20:30

OgreMain_d.dll (or OgreMain.dll) is required to be in the same folder as your executable. There are a few others as well, such as cg.dll, OgrePlatform.dll, and a bunch of others that it'll tell you about beforehand.

The only dlls that should go in the plugins folder are both Render Managers (D3D and OGL), the Particle System, and the three Scene Managers. Everything else needs to be either in the same folder as the executable, or in C:\Windows\System32 (it may be best to hold off until the final installation for that one)

CaseyB

08-02-2007 04:24:20

Everything else needs to be either in the same folder as the executable, or in C:\Windows\System32 (it may be best to hold off until the final installation for that one)That's because the system knows to look for them there, if you add an entry to your system path that points to the folders that those live in already then you don't need to copy them around and clutter stuff up. That is, of course, just a personal preference, you can put them in the same folder as the executable and it will work just fine.

kinggori

08-02-2007 04:32:53

I did as t0tAl_mElTd0wN suggested and i managed to run the simple demo :D :D :D
cool music CaseyB :D


so how do i setup the global variables on Windows xp to avoid having to clutter my space?

and secondly, now how do I add sound to my game? which file in this demo should i look at to get an idea of what i need to do?

t0tAl_mElTd0wN

08-02-2007 04:43:37

For the system path, right click on My Computer and go into Properties.
From there, go to the "Advanced" tab, and click on "Environment Variables" at the bottom.
In the bottom listbox, find the one that says "Path", click on it, and press "Edit"
At the end, add a semicolon (No Spaces!) and add your new path on the end of it.
Repeat as necessary.

As for the sound in the game, try following what I said on the previous page, using the doxygen files as a reference. If after that you can't get it, come back here, but you'll learn better if you can figure it out yourself, rather than copying an example ;)

CaseyB

08-02-2007 04:49:14

cool music CaseyB :DThat's actually my brother! He gave me permission to put some of his songs out so people could play with the library! There are a couple more files in the media/audio directory.

so how do i setup the global variables on Windows xp to avoid having to clutter my space?If you right-click on My Computer and go to Properties / Advanced and click on the Environment Variables button. In the System Variables box there is an entry for Path, just add the paths to the end of that list seperated by a semi-colon.

now how do I add sound to my game? which file in this demo should i look at to get an idea of what i need to do?Look in the OgreApp files in the demos. They aren't very big and you'll see how it's done.

-=EDIT=-
Beat by t0tAl_mElTd0wN