Page 1 of 3

FSLManager, easy sound implementation in OGRE

Posted: Sun Jul 23, 2006 12:18 am
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,

Posted: Sun Jul 23, 2006 1:23 am
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:

Posted: Sun Jul 23, 2006 5:22 am
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.

Posted: Sun Jul 23, 2006 8:13 am
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?

Posted: Sun Jul 23, 2006 8:54 am
by Grom
I fly all around the monkeys but all i hear is wind...

Posted: Sun Jul 23, 2006 9:00 am
by Vectrex
get really close to the monkeys :)

Posted: Sun Jul 23, 2006 10:12 am
by OvermindDL1
The sounds he uses are quiet and intermittent, have to be really close and patient...

Posted: Sun Jul 23, 2006 10:45 am
by DaCracker
thanks alot jomunoz! this is really useful! :D

Posted: Sun Jul 23, 2006 6:16 pm
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.

Posted: Tue Jul 25, 2006 2:25 am
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.

Posted: Fri Aug 25, 2006 10:14 am
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)

Posted: Fri Aug 25, 2006 11:47 am
by artm
ah, disregard the second part of my question, i didn't do my homework well, sorry

Posted: Fri Aug 25, 2006 2:56 pm
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.

Extending!

Posted: Mon Sep 11, 2006 2:03 pm
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.

Posted: Fri Sep 29, 2006 4:47 pm
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.

Posted: Wed Oct 18, 2006 6:59 pm
by jacmoe
@jomunoz:
The FreeSL homepage links to this topic, ie your FreeSL wrapper! WooHoo! 8)

Posted: Wed Oct 18, 2006 7:26 pm
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?

asd

Posted: Wed Oct 18, 2006 9:09 pm
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]

Posted: Fri Oct 20, 2006 11:49 am
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

Posted: Fri Oct 20, 2006 8:40 pm
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.

Posted: Thu Oct 26, 2006 1:41 am
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 :!:

Posted: Sat Nov 04, 2006 8:41 pm
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.

Posted: Sun Nov 05, 2006 12:30 pm
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'

Posted: Sun Nov 05, 2006 2:23 pm
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:

Posted: Sun Nov 05, 2006 8:29 pm
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