MogreFreeSL - Sound Library

grizzley90

19-11-2006 14:05:35

UPDATE - GET THE LATEST VERSION FROM SVN.

I have ported the Ogre FreeSL manager to Mogre for anyone to use, the original could be found here. This project is meant to be an exact port of the original. I tried to keep the differences as minute as possible, however when I found places that I could use c# features, I tried to do so without changing much of the interface.

I have even translated the demo to show how easy and how minute the differences between the mogre and ogre versions are.
Hopefully this will incite people to start using mogre and translate existing libraries to mogre.

The source will be soon up in the Mogre svn!

You can download the project from here for the moment : http://www.uploading.com/files/AAWDMHQG ... S.zip.html

You can download and compile it with the current sdk (1.8.1).

PS. This project is the result of my frustration with ManagedDirectX.

grizzley90

19-11-2006 15:48:33

You can get it from svn here: https://svn.sourceforge.net/svnroot/mog ... ogreFreeSL

I hope you guys find it useful. :D

LuRenJia

21-11-2006 11:03:34

I'm sorry, what is Ogre FreeSL ?

grizzley90

21-11-2006 12:38:13

The ogre FreeSL manager is an excellent wrapper for the freesl sound library available here: http://www.ogre3d.org/phpBB2/viewtopic.php?t=22679

This is what FreeSL is:


About
FreeSL (Free Sound Library) is a OpenAL wrapper. It also includes the EAX 2.0 library for realistic audio environment simulations plus occlusion and obstruction.

Features
· OpenAL (2D/3D)
· EAX 2.0 (can simulate complex sound environments like underwater or caves)
· Sound Object Memory Manager
· Static Playback WAV and Ogg
· Stream Playback Ogg and AVI(PCM)
· Zip File Support (can load static sounds and EAX scripts from *.zip packages)
· Can be used by Visual Basic and C++

Now I have ported the ogrefreesl that lets you use 3D sound in OGRE. So you can use 3d sound in ogg or wtv format freesl supports with your MOGRE app. I have also ported the demo to show how similiar they are and how easy they are to use, in hope of persuading other developers to port their ogre libraries to mogre.

I hope I just offered a decent explanation of its uses. You can download the project compile it and try it out.

EDIT: I got fed up with being forced to used ManagedSound from dx1.1 with all the random loader lock exceptions and everything else, so I just ported something I knew would work and had plenty of features I desired.

LuRenJia

22-11-2006 09:57:44

thank you very much!

MOGRE is a great project, it will be greater with the add-ons such as OGRE FreeSL.

sorry for my poor English. :oops:

Bekas

22-11-2006 11:16:48

@grizzley90:
Can you edit the wiki page for MogreFreeSL ? (put whatever you think is appropriate, description, samples, etc.)

grizzley90

23-11-2006 00:30:24

Done, includes a tutorial, how to compile and run an app. Check it out tell me if there are any mistakes or anything stupid of me. :)

Bekas

23-11-2006 14:07:16

When I tried the demo there was no sound, not even ambient sound, any idea what's wrong ?

grizzley90

24-11-2006 02:12:43

k does it give any error messages? if it doesn't i thinks its because i moved the media folder up one because there was two copies of it in each configuration folder and i wanted to reduce the size of the entire folder (mogrefreesl)... so just recopy the media folder back into the exe folder or change the paths to the sound in the demo ... i believe i forgot to change the paths, sorry!

Bekas

24-11-2006 09:38:27

I fixed the paths in the demo and it's working fine now, good job :D

But there should be a check somewhere that will throw an exception or log a message if the sound file doesn't exist, what do you think ?

grizzley90

24-11-2006 12:48:00

It will now throw a file not found exception if the file doesn't exist. Its in svn now.

LuRenJia

11-12-2006 10:05:41

Can't FreeSLOgre load sound file by ogre resource management?

grizzley90

11-12-2006 18:07:49

I don't understand what you mean by "Can't FreeSLOgre load a sound file by ogre resource management? " ...

Are you trying to ask if mogrefreesl can load resources you already have in your resources.cfg?

Are you trying to ask if mogrefreesl can load something already loaded into ogre? :?

Absolutely confused?

The sound file loading is done in freesl which is why it supports multiple file formats.

LuRenJia

12-12-2006 03:20:24

sorry for my poor English. :oops:

My question is if mogrefreesl can load resources I already have in my resource.cfg.

I found mogrefreesl now directly access filesystem, not by ogre.

grizzley90

02-01-2007 15:20:51

@LuRenJia If I understand correctly, no, because you can't declare a sound in freesl like you can declare a material and use it later in ogre. Declaring sounds is not currently possible in FreeSL.

UPDATE:

I added to MogreFreeSL zip and streaming support with little change to the interface, which isn't in the current OgreFreeSL.

soundManager.CreateAmbientSound("../media/sound/windy1.ogg", "Ambiente1", true, true); //Create Ambient sound

The last boolean variable will specify streaming.

soundManager.CreateSoundEntity("../media/sound/chime.zip","chime1.ogg", nodo2, nodo2.Name, true);

for zip support. You need the zip file and the name of the soundfile inside it. (the last bool is not for streaming because, I believe, freesl doesn't currently support streaming from a zip.)

You no longer need the ogg and vorbis dlls. Thanks to M.Stevens for spotting that one out.

Get the latest updated files from svn and check out the demo that is in svn as well.

LuRenJia

08-01-2007 08:35:57

Cool! Thank you very much.

Does it only support ogg sound file? I tried mp3 sound file, there was no sound, and it work fine when change to ogg format

grizzley90

15-01-2007 00:22:33

It seems to support ogg and not mp3 unless I am mistaken. mp3 has some legal issues you have to worry about by the way.

From the website it says ogg and wav.

Features
· OpenAL (2D/3D)
· EAX 2.0 (can simulate complex sound environments like underwater or caves)
· Sound Object Memory Manager
· Static Playback WAV and Ogg
· Stream Playback Ogg and AVI(PCM)
· Zip File Support (can load static sounds and EAX scripts from *.zip packages)
· Can be used by Visual Basic and C++

LuRenJia

15-01-2007 09:25:47

I use a tool to convert mp3 to ogg. :D

smernesto

29-01-2007 06:50:33

What is the difference between OpenAL and FreeSL, why create a wrapper for OpenAL and don´t use it directly?.

I don´t know much about both :wink:

grizzley90

03-02-2007 14:00:20

OpenAL is like OpenGL for graphics. FreeSL is like OGRE for sound.

FreeSL will let you play ogg files right away, instead of having to write your own ogg loader. It will let you play files inside zips etc...

FreeSL:
OpenAL (2D/3D)
· EAX 2.0 (can simulate complex sound environments like underwater or caves)
· Sound Object Memory Manager
· Static Playback WAV and Ogg
· Stream Playback Ogg and AVI(PCM)
· Zip File Support (can load static sounds and EAX scripts from *.zip packages)

Eldritch

27-03-2007 08:42:35

I must say that I absolutely love the port of FreeSL, but there are some issues with it:

1. Sounds do not appear in 3D all the time. I've loaded a sound entity and attached it to my ninja entity. As long as the ninja remains still, the sound will always play in full volume even though I move the camera several units away. But, if I suddenly move the ninja, then the sound is updated and is played with lower volume. I first thought it was a stereo vs. mono thing like with OpenAL, but that was not the case.

2. How to use EAX? I've found nothing on this.

Keep up the amazing work :)

grizzley90

29-03-2007 00:04:38

Updated to Eihort and FreeSL version 2.4.


@Eldritch:
Thanks!
1. I haven't had a problem like that before, try with the new FreeSL, if it is still persistent, send me a code example.

2. I will add the ability to use EAX scripts, this weekend, and I will update the wiki with an example of how to use it.

Eldritch

29-03-2007 16:06:21

Tried the new version. The errors still remain... If I only move the camera, the sound entity can be heard in full volume all the time. But if I only move the sound entity, it fades in out and depending on distance.

Stereo is reversed as well.

I am not sure what code you want to see. Here is how I set up my sound:


public class Sound
{
private Dictionary<string, FSLSoundObject> m_dictSounds = new Dictionary<string, FSLSoundObject>();

public void Initialize()
{
FSLSoundManager.Instance.InitializeSound(CCamera_s.Instance.GetInternalRef());
}

public void DeInitialize()
{
FSLSoundManager.Instance.Destroy();
}

public void Update()
{
FSLSoundManager.Instance.UpdateSoundObjects();
}

public void LoadMusic(string strName, string strFilename)
{
if (!m_dictSounds.ContainsKey(strName))
{
FSLSoundObject sound = FSLSoundManager.Instance.CreateAmbientSound(strFilename, strName, true, false);
m_dictSounds.Add(strName, sound);
}
}

public void LoadSound(string strName, string strFilename, SceneNode refNode, bool bLoop)
{
if (!m_dictSounds.ContainsKey(strName))
{
FSLSoundObject sound = FSLSoundManager.Instance.CreateSoundEntity(strFilename, refNode, strName, bLoop, false);
m_dictSounds.Add(strName, sound);
}
}

public FSLSoundObject GetSound(string strName)
{
FSLSoundObject sound;
m_dictSounds.TryGetValue(strName, out sound);
return sound;
}

public void Play(string strName)
{
FSLSoundObject sound;
m_dictSounds.TryGetValue(strName, out sound);
sound.Play();
}

public void Stop(string strName)
{
FSLSoundObject sound;
m_dictSounds.TryGetValue(strName, out sound);
sound.Stop();
}
}


I load the sound and play it from Lua, using this class. The actual code is somewhat similar to your demo, I've simply wrapped a few things so it works better from Lua. Could be that I have done something wrong though.. I call the Update() function each frame, if that has anything to do with the errors I am experiencing.

grizzley90

07-04-2007 17:00:50

@ Eldritch:

You might find this piece of information useful:
Note: the sound must be recorded in MONO format, or EAX and 3D positioning will not work.
It was in Sample3.cpp in the freesl 2.4 distribution.

Also I added the ability to create listener environments, load eax scripts etc...

The latest version is in svn. I apologize for taking this long but I didn't have any time last weekend and throughout the week.

Eldritch

07-04-2007 17:19:57

I have the sound in mono already, since I knew of this problem from using OpenAL some years ago.. so there must be something else wrong..

grizzley90

08-04-2007 15:54:57

Is the demo working fine, because the demo you can move the camera and it will fade in and out depending on the distance, well atleast on my pc? Did you try the eax?

Eldritch

09-04-2007 18:55:36

I cannot run the demo, I get some exception. I've tried using all the necessary DLLs but that won't work.

How do I use EAX in this? I see very little belonging to EAX...

grizzley90

09-04-2007 19:39:53

What is the exception you get running the demo?

if you updated from svn, you should have this in the fsl sound manager. You can use the load listener environment for loading eax scripts etc...

#region Environment Functions
164
165 /// <summary>
166 /// Sets the listener environment.
167 /// </summary>
168 /// <param name="prop">The prop.</param>
169 public void SetListenerEnvironment(FreeSL.FSL_EAX_LISTENER_PROPERTIES prop)
170 {
171 FreeSL.fslSetListenerEnvironment(prop);
172 }
173 /// <summary>
174 /// Sets the listener environment preset.
175 /// </summary>
176 /// <param name="type">The type.</param>
177 public void SetListenerEnvironmentPreset(FreeSL.FSL_LISTENER_ENVIRONMENT type)
178 {
179 FreeSL.fslSetListenerEnvironmentPreset(type);
180 }
181
182 /// <summary>
183 /// Sets the listener default environment.
184 /// </summary>
185 public void SetListenerDefaultEnvironment()
186 {
187 FreeSL.fslSetListenerDefaultEnvironment();
188 }
189
190 /// <summary>
191 /// Gets the current listener environment.
192 /// </summary>
193 /// <returns></returns>
194 public FreeSL.FSL_EAX_LISTENER_PROPERTIES GetCurrentListenerEnvironment()
195 {
196 return FreeSL.fslGetCurrentListenerEnvironment();
197 }
198
199 /// <summary>
200 /// Loads the listener environment.
201 /// </summary>
202 /// <param name="strFile">The STR file.</param>
203 /// <returns></returns>
204 public FreeSL.FSL_EAX_LISTENER_PROPERTIES LoadListenerEnvironment(string strFile)
205 {
206 return FreeSL.fslLoadListenerEnvironment(strFile);
207 }
208
209 /// <summary>
210 /// Loads the listener environment from zip.
211 /// </summary>
212 /// <param name="strFile">The STR file.</param>
213 /// <param name="strPackage">The STR package.</param>
214 /// <returns></returns>
215 public FreeSL.FSL_EAX_LISTENER_PROPERTIES LoadListenerEnvironmentFromZip(string strFile, string strPackage)
216 {
217 return FreeSL.fslLoadListenerEnvironmentFromZip(strPackage, strFile);
218 }
219
220 /// <summary>
221 /// Creates the listener environment.
222 /// </summary>
223 /// <param name="strData">The STR data.</param>
224 /// <param name="Size">The size.</param>
225 /// <returns></returns>
226 public FreeSL.FSL_EAX_LISTENER_PROPERTIES CreateListenerEnvironment(string strData, uint Size)
227 {
228 return FreeSL.fslCreateListenerEnvironment(strData, Size);
229
230 }
231 #endregion

Eldritch

09-04-2007 20:09:36

Aha.. still not used to MSVC having the ability to hide code blocks.. really stupid thing :)

Found it. but, the following does not seem to have any effect:

FSLSoundManager.Instance.SetListenerEnvironmentPreset
(FreeSL.FSL_LISTENER_ENVIRONMENT.FSL_ENVIRONMENT_SEWERPIPE);

I have a sound card that supports it. Do I need to change the Sound system setting in FreeSL?

grizzley90

11-04-2007 18:00:11

Which sound system are you using right now?
Try with OpenAL

Eldritch

11-04-2007 20:38:58

The default one. How do I change?

grizzley90

11-04-2007 21:37:02

public bool InitializeSound(Mogre.Camera listener)
{
_listener = new FSLListener(listener);
if (_initSound)
return true;

if (!FreeSL.fslInit(FreeSL.FSL_SOUND_SYSTEM.FSL_SS_DIRECTSOUND3D)) //Change if desire
return false;

_initSound = true;
return true;
}
In FSLSoundManager.cs

Eldritch

12-04-2007 10:34:56

Aha, I cannot change it on the fly?? Would be good to be able to give the user some options.

grizzley90

12-04-2007 12:49:24

Just like Ogre you can't change the settings on the fly, you have to reinitialize the system and why would you in this case? Sound will be the same in all the subsystems, stick to one, the OpenAL one is best because potentially it would work on non windows pcs when mogre starts working on non windows pcs. The reason why I don't give you options is because MogreFreeSL was meant to be a direct port of the c++ version. If you want to be able to pass the options simply do this:


public bool InitializeSound(FreeSL.FSL_SOUND_SYSTEM mSys, Mogre.Camera listener)
{
_listener = new FSLListener(listener);
if (_initSound)
return true;

if (!FreeSL.fslInit(mSys)) //Change if desire
return false;

_initSound = true;
return true;
}


Just replace the original function with that one.

Eldritch

12-04-2007 14:21:38

Great, thank you, I hope the EAX will work :)

Edit: It did, when I changed the sound system to EAX 2.0. Thanks a bunch!

GermanDZ

02-06-2007 05:27:41

A few weeks ago, I was trying OgreDotNet.. And because there is not a FreeS L for OgreDotNet, I translate MogreFreeSL to OgreDotNet (easy work). My tests runs fine.


Now I am trying MOGRE (I like more than OgreDotNet because MOGRE is 1.4 compatible).. But at the time of add the Sound to my Scene, I heard the ambient sound, but it's ends after the 1st Loop. [YES, I suscribed the SoundManager to the FrameStarted Event]


Any ideas? I am trying with FreeSL 2.5 and HEAD of SVN for MogreFreeSL.


I am an experienced developer, any hint could be useful. I can contribute with patchs..

grizzley90

02-06-2007 13:12:59

When you create an ambient sound, are you setting the loop variable to true?

Example:

FSLSoundObject sonido2 = soundManager.CreateAmbientSound("../media/sound/windy1.ogg", "Ambiente1", /*Loop value here*/true, true); //Create Ambient sound


Also does the demo work fine on your computer?

GermanDZ

21-06-2007 22:23:10

Yes, the demo works. I have a DLL trouble with MOIS, so.. sounds works fine until the error of DLL.

Of course that my app sets loop to true;

I suspect the problem could be a Thread problem. I running the render loop in a different thread because I have a Window Forms App.

palisade

13-07-2007 05:49:43

Seems like the Z axis is flipped. I created a ninja that just turns and I attached a mono looping footstep sound to him. I've tried all the different possible sound devices that FreeSL supports, none of them resolved this issue. Changing the reference or max distance just makes the sound further away.

1) The sound starts out very loud, at first, almost as if its an ambient effect, a second or two later its inaudible.

2) If I move my camera close to the entity, I can hear the footsteps but they're coming from my rear speakers.

3) If I fly through the entity to the other side, I can hear the footsteps on my front speakers.

:shock:

To temporarily resolve this I added the following code to the FSLListener:


public class FSLListener
{
private Mogre.Camera _renderable;
public bool ZFlipped = false;
...
public void Update()
{
int zflip = (ZFlipped) ? -1 : 1; // added

FreeSL.fslSetListenerPosition(_renderable.Position.x,
_renderable.Position.y,
zflip * _renderable.Position.z); // added

Mogre.Vector3 yVec, zVec;
yVec = _renderable.Orientation.YAxis;
zVec = _renderable.Orientation.ZAxis;

FreeSL.fslSetListenerOrientation(zVec.x, zVec.y, zVec.z, yVec.x, yVec.y, yVec.z);
}
...
}


To use:


soundManager = FSLSoundManager.Instance;
soundManager.InitializeSound(FreeSL.FSL_SOUND_SYSTEM.FSL_SS_DIRECTSOUND3D, camera);
soundManager.GetListener().ZFlipped = true;

stepsFX = (FSLSoundEntity)(FSLSoundEntity)soundManager.CreateSoundEntity("../media/sound/foot/Footsteps.wav",
ninjaNode, ninjaNode.Name, true, false);
stepsFX.Play();

distrans

19-07-2007 15:31:29

Hello,

i'm new to ogre3d.org and this is my first post.

First of all, thank you, dear grizzley90 for MogreFreeSL and thank you, dear ogre-community for ogre and all of its sub-projects. Its simply amazing :)

Now i want to be a little part of this community:

Just replace the original function with that one.

I suggest to overload InitializeSound.

To temporarily resolve this I added the following code to the FSLListener:

Don't do this, because it inverts the position of the sound on the z-axis.

Its okay as long as the position of the sound-generating node is [0,0,0] But if you move the node on the z-axis, the sound will move to the exact opposite direction on the z-axis.

And: The y-axis (or paning in sound-terms) seems to be inverted too: If i turn the camera right, the sound moves to the left... I'm trying to fix this at the moment.

Another problem is within FSLListener.Update(): The position of the camera comes from Camera.Position, that is always relative to the parent-node. If you use SceneNodes to move the camera, the position of the cam is always [0,0,0] because of the relativeness to its parent. All you have to do is to replace _renderable.Position with _renderable.WorldPosition and _renderable.Orientation with _renderable.WorldOrientation to get this work with all cases (as i think with all cases...)

Am i right and/or anything i didn't see?

smernesto

13-08-2007 07:18:07

Hi,

well I tried and tried to figure why IsPlaying returns true when the sound is stoped.

There is an error in the DLLImport, the bool datatype in FreeSL is the C++ bool not the Win32 BOOL, then you have to mark all bools with an Attribute because it uses Win32 BOOL by default.

For example if you use this, it works fine:

[DllImport("FreeSL.dll", EntryPoint = "?fslSoundIsPlaying@@YA_NI@Z")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool fslSoundIsPlaying(uint obj);


I marked the return value with [return: MarshalAs(UnmanagedType.U1)], it means the bool is 1 byte bool and not a 4 byte bool. Now IsPlaying works fine in my code, but I will mark all bools with this.

For more information please visit http://msdn2.microsoft.com/en-us/librar ... 5699(vs.80).aspx

Beejay

06-09-2007 04:31:15

All the links seem to be dead, and Google isn't helping me much.. Is there anywhere I can get ahold of MogreFreeSL atm?

dodongoxp

28-10-2007 21:49:23

you can get MogreFreeSL in the Mogre svn repository in source forge.. get the trunk one and you will get MogreFreeSL in there..

the mogre svn trunk is in :

https://mogre.svn.sourceforge.net/svnroot/mogre/trunk

you can get it with tortoise svn easily
8)

codo

02-05-2008 22:47:23

Hello,
I used the newest MogreFreeSL with Mogre 1.4.6 and I'm having issues with ambient sound streaming. It all works OK with no streaming. When I turn it on, however, I can hear like 1sec of music and then silence... I use original Demo of MogreFreeSL with Mogre.dll and Mogre.Demo.ExampleApplication from C:\OgreSDK\bin\debug.

It does not work on my collegue's computer either.
Any ideas what the problem might be?

codo

22-08-2008 07:48:14

Seems like the Z axis is flipped. I created a ninja that just turns and I attached a mono looping footstep sound to him. I've tried all the different possible sound devices that FreeSL supports, none of them resolved this issue. Changing the reference or max distance just makes the sound further away.

1) The sound starts out very loud, at first, almost as if its an ambient effect, a second or two later its inaudible.

2) If I move my camera close to the entity, I can hear the footsteps but they're coming from my rear speakers.

3) If I fly through the entity to the other side, I can hear the footsteps on my front speakers.

:shock:

To temporarily resolve this I added the following code to the FSLListener:


public class FSLListener
{
private Mogre.Camera _renderable;
public bool ZFlipped = false;
...
public void Update()
{
int zflip = (ZFlipped) ? -1 : 1; // added

FreeSL.fslSetListenerPosition(_renderable.Position.x,
_renderable.Position.y,
zflip * _renderable.Position.z); // added

Mogre.Vector3 yVec, zVec;
yVec = _renderable.Orientation.YAxis;
zVec = _renderable.Orientation.ZAxis;

FreeSL.fslSetListenerOrientation(zVec.x, zVec.y, zVec.z, yVec.x, yVec.y, yVec.z);
}
...
}


To use:


soundManager = FSLSoundManager.Instance;
soundManager.InitializeSound(FreeSL.FSL_SOUND_SYSTEM.FSL_SS_DIRECTSOUND3D, camera);
soundManager.GetListener().ZFlipped = true;

stepsFX = (FSLSoundEntity)(FSLSoundEntity)soundManager.CreateSoundEntity("../media/sound/foot/Footsteps.wav",
ninjaNode, ninjaNode.Name, true, false);
stepsFX.Play();



That's my version of Update method which handles reversed stereo problem for me:

public void Update()
{
int zflip = (ZFlipped) ? -1 : 1; // added

FreeSL.fslSetListenerPosition(_renderable.RealPosition.x,
_renderable.RealPosition.y,
_renderable.RealPosition.z);

Mogre.Vector3 yVec, zVec;
yVec = _renderable.RealOrientation.YAxis;
zVec = _renderable.RealOrientation.ZAxis * zflip;// change

FreeSL.fslSetListenerOrientation(zVec.x, zVec.y, zVec.z, yVec.x, yVec.y, yVec.z);
}


Moreover "RealPosition" works independently on camera parentNode. Hope it's useful for someone...

Nexam

27-08-2008 11:28:10

I haven't any sound with the Demo from the SVN...

No error, but no sound... Idea ?

Edit:

I found solution :)

Just change this line in FSLSoundManager.cs

FreeSL.fslInit(FreeSL.FSL_SOUND_SYSTEM.FSL_SS_DIRECTSOUND3D)

koirat

15-06-2009 19:43:36

I have compiled MogreFreeSL with mogre 1.6.2.2
But there are some differences with mogre versions.
See this code /*Commented is what was before*/:
Can you check if what i have made is equivalent to what was before ??
Since renderable.WorldPosition does not exist anymore in Mogre/Ogre


public override void Update()
{
/*
FreeSL.fslSoundSetPosition( _sound,
_renderable.WorldPosition.x,
_renderable.WorldPosition.y,
_renderable.WorldPosition.z );
*/

Mogre.Matrix4 worldTransform = new Mogre.Matrix4();
unsafe
{
fixed (Mogre.Matrix4.NativeValue* natVal = &(worldTransform.value))
{
_renderable.GetWorldTransforms(natVal);
}
}

Mogre.Vector3 trans = worldTransform.GetTrans();

FreeSL.fslSoundSetPosition(_sound,trans.x,trans.y,trans.z);
}


[EDIT]
It looks like it is working, i hear 3d sound.
[/EDIT]

DIABLO99

17-06-2009 22:51:03

can someone post a working link, all i can seem to find is broken links or files that no longer exist...

cheers

smiley80

17-06-2009 23:52:48

http://mogre.svn.sourceforge.net/viewvc ... z?view=tar

DIABLO99

18-06-2009 07:20:57

thank you!

DIABLO99

23-06-2009 20:53:42

hey all,

i'm having some problems getting mogre freesl to work...

i dont use c#, instead i use vb.net...and i havent seen any vb.net tutorial...

so my questions is: Can someone tell me how to start mogre freesl, all i can see in the c# tutorial is a manipulation of already declared variables, but i cant figure out where those declarations are, so i'm pretty much "stuck".
if someone could tell me the first steps(declaration,imports etc),no need for "late" code like assigning sounds to nodes and so on...

someone answer plz...

cheers,

DIABLO99

27-06-2009 21:27:22

anyone?

i just need the "startup" code, or a project , something lol

koirat

27-06-2009 23:02:26

You are talking probably about default instance of FSLSoundManager.

We do it like this in c#
FSLSoundManager.Instance.InitializeSound(camera);

It's probably a Singelton pattern, it's created as soon as you call Instance (or maybe sooner) for the first time.
You do not declare this variable.

same as creating sound
FSLSoundManager.Instance.CreateSoundEntity(...);

I hope that helps, I'm not much of a VB programmer.

DIABLO99

27-06-2009 23:16:59

well, thank you for the quick answer but,

vb.net doesnt recognize fslsoundmananger... i've added the dll's, and copy-paste the line (FSLSoundManager.Instance.InitializeSound(camera))

and says flsSoundManager is not decladed...i don't know if i need to add a reference, or the method is diferent from the above mentioned...

if anyone knows the solution, plz say something, i'm a little short on time(need this for a school project)

smiley80

27-06-2009 23:40:46

FSLSoundManager is in namespace FSLOgreCS, which you have to import first:
Imports FSLOgreCS
or you use the fully qualified name:
FSLOgreCS.FSLSoundManager.Instance.InitializeSound(camera)

DIABLO99

27-06-2009 23:50:30

hmmm i've just started a mogre aplication, added the dll's and imported fslogrecs(error here), but it still doesn t work...

the error on the import is :Namespace or type specified in the Imports 'FSLOgreCS' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.

dont do i need to had some kind of reference to add an exterior resource? (i'm a noob, i know...)

smiley80

28-06-2009 00:10:56

1) open the FSLOgreCS solution
2) if your using 1.6.2 make the changes koirat has posted
3) correct the reference for Mogre in the FSLOgreCS project
4) build the FSLOgreCS project
5) copy FSLOgreCS.dll (.\FSLOgreCS\bin\release) and the native dlls (.\FSLOgreCSDemo\bin\release) to the output dir of your project
6) in your project, add the reference for FSLOgreCS

DIABLO99

28-06-2009 00:39:02

thank you! it works!
this explanation should be added to the wiki tutorial for the vb.net users...

just got 1 last question:

when i'm creating an object sound
Dim sound As FSLSoundObject = FSLSoundManager.Instance.CreateSoundEntity("./media/sound/soundobject.ogg", spamnNode, spamnNode.Name,??? )

it asks for a loop as boolean in the end, in the c# tutorial is - boollooptrue but in vb.net i dont know what to put there

iNuts

28-06-2009 03:23:49

For what I tryed with MogreFreeSL, you need to pass a boolean value there (true/false) for the constructor to know if It loops or not the play of your loaded sound. In the demo boollooptrue is a boolean with the value true....

For instance, for an ambient sound (In C#):
FSLSoundObject ambient = soundManager.CreateAmbientSound("../media/sound/ambient.wav", "AmbientCuteName", true, true);

For a sound attached to a Ogre(well....Mogre) 3dEntity:
SoundEntity = soundManager.CreateSoundEntity("../media/sound/chime.zip", "MySound.wav", node, node.Name, true);

The weird thing is Intellisense (on VisualStudio...) thinks the prototype for the CreateSoundEntity requires two booleans at the end (one for streaming an other for looping... but if you put them both it doesn't compile, because it doesn't have that prototype method... strange.)

It works with just that line of code though, I have my 3d objects with sound on them.
Hope it helps in any way...

DIABLO99

28-06-2009 11:34:32

thanks, it worked, but once again, i have another problem....

when i put this: FSLSoundManager.Instance.InitializeSound(mycamera)
and debug, it shows the c# code, and a yellow marker thing "gets stuck" on - if (!FreeSL.fslInit(FreeSL.FSL_SOUND_SYSTEM.FSL_SS_DIRECTSOUND3D)) //Change if desire

hmmm and i dont know why, i'm not using any brakepoints, and it doesnt step over, it just stays there...

so, if anyone could help me again

THE CODE IN C# ----------------------------------------------------------------------------------------------

public bool InitializeSound(Mogre.Camera listener)
{
_listener = new FSLListener(listener);
if (_initSound)
return true;

if (!FreeSL.fslInit(FreeSL.FSL_SOUND_SYSTEM.FSL_SS_DIRECTSOUND3D)) //Change if desire
return false;

_initSound = true;
return true;

iNuts

28-06-2009 18:55:33

The yellow marker on VS (visual studio, any edition) represents usually an exception that was not handled (sometimes it can be worst and it closes with no marker)...

You can do several things to examine what happened:
- log (ogre.log)
- debug by hand
- catch and look at the exception
- confirm if that the yellow marker window has the "View Detail.." link, which gives you more info on the exception..


Good luck. Post if you need more help (and if I can help you o'course... I'm currently using IrrKlang as 3d sound engine, but I've also used MogreFreeSl and its a great engine).

DIABLO99

28-06-2009 21:01:12

ohohohoh thanks man, it works!

the problem was solved by simply putting the propertie (coppy to output - copy if newer) and thats it!

made my day...

cheers everyone

iNuts

29-06-2009 00:19:46

ohohohoh thanks man, it works!

the problem was solved by simply putting the propertie (coppy to output - copy if newer) and thats it!

made my day...

cheers everyone


No sweat, usually problems are more simply than we imagine (note to myself... : 8) )
Good luck.

rbee

20-09-2009 12:41:07

Hey everybody,

I'm not able to convert my wav and mp3 files to ogg files, so that they will be handled correctly in my game.
When I use the converted files in my game, there is no 3D effect, doesn't matter where I am standing. It has always the same volume.
Why that? When I change the file to one of the examples, it works.

Which converter should I use?

Thanks!

rbee

20-09-2009 15:14:30

Hey guys!

I have done it. The problem was, that you have to set the channel-number of the output file to 1 (mono). Furthermore, I had to solve the problem with the inverted Z-axis (code also in this thread).
Now it works as expected.

Thanks!

rbee

21-09-2009 21:01:29

Has anybody got streaming with an ogg file to work? Everything works perfect with streaming = false!
If i use the test.ogg file and the streaming=true parameter, then I here only a second the sound, after this second, it's completely quiet.

Anybody?

codo

23-09-2009 11:40:08

I've spent some time working with streaming oggs. Unfortunatelly MogreFreeSL does not provide a stable solution. Music occasionally glitches and stops (exceptions from within OpenAL which is the heart of the library). I tried to put the update method in the separate thread - no luck there... Any ideas?

Kohedlo

21-11-2009 16:47:14

Hi all.

I have a problem. I integrated MogreFreeSL- to my project -but no any sound.(Is quietly as in grave)I see demo also. I compile demo , fix ihe patchs,change directory- but no sound.Please , give me link to download worked demo of MogreFreeSL with scr - and its all for me. I trusted on you guys.

Kohedlo

21-11-2009 17:25:58

I tested demo on another CPU - and sound is present.
MogreFreeSL -is really works -there my bad CPU

codo

20-12-2009 10:40:00

I've spent some time working with streaming oggs. Unfortunatelly MogreFreeSL does not provide a stable solution. Music occasionally glitches and stops (exceptions from within OpenAL which is the heart of the library). I tried to put the update method in the separate thread - no luck there... Any ideas?

Finally I've managed to get it running. Simply get the newest FreeSL.dll (2.5.0.0), not the one distrubuted with MogreFreeSL (2.4.0.0), and replace the old one.
There's also one tiny problem when playing looped, streaming sounds. They are not restarted, also fslSoundIsPlaying() is buggy . So I did a rough workaround. Add the following to your FSLSoundObject.cs:

...
protected bool _streaming;

protected bool _loop;

protected bool _shouldBePlaying = false;
protected bool _playing = false;
public void SetSound(string soundFile, bool loop, bool streaming)
{
RemoveSound();
if (File.Exists(soundFile) == false)
throw new FileNotFoundException("The sound file at : " + soundFile + " does not exist.");
if (streaming)
_sound = FreeSL.fslStreamSound(soundFile);
else
_sound = FreeSL.fslLoadSound(soundFile);
_streaming = streaming;
if(!streaming) LoopSound(loop);
_loop = loop;
_soundFile = soundFile;
_withSound = true;
}

public virtual void Play()
{
FreeSL.fslSoundPlay(_sound);
_shouldBePlaying = true;
_playing = true;
}

public void Stop()
{
_shouldBePlaying = false;
FreeSL.fslSoundStop(_sound);
_playing = false;
}

public bool IsPlaying()
{
// z uwagi na bugi w streamingu w FreeSL trzeba zrobic workaround...
if(FreeSL.fslSoundIsPlaying(_sound))
{
// nie wierzymy freeslowi
return _playing;
}
else
{
// wierzymy ze dzwiek sie zakonczyl
_playing = false;
return false;
}
}

public virtual void Update()
{
if(_streaming)
{
if(_loop && _shouldBePlaying && !IsPlaying())
{
this.SetSound(_soundFile, _loop, _streaming);
SetGain(GetBaseGain() * EngineConfig.SoundVolume / 100.0f);
Play();

}
}

}


Remember to call Update() method. I do it in separate thread, I'm not sure whether it works in otherwise.


Update: after extensive testing my conclusion is that streaming in FreeSL is sh**** :twisted:

Mahdi

20-04-2010 13:09:54

Hello great Community,

I've got a tiny problem with MogreFreeSL, I implement it in a project we have to do for university a little game, using touchless and ARToolKit to realize a Xylophone playing game. So sound should be quite important ;)
All tones are seperate files, and each stroke on the keys creates a new FSLManager.CreateEntity(...); In general all works fine. Sound is clear and perfect at all.
But if I play a specifiv amount of tones (large amount indeed, I guess about 250 or 500) Everything is quite quiet -,- don't know exactly why, also try to do this via CreateAmbient, and to destroy them after 32 tones played ... but the same issue is still present.

I hope anybody has got any advice.

Code is accessable here:
http://bucketfullofwork.googlecode.com/svn/trunk/

But I'm sorry this project we have to create within 3 weeks and in a shuffled group, so the quality of code is very disgusting...

thx!
Mahdi

RcALTIN

11-08-2012 00:14:24

Hello guys, i have a problem. In my test app, my soundentity moving with camera, not stick to the node which i gave it :x i am an newbie who has discovered (m)ogre two days ago. i'm tried to work mogrefreesl for a day but i didnt solve this problem. This is code of my test app :

using System;
using System.Collections.Generic;
using System.Text;
using Mogre;
using MogreFreeSL;

namespace testgame
{
class Program
{
protected static Root mRoot;
protected static RenderWindow mRenderWindow;
protected static SceneManager sceneMgr;
//protected static float mTimer = 5;
protected static Camera camera;

protected static MOIS.InputManager inputMgr;
protected static MOIS.Keyboard inputKeyboard;
protected static MOIS.Mouse inputMouse;

static SoundManager sMgr;

protected static void CreateRoot()
{
mRoot = new Root();
}

protected static void DefineResources()
{
ConfigFile cf = new ConfigFile();
cf.Load("resources.cfg", "\t:=", true);

var section = cf.GetSectionIterator();
while (section.MoveNext())
{
foreach (var line in section.Current)
{
ResourceGroupManager.Singleton.AddResourceLocation(
line.Value, line.Key, section.CurrentKey);
}
}
}

protected static void CreateRenderSystem()
{
/*if (!mRoot.ShowConfigDialog())
throw new OperationCanceledException();*/

RenderSystem renderSystem = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem");
renderSystem.SetConfigOption("FSAA", "4");
renderSystem.SetConfigOption("Full Screen", "No");
renderSystem.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");
mRoot.RenderSystem = renderSystem;
}

protected static void CreateRenderWindow()
{
mRenderWindow = mRoot.Initialise(true, "Test-Game");
}

protected static void InitializeResources()
{
TextureManager.Singleton.DefaultNumMipmaps = 5;
ResourceGroupManager.Singleton.InitialiseAllResourceGroups();
}

protected static void CreateScene()
{
sceneMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
camera = sceneMgr.CreateCamera("Camera");
camera.Position = new Vector3(0, 0, 150);
camera.LookAt(Vector3.ZERO);
mRenderWindow.AddViewport(camera);

//TO DO:

Entity ogreHead = sceneMgr.CreateEntity("Head", "ogrehead.mesh");
SceneNode headNode = sceneMgr.RootSceneNode.CreateChildSceneNode();
headNode.AttachObject(ogreHead);
headNode.SetPosition(1963, 50, 1660);
sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f);

/*Light l = sceneMgr.CreateLight("MainLight");
l.Position = new Vector3(20, 80, 50);*/

// setting up the camera
camera.Position = new Vector3(1683, 50, 2116);
camera.LookAt(new Vector3(1963, 50, 1660));
camera.NearClipDistance = 0.1f;
camera.FarClipDistance = 50000;

if (mRoot.RenderSystem.Capabilities.HasCapability(Capabilities.RSC_INFINITE_FAR_PLANE))
camera.FarClipDistance = 0;

// setting up the light
Vector3 lightDir = new Vector3(0.55f, -0.3f, 0.75f);
lightDir.Normalise();

Light light = sceneMgr.CreateLight("tstLight");
light.Type = Light.LightTypes.LT_DIRECTIONAL;
light.Direction = lightDir;
light.DiffuseColour = ColourValue.White;
light.SpecularColour = new ColourValue(0.4f, 0.4f, 0.4f);

sceneMgr.AmbientLight = new ColourValue(0.2f, 0.2f, 0.2f);

sceneMgr.SetSkyBox(true, "Examples/CloudyNoonSkyBox", 5, true);

sMgr = SoundManager.Instance;
sMgr.InitializeSound(FSL_SOUND_SYSTEM.FSL_SS_EAX2, camera);
mRoot.FrameStarted += new Mogre.FrameListener.FrameStartedHandler(sMgr.FrameStarted);
sMgr.SetLinearDistanceModel(AL_DISTANCE_MODEL.AL_EXPONENT_DISTANCE_CLAMPED);

SoundEntity soundEntity = sMgr.CreateSoundEntity("file.ogg", headNode, headNode.Name, true, false);
soundEntity.SetReferenceDistance(.5f);
soundEntity.SetMaxDistance(10);
soundEntity.Play();

}

protected static void CreateFrameListeners()
{
mRoot.FrameRenderingQueued += new FrameListener.FrameRenderingQueuedHandler(OnFrameRenderingQueued);

MOIS.ParamList pl = new MOIS.ParamList();
pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE");
pl.Insert("w32_mouse", "DISCL_FOREGROUND");
IntPtr hwnd;
mRenderWindow.GetCustomAttribute("WINDOW", out hwnd);
pl.Insert("WINDOW", hwnd.ToString());
inputMgr = MOIS.InputManager.CreateInputSystem(pl);
inputKeyboard = (MOIS.Keyboard)inputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true);
inputMouse = (MOIS.Mouse)inputMgr.CreateInputObject(MOIS.Type.OISMouse, true);

if (inputKeyboard != null)
{
inputKeyboard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(OnKeyPressed);
inputKeyboard.KeyReleased += new MOIS.KeyListener.KeyReleasedHandler(OnKeyReleased);
}

if (inputMouse != null)
{
//inputMouse.MousePressed += new MOIS.MouseListener.MousePressedHandler(OnMousePressed);
//inputMouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(OnMouseReleased);
inputMouse.MouseMoved += new MOIS.MouseListener.MouseMovedHandler(OnMouseMoved);
}

}

protected static bool OnFrameRenderingQueued(FrameEvent evt)
{
float moveScale = 100 * evt.timeSinceLastFrame;
Vector3 translateVector = Vector3.ZERO;


inputKeyboard.Capture();
inputMouse.Capture();

if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_ESCAPE))
return false;

if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_LSHIFT))
moveScale *= 10;

if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_A))
{
translateVector.x = -moveScale;
}

if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_D))
{
translateVector.x = moveScale;
}

if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_W))
{
translateVector.z = -moveScale;
}

if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_S))
{
translateVector.z = moveScale;
}


camera.MoveRelative(translateVector);

/*
mTimer -= evt.timeSinceLastFrame;
return (mTimer > 0);
*/

if (mRenderWindow.IsClosed)
return false;

return true;
}

protected static bool OnKeyPressed(MOIS.KeyEvent e)
{
switch (e.key)
{
case MOIS.KeyCode.KC_R:
camera.PolygonMode = PolygonMode.PM_WIREFRAME;
break;
}
return true;
}

protected static bool OnKeyReleased(MOIS.KeyEvent e)
{
switch (e.key)
{
case MOIS.KeyCode.KC_R:
camera.PolygonMode = PolygonMode.PM_SOLID;
break;
}
return true;
}

protected static bool OnMouseMoved(MOIS.MouseEvent evt)
{
//if (evt.state.ButtonDown(MOIS.MouseButtonID.MB_Right))
//{
Degree cameraYaw = -evt.state.X.rel * .13f;
Degree cameraPitch = -evt.state.Y.rel * .13f;

camera.Yaw(cameraYaw);
camera.Pitch(cameraPitch);
//}
return true;
}

protected static void EnterRenderLoop()
{
mRoot.StartRendering();
}

static void Main(string[] args)
{
try
{
CreateRoot();

DefineResources();

CreateRenderSystem();

CreateRenderWindow();

InitializeResources();

CreateScene();

CreateFrameListeners();

EnterRenderLoop();
}
catch (OperationCanceledException) { }
}
}
}


what did i do wrongly ? why the soundentity instance moving with camera? i want to stick it on a node which i gave it , thanx for helps. (by the way sorry for my english :D )

RcALTIN

12-08-2012 01:09:12

in where i'm creating my frame listeners
mRoot.FrameStarted += new Mogre.FrameListener.FrameStartedHandler(soundManager.FrameStarted);

in the scene function:

..............
sceneMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
camera = sceneMgr.CreateCamera("Camera");
camera.Position = new Vector3(0, 0, 150);
camera.LookAt(Vector3.ZERO);
mRenderWindow.AddViewport(camera);

soundManager = SoundManager.Instance;
soundManager.InitializeSound(FSL_SOUND_SYSTEM.FSL_SS_DIRECTSOUND3D, camera);
soundManager.GetListener().ZFlipped = false;

AmbientSound sound1 = soundManager.CreateAmbientSound("file1.ogg", "Ambiente1", true, false); //Create Ambient sound
sound1.Play();

SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("N1", new Vector3(0, 0, 0));
Entity ent = sceneMgr.CreateEntity("OgreHead", "ogrehead.mesh");
ent.CastShadows = true;
SceneNode node2 = node.CreateChildSceneNode("N2", new Vector3(0, 0, 0));
//node2.SetPosition(1963, 25, 1660);
node2.AttachObject(ent);
SoundEntity sound2 = soundManager.CreateSoundEntity("file2.ogg", node2, node2.Name, true, false);
sound2.SetReferenceDistance(500f);
sound2.SetMaxDistance(10000f);
sound2.Play();
..................


it works now correctly, after some efforts :D

idcsteve

31-08-2012 16:40:09

Hi all,
Is there any way to get this to work with an x64 version of Mogre? I'm getting a BadImageFormatException, even though the library should be compiled for "Any CPU"

[Edit] I tried to recompile, but I can't get openAL to install - something is badly broken there, and the link for the OpenAL sdk is broken, so I can't figure out a way around this.
If anyone has any suggestions for playing sounds, I'm all ears.
Regards,
Steve