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.

FSLManager, easy sound implementation in OGRE

Postby jomunoz » Sun Jul 23, 2006 12:18 am

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
jomunoz
Goblin
 
Posts: 228
Kudos: 0
Joined: 13 Apr 2005
Location: Medellin - Colombia

Postby jacmoe » Sun Jul 23, 2006 1:23 am

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.
Ogre AppWizards - Ogre project wizards for VC 8-10, Code::Blocks and KDevelop.
OgreAssimpConverter - command-line to convert models to Ogre format.
TwOgreGUI - wrapper for AntTweakBar GUI library.
I accept donations | Me on Google+
User avatar
jacmoe
OGRE Moderator
OGRE Moderator
 
Posts: 21024
Kudos: 162
Joined: 22 Jan 2004
Location: Denmark

Postby OvermindDL1 » Sun Jul 23, 2006 5:22 am

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.
OvermindDL1
Gnome
 
Posts: 333
Kudos: 0
Joined: 25 Sep 2005

Postby Vectrex » Sun Jul 23, 2006 8:13 am

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?
Vectrex
Troll
 
Posts: 1354
Kudos: 1
Joined: 12 Aug 2003
Location: Melbourne, Australia

Postby Grom » Sun Jul 23, 2006 8:54 am

I fly all around the monkeys but all i hear is wind...
User avatar
Grom
Hobgoblin
 
Posts: 523
Kudos: 0
Joined: 06 Jan 2006

Postby Vectrex » Sun Jul 23, 2006 9:00 am

get really close to the monkeys :)
Vectrex
Troll
 
Posts: 1354
Kudos: 1
Joined: 12 Aug 2003
Location: Melbourne, Australia

Postby OvermindDL1 » Sun Jul 23, 2006 10:12 am

The sounds he uses are quiet and intermittent, have to be really close and patient...
OvermindDL1
Gnome
 
Posts: 333
Kudos: 0
Joined: 25 Sep 2005

Postby DaCracker » Sun Jul 23, 2006 10:45 am

thanks alot jomunoz! this is really useful! :D
----------------------------------------------------
DaCracker's Common Lib:
http://sourceforge.net/projects/dacrackerslib/
User avatar
DaCracker
Gremlin
 
Posts: 192
Kudos: 0
Joined: 27 Jan 2005
Location: Sweden

Postby jomunoz » Sun Jul 23, 2006 6:16 pm

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
Kudos: 0
Joined: 13 Apr 2005
Location: Medellin - Colombia

Postby jomunoz » Tue Jul 25, 2006 2:25 am

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
jomunoz
Goblin
 
Posts: 228
Kudos: 0
Joined: 13 Apr 2005
Location: Medellin - Colombia

Postby artm » Fri Aug 25, 2006 10:14 am

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
Kudos: 0
Joined: 22 Feb 2006
Location: Schoonoord or Rotterdam

Postby artm » Fri Aug 25, 2006 11:47 am

ah, disregard the second part of my question, i didn't do my homework well, sorry
User avatar
artm
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 22 Feb 2006
Location: Schoonoord or Rotterdam

Postby jomunoz » Fri Aug 25, 2006 2:56 pm

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.
User avatar
jomunoz
Goblin
 
Posts: 228
Kudos: 0
Joined: 13 Apr 2005
Location: Medellin - Colombia

Extending!

Postby Grox » Mon Sep 11, 2006 2:03 pm

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.
Grox
Gnoblar
 
Posts: 17
Kudos: 0
Joined: 29 Oct 2004
Location: Russia, Krasnodar

Postby kiskami » Fri Sep 29, 2006 4:47 pm

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
kiskami
Gnoblar
 
Posts: 15
Kudos: 0
Joined: 01 Feb 2006
Location: Zalaegerszeg, Hungary

Postby jacmoe » Wed Oct 18, 2006 6:59 pm

@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.
Ogre AppWizards - Ogre project wizards for VC 8-10, Code::Blocks and KDevelop.
OgreAssimpConverter - command-line to convert models to Ogre format.
TwOgreGUI - wrapper for AntTweakBar GUI library.
I accept donations | Me on Google+
User avatar
jacmoe
OGRE Moderator
OGRE Moderator
 
Posts: 21024
Kudos: 162
Joined: 22 Jan 2004
Location: Denmark

Postby Yaraher » Wed Oct 18, 2006 7:26 pm

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
Yaraher
Greenskin
 
Posts: 142
Kudos: 0
Joined: 13 Dec 2005
Location: Lima, Peru

asd

Postby Marioko » Wed Oct 18, 2006 9:09 pm

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
Marioko
Halfling
 
Posts: 43
Kudos: 0
Joined: 13 Aug 2006
Location: Cartagena - Colombia

Postby PapiRauk » Fri Oct 20, 2006 11:49 am

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
PapiRauk
Gnoblar
 
Posts: 10
Kudos: 0
Joined: 28 Aug 2006

Postby jomunoz » Fri Oct 20, 2006 8:40 pm

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.
User avatar
jomunoz
Goblin
 
Posts: 228
Kudos: 0
Joined: 13 Apr 2005
Location: Medellin - Colombia

Postby arkosh » Thu Oct 26, 2006 1:41 am

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 :!:
arkosh
Gnoblar
 
Posts: 3
Kudos: 0
Joined: 14 Sep 2006

Postby jomunoz » Sat Nov 04, 2006 8:41 pm

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
jomunoz
Goblin
 
Posts: 228
Kudos: 0
Joined: 13 Apr 2005
Location: Medellin - Colombia

Postby yuriythebest » Sun Nov 05, 2006 12:30 pm

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
yuriythebest
Orc
 
Posts: 468
Kudos: 0
Joined: 10 Jul 2005
Location: Kiev, Ukraine

Postby jacmoe » Sun Nov 05, 2006 2:23 pm

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.
Ogre AppWizards - Ogre project wizards for VC 8-10, Code::Blocks and KDevelop.
OgreAssimpConverter - command-line to convert models to Ogre format.
TwOgreGUI - wrapper for AntTweakBar GUI library.
I accept donations | Me on Google+
User avatar
jacmoe
OGRE Moderator
OGRE Moderator
 
Posts: 21024
Kudos: 162
Joined: 22 Jan 2004
Location: Denmark

Postby yuriythebest » Sun Nov 05, 2006 8:29 pm

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
User avatar
yuriythebest
Orc
 
Posts: 468
Kudos: 0
Joined: 10 Jul 2005
Location: Kiev, Ukraine

Next

Return to Using OGRE in practice

Who is online

Users browsing this forum: dark_sylinc, Google [Bot] and 2 guests