FSLManager, easy sound implementation in OGRE

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
jomunoz
Goblin
Posts: 228
Joined: Wed Apr 13, 2005 5:07 pm
Location: Medellin - Colombia

FSLManager, easy sound implementation in OGRE

Post by jomunoz »

Hi everyone,
I made a sound manager using FreeSL, it' an easy way to implent sound using the example framework or your own framework.
It consist of the following classes FSLSoundObject, FSLSoundEntity, FSLAmbientSound, FSLListener, FSLSoundManager and SoundListener.

FSLSoundObject: is the base object for sounds, can't use directly, must derive from it.

FSLAmbientSound: Used for sound that's not present in the 3D space, like sound tracks or ambient sounds.

FSLSoundEntity: Used for sound located in 3D space.

FSLListener: It the listener, right now it must be a camera.

FSLSoundManager: Manage creation and destruction of sounds, also is in charge of initializing and stoping the sound system.

SoundListener: updates the position of the listener and SoundEntities every frame.


Here is the link to an example and the source files:
http://www.uploading.com/es/?get=AK7VWMHH
or
http://www.mediamax.com/jomunoz/Hosted/OgreSound.zip

In the example just aproach any of the monkey heads where a different sound is playing, also notice the wind blowing in the backgroung.


It as easy as:

Code: Select all

soundManager = new FSLSoundManager( mCamera ); //Create instance of the Sound Manager
soundManager->initSound(); //Init sound system


FSLSoundObject *sonido1 = soundManager->createSoundEntity("chime1.ogg",nodo2,nodo2->getName(),true);
sonido1->play();
//where nodo2 is the SceneNode of the entity that will have the sound.


//Then add the sound listener to the root object, that will update the position of the objects every frame.
mSoundListener = new SoundListener( soundManager );		
mRoot->addFrameListener(mSoundListener); //Add sound listener so it will update every frame
Hope to improve it a little more.

Suerte,
Last edited by jomunoz on Sat Nov 04, 2006 8:39 pm, edited 3 times in total.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

Wow! Great news! Perfect timing, actually!
Because I was just about to dig into FreeSL myself. :)

Consider making a Wiki page about it!

That way it won't get lost. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
OvermindDL1
Gnome
Posts: 333
Joined: Sun Sep 25, 2005 7:55 pm

Post by OvermindDL1 »

jacmoe wrote:Wow! Great news! Perfect timing, actually!
Because I was just about to dig into FreeSL myself. :)

Consider making a Wiki page about it!

That way it won't get lost. :wink:
Ditto, was just about to add sound to my app. Have you made any wrappers for any other parts, like environments and such? A resource loader for the environment scripts would be nice, I could whip one up in 2 minutes if anyone wishes.
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

nice. A few things,
- can you change the pitch of a sound? I couldn't see it anywhere. Also you create the soundmanager with a camera.
- What happens when you switch cameras? Do you need to recreate all the sounds as they are created through this manager?
User avatar
Grom
Hobgoblin
Posts: 523
Joined: Fri Jan 06, 2006 6:35 pm

Post by Grom »

I fly all around the monkeys but all i hear is wind...
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

get really close to the monkeys :)
OvermindDL1
Gnome
Posts: 333
Joined: Sun Sep 25, 2005 7:55 pm

Post by OvermindDL1 »

The sounds he uses are quiet and intermittent, have to be really close and patient...
User avatar
DaCracker
Gremlin
Posts: 192
Joined: Thu Jan 27, 2005 9:57 am
Location: Sweden
Contact:

Post by DaCracker »

thanks alot jomunoz! this is really useful! :D
----------------------------------------------------
DaCracker's Common Lib:
http://sourceforge.net/projects/dacrackerslib/
User avatar
jomunoz
Goblin
Posts: 228
Joined: Wed Apr 13, 2005 5:07 pm
Location: Medellin - Colombia

Post by jomunoz »

Vectrex wrote:get really close to the monkeys :)
I just notice that on my deskstop computer, you got to get real close to the monkeys so you can hear the sounds, the manager was developed in my laptop where it works OK. I will check that out.
Last edited by jomunoz on Mon Jul 24, 2006 12:32 am, edited 1 time in total.
User avatar
jomunoz
Goblin
Posts: 228
Joined: Wed Apr 13, 2005 5:07 pm
Location: Medellin - Colombia

Post by jomunoz »

The issue of getting to close to the sound sources is fixed, the link to the example and sources is in the first post.
User avatar
artm
Gnoblar
Posts: 23
Joined: Wed Feb 22, 2006 4:09 pm
Location: Schoonoord or Rotterdam
Contact:

Post by artm »

Some questions about the design of the wraper:

- why is listener attached to camera and not to a scene node?

(we have stereo rendering mode in our game where we use two cameras, at the moment I just attach listeener to the left camera, but "correct" way would have been to place it between the two, right?)

- why are samples attached to renderables and not to scene nodes?

(I'd like to hang some sounds in space not attached to a renderable, but moving on their own - scary but invisible ghosts)
User avatar
artm
Gnoblar
Posts: 23
Joined: Wed Feb 22, 2006 4:09 pm
Location: Schoonoord or Rotterdam
Contact:

Post by artm »

ah, disregard the second part of my question, i didn't do my homework well, sorry
User avatar
jomunoz
Goblin
Posts: 228
Joined: Wed Apr 13, 2005 5:07 pm
Location: Medellin - Colombia

Post by jomunoz »

The Listener is attached to camera because FSLManager is based on the ExampleApplication, and in the example application the camera isn't attach to a SceneNode, i will change that and look a way to use the ResourceManager to load the samples. When i get that done i will put everything in the Wiki.

And the Sound is attached to a Renderable cause if someone doesn't want to use the SceneNode but create a similar object of their own, they world probably have to extend from a Renderable.
Grox
Gnoblar
Posts: 16
Joined: Fri Oct 29, 2004 12:25 pm
Location: Russia, Krasnodar
Contact:

Extending!

Post by Grox »

I use your manager and I like it.
Can you say me, how to add stream reading for OGG files.
I need it for ambient. Because now it unpacks the hole OGG file into RAM.
User avatar
kiskami
Gnoblar
Posts: 15
Joined: Wed Feb 01, 2006 5:28 pm
Location: Zalaegerszeg, Hungary
Contact:

Post by kiskami »

Please upload it to some webspace, where I dont need to register!
All download slots assigned to your country (Hungary) are in use. We apologize for the inconvenience.
Please try again later.
regards,
Kami
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

@jomunoz:
The FreeSL homepage links to this topic, ie your FreeSL wrapper! WooHoo! 8)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Yaraher
Greenskin
Posts: 142
Joined: Tue Dec 13, 2005 11:37 pm
Location: Lima, Peru
Contact:

Post by Yaraher »

kiskami wrote:Please upload it to some webspace, where I dont need to register!
All download slots assigned to your country (Hungary) are in use. We apologize for the inconvenience.
Please try again later.
Same here, all slots for Peru are in use :P Maybe Rapidshare or Megaupload?
User avatar
Marioko
Halfling
Posts: 43
Joined: Sun Aug 13, 2006 5:38 pm
Location: Cartagena - Colombia

asd

Post by Marioko »

hhehe...

Good for that..

[SpanishMode=ON]
heyyy buena por esa parce.... siga asi.
mm no he podido bajar el demo... le doy en el link, luego el free, y carga una nueva pagina y se queda alli..

Prueba subiendolo a MediaMax.com, te dan un 1GB gratis..
[/SpanishMode=OFF]
User avatar
PapiRauk
Gnoblar
Posts: 10
Joined: Mon Aug 28, 2006 9:45 pm

Post by PapiRauk »

I haven't downloaded it but check out this page. Says Ogre Wrapper which is nice.
http://www.lukasheise.com/web_res/freesl.html
What, me worry?
User avatar
jomunoz
Goblin
Posts: 228
Joined: Wed Apr 13, 2005 5:07 pm
Location: Medellin - Colombia

Post by jomunoz »

Hi again,
I've been working on the final project of my carreer so i can finally graduate, so that's taking most of my time. Hopefully, i will get another place to upload the files this weekend.
arkosh
Gnoblar
Posts: 3
Joined: Thu Sep 14, 2006 11:33 pm

Post by arkosh »

Hi, should I be able to simply add the .h and .cpp files to my project to integrate? I assume that I also have to include the freesl files also. Please help with my setup, I am using vs 2003. Thanks for any advice.

Oh Never Mind, I think that I figured it out. For any others having a problem, all that I did was add the ogresound .h's and .cpp's to my project and point the linker input to the freesl.lib in my project settings.

thanks for the work jomunoz :!:
User avatar
jomunoz
Goblin
Posts: 228
Joined: Wed Apr 13, 2005 5:07 pm
Location: Medellin - Colombia

Post by jomunoz »

I've finally uploaded the files in another place:
http://www.mediamax.com/jomunoz/Hosted/OgreSound.zip

I've put the link in the first post also.
User avatar
yuriythebest
Orc
Posts: 468
Joined: Sun Jul 10, 2005 11:44 am
Location: Kiev, Ukraine
Contact:

Post by yuriythebest »

thanks mate- currently tying to implement in VS2005

things I've done:
1.set up ogre project using jacmoes appWizard
2.added the ogreFSL *.cpp, *h files to my project
3. placed the freeSL.lib file into my project's lib folder, in project settings->linker->input->additional dependencies changed to:
additional dependencies: OgreMain_d.lib FreeSL.lib
4. tried to compile- it says:
1>Compiling...
1>FSLAmbientSound.cpp
1>FSLListener.cpp
1>FSLSoundEntity.cpp
1>FSLSoundManager.cpp
1>FSLSoundObject.cpp
1>Generating Code...
1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'FreeSL.lib'
asteroidWars - an OGRE game
NOOB MAKE MMORPG- the flash movie
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

yuriythebest wrote:3. placed the freeSL.lib file into my project's lib folder
And where is that?
Just add the location of FreeSL.lib to your projects additional library directories.
Like 'dependencies/freesl/lib', or something like that.
Your project doesn't have a 'lib folder' - you need to tell your project what library directories it should use. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
yuriythebest
Orc
Posts: 468
Joined: Sun Jul 10, 2005 11:44 am
Location: Kiev, Ukraine
Contact:

Post by yuriythebest »

jacmoe wrote: Like 'dependencies/freesl/lib', or something like that.
Your project doesn't have a 'lib folder' - you need to tell your project what library directories it should use. :wink:
thanks, it compiles now!
After trying to use the sound commands however, I've realised I still have to add some code. I've used main.cpp from the ogreSL src folder for guidance, but it uses the example application framework while I use the standard jacmoe ogreAppWizard framework.
Currently stumped as to where to declare
SoundListener *mSoundListener;
FSLSoundManager* soundManager;
I've tried declaring them in my header, also the BaseApplication header but either way some part of the code complains

My project without all the fsl files looks like so:

Headers:
BaseApplication.h
ogreSoundTest3.h //my app

Source files:
BaseApplication.cpp
ogreSoundTest3.cpp

also don't know where to put this:


void createFrameListener(void){
mSoundListener = new SoundListener( soundManager ); //Create sound listener
mRoot->addFrameListener(mSoundListener); //Add sound listener so it will update every frame
ExampleApplication::createFrameListener();
}

public:
PruebaSL1() : ExampleApplication(){
mSoundListener = 0;
}

~PruebaSL1()
{ if (mSoundListener)
delete mSoundListener;
if (soundManager)
delete soundManager;
}
I've tried putting the createFrameListener after createScene in ogreSoundTest3.cpp but it didn't get digested very well

This will hopefully be my first ever ogre add on to be implemented by me successfully
asteroidWars - an OGRE game
NOOB MAKE MMORPG- the flash movie
Post Reply