MogreFreeSL Development

materialDefender

07-07-2010 20:11:38

Visit the wiki page for MogreFreeSL download links, compilation instructions, and a detailed tutorial.

See here for the start of the discussion on updating MogreFreeSL.



Hello, everyone!

I'm trying to integrate background and foreground sounds into my program and I'd like to use MogreFreeSL, but I'm having issues compiling it with Mogre 1.7.1:

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


'Mogre.IRenderable' does not contain a definition for 'WorldPosition' and no extension method 'WorldPosition' accepting a first argument of type 'Mogre.IRenderable' could be found (are you missing a using directive or an assembly reference?)


Does anybody know how to resolve this or have a compiled MogreFreeSL 1.7.1 library they could send me?

Thank you for your time!

Kohedlo

07-07-2010 22:20:29

If this occur -need:

1 - Open file FSLSoundManager.cs and find next:

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

if (!FreeSL.fslInit(FreeSL.FSL_SOUND_SYSTEM.FSL_SS_DIRECTSOUND))
return false;

_initSound = true;
return true;
}


2 - change enumerator FreeSL.FSL_SOUND_SYSTEM. - on compatable with yours sound card technology

3 -Recompile and rebuild FSLOgreCS.dll

4 -Take juice and rejoice.

materialDefender

08-07-2010 04:22:05

Thank you for the suggestion. I tried changing the sound system, but it didn't work. I tried all the different enumerations, to no avail.

To me, it seems that the new version of Mogre (1.7.1) isn't compatible with the MogreFreeSL wrapper as it is currently written... has anyone successfully compiled it without code modification?

Again, thank you for your time.

materialDefender

08-07-2010 23:27:44

Whoops, looks like my previous problem was already solved by koirat:
I had found that thread in my previous searches, but I never read page 4 & 5... :oops:

But now, of course, a new problem has cropped up:

QUESTION: When calling CreateSoundEntity(), both the Wiki and the MogreFreeSL thread state that I should just pass a node. When I try this:
soundobject = FSLSoundManager.Instance.CreateSoundEntity("location", node, node.Name, true, false);
it fails, with the message:
Error Argument '2': cannot convert from 'Mogre.SceneNode' to 'Mogre.IRenderable'

Thank you for your time! :D

smiley80

08-07-2010 23:35:15

Change IRenderable to Node and WorldPosition to _getDerivedPosition().

materialDefender

09-07-2010 00:45:52

Hey, it compiles again! Thanks!
:D
:)
:(
:cry:
But it doesn't sound 3D. The balance seems to be a perfect 50/50 between both ears, and the volume does not fade as the camera (set up in the soundmanager InitializeSound function) travels away from the node provided to CreateSoundEntity().

I've added the frame listener as specified by the Wiki:
root.FrameStarted += new Mogre.FrameListener.FrameStartedHandler(FSLSoundManager.Instance.FrameStarted);
and I'm also updating every frame thusly:
FSLSoundManager.Instance.UpdateSoundObjects();
but still no dice.


To sum up: I'm calling the above MogreFreeSL update method and have set up the MogreFSL frame listener, but the soundobjects do not sound 3D.

So... one more time... Please help me? :D

koirat

09-07-2010 09:16:18

As I know environmental sound works only with mono audio. So check if accidentialy you are not using stereo.

Btw. I think that we should introduce IPosition (or differently named) interface to MogreFreeSL. That time our troubles with positioning sound should be solved. What do you think.

materialDefender

09-07-2010 22:01:30

Okay, everything is resolved (thanks, koirat! :D ) except for one thing: the sounds still do not fade as the camera moves away from the sound nodes. :cry:

This post mentioned my current problem (#2), and this post offered different code, but neither work in my situation to make sounds fade as the listener leaves the soundEntity.


Response to koirat:

If everything would work, I would be perfectly complacent with MogreFreeSL the way it is currently written. I can understand wanting to move to a different system of positioning sound so both old & new versions of Mogre can work with MogreFreeSL, but shouldn't smiley80's node-based positioning be compatible with both old & new?

I may have misunderstood your suggestion (and a lot of other things) and if I did, I'm sorry. I really don't know too much about Mogre at this point. :oops:

I suggest we update the svn with the slightly re-written MogreFreeSL, so no one else has to read through forums and ask questions to get a library to work.

To that effect, here's a mostly-working copy (i.e. except for volume fade over distance) of FSLOgreCS.dll for Mogre 1.7.1.
EDIT: Old version of MFSL that was here has been removed. Please check the wiki or the repository for the latest version.

koirat

09-07-2010 23:40:56

Maybe you don't here the difference in sound because change in distance is to small. As I was testing it some time ago with default settings I had to move very far from my sound node.

Are you updating MogreFreeSL from time to time so the distance is updated ?

Doing position interface such as for example IPosition could be useful in cases like this one that occured. Change in Mogre forced to reimplement MogreFreeSL.
You could do classes like for example NodePosition that inherits from IPosition and use it inside MogreFreeSL. So you are not forced to even use Node as your sound placement.

materialDefender

10-07-2010 03:32:41

Ah, you're right, the volume does decrease over larger distances. Thank you!

For anyone looking for solutions, I'm now doing this to change how the volume fades:

soundobject = smgr.CreateSoundEntity("mono.ogg", node, node.Name, true, false); //Create sound object
((FSLSoundEntity)soundobject).SetReferenceDistance(4); //Distance from source at which volume starts to fade
((FSLSoundEntity)soundobject).SetMaxDistance(15); //Distance from source at which volume is at its lowest


I think changing the system to the node-based one would be best. After all, nodes aren't really much more than containers for position & orientation. I can't really imagine Mogre without nodes, and I don't think they'll ever leave.

materialDefender

10-07-2010 05:24:51

Ah, one final question:

Why can I still hear my SoundObject after I've passed the MaxDistance? It's a bit faint, but still there. Is there any fix for this?

Once again, thank you for your time! :D

koirat

10-07-2010 11:08:18


I think changing the system to the node-based one would be best. After all, nodes aren't really much more than containers for position & orientation. I can't really imagine Mogre without nodes, and I don't think they'll ever leave.


IPosition interface would not prevent you form using Nodes. There would be a wrapper class for node inheriting from IPosition.

This below is not checked for errors :)


public interface IPosition
{

float X{get;}
float Y{get;}
float Z{get;}

}

public class NodePosition:IPosition
{

public Mogre.Node Node{get;set;}

public NodePosition(Mogre.Node node)
{
this.Node=node;
}

public float X
{
get{return node.Position.x;}
}

public float Y
{
get{return node.Position.y;}
}

public float Z
{
get{return node.Position.z;}
}

//Or you can change it to world positions

}



instead of this:

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


you could do this:

public override void Update()
{
FreeSL.fslSoundSetPosition( _sound, position.x,position.y,position.z );
}

and you do not have to care if it is Node or some different object providing position to the sound system.

It gives flexibility and a lot of new possibilities.



About you question check if there is something like MinVolume, I do not know it just guessing.

materialDefender

10-07-2010 20:15:49

In search of some sort of MinVolume-like function, I found the source for FreeSL. I read in an FAQ provided with the source that streaming issues (playing for 1 second & stopping) can be remedied by calling a function that I realized had not been wrapped in MogreFreeSL. I read up on PInvoke wrapping and, long story short, I can now stream audio with MogreFreeSL by simply calling a method. :D

Here are all of the methods available in FreeSL. If you see any that you think would be useful (for any purpose), please tell me so I can try to wrap them.

// Initialization, Shutdown and Common Functions
FSLAPI bool FSLAPIENTRY fslInit(FSL_SOUND_SYSTEM val); // main initialization function
FSLAPI void FSLAPIENTRY fslShutDown(); // shutdown FreeSL and free any allocated memory
FSLAPI void FSLAPIENTRY fslUpdate(); // per-frame update stuff (must be called if there are streaming sounds)
FSLAPI void FSLAPIENTRY fslSetAutoUpdate(bool do_automaticly); // dont want to call fslUpdate? Then let FreeSL do it for you
FSLAPI int FSLAPIENTRY fslGetVersion(); // get the current version of FreeSL (should be equal to FSL_VERSION)
FSLAPI void FSLAPIENTRY fslSetErrorCallback(FSLerror_callback* func); // set error callback function
FSLAPI void FSLAPIENTRY fslSleep(float duration); // delay the execution of the current thread for a number of seconds


// General Functions
FSLAPI void FSLAPIENTRY fslSetVolume(float gain_mult); // multiply all sounds with the following gain value
FSLAPI int FSLAPIENTRY fslCountSoundsStreaming(); // get the number of sounds sources that are playing and that are stream sounds
FSLAPI int FSLAPIENTRY fslCountSoundsTotal(); // get the total number of sound sources
FSLAPI unsigned long FSLAPIENTRY fslGetSoundMemoryUsage(); // return the memory usage for the sounds (not including stream sounds)


// Sound Creation and Loading
FSLAPI char* FSLAPIENTRY fslGetSupportedSoundFileFormats(); // returns a string with the extension names of the supported sound files
FSLAPI char* FSLAPIENTRY fslGetSupportedSoundStreamFormats(); // returns a string with the extension names of the supported stream sound files
FSLAPI int FSLAPIENTRY fslGetMaxSources(); // return the amount of sound sources supported by the current hardware
FSLAPI FSLsound FSLAPIENTRY fslCreateEmptySound(); // create a sound object that has not buffer
FSLAPI FSLsound FSLAPIENTRY fslCreateDummySound(); // create an empty sound object
FSLAPI FSLsound FSLAPIENTRY fslCreateSoundFromBuffer(FSLbuffer buffer); // create a sound source using a pre-defined sound buffer
FSLAPI FSLsound FSLAPIENTRY fslLoadSound(const char* strFile); // load a sound file
FSLAPI FSLsound FSLAPIENTRY fslLoadSoundFromZip(const char* strPackage,
const char* strFile); // load sound from *.zip file
FSLAPI FSLsound FSLAPIENTRY fslLoadSoundFromData(const char* strFileFormat,
const void* pData, unsigned int size); // load a sound from data
FSLAPI FSLsound FSLAPIENTRY fslCreateSound(const void* pData, FSLenum format,
unsigned int size, unsigned int freq); // creates a sound from data
FSLAPI FSLsound FSLAPIENTRY fslStreamSound(const char* strFile); // load sound as a stream
FSLAPI FSLsound FSLAPIENTRY fslCloneSound(FSLsound obj); // create a new sound source, copy the buffer
FSLAPI void FSLAPIENTRY fslFreeSound(FSLsound obj, bool remove_buffer = true); // destroy sound source
FSLAPI int FSLAPIENTRY fslFreeAllSounds(); // destroy all loaded/created sound sources (returns remove count)


// Sound Buffer Functions
FSLAPI FSLbuffer FSLAPIENTRY fslGetBufferFromSound(FSLsound obj); // retrieve the sound's buffer
FSLAPI void FSLAPIENTRY fslSetSoundBuffer(FSLsound obj, FSLbuffer buffer); // set the buffer for a sound (if you want to replace the current buffer then you have to destroy it)
FSLAPI FSLbuffer FSLAPIENTRY fslCreateBuffer(); // create an empty buffer
FSLAPI void FSLAPIENTRY fslDestroyBuffer(FSLbuffer obj); // destroy buffer
FSLAPI void FSLAPIENTRY fslSetBufferData(FSLbuffer obj, FSLenum format,
const void* pData, unsigned int size,
unsigned int freq); // set the data for a buffer
FSLAPI void FSLAPIENTRY fslSoundQueueBuffers(FSLsound obj, unsigned int num_buffers,
FSLbuffer* buffers); // queue buffers for a sound
FSLAPI void FSLAPIENTRY fslSoundUnqueueBuffers(FSLsound obj, unsigned int num_buffers,
FSLbuffer* buffers); // unqueue buffers for a sound
FSLAPI FSLbuffer FSLAPIENTRY fslLoadBuffer(const char* strFile); // load a sound buffer from file
FSLAPI FSLbuffer FSLAPIENTRY fslLoadBufferFromZip(const char* strPackage,
const char* strFile); // load a sound buffer from *.zip file
FSLAPI FSLbuffer FSLAPIENTRY fslLoadBufferFromData(const char* strFileFormat,
const void* pData, unsigned int size,
const char* strID = 0); // load a sound buffer from data
FSLAPI int FSLAPIENTRY fslFreeAllBuffers(); // destroy all loaded/created buffers (returns remove count)
FSLAPI FSL_SOURCE_INFO FSLAPIENTRY fslBufferGetInfo(FSLbuffer obj); // get info about the sound buffer


// Sound Functions
FSLAPI void FSLAPIENTRY fslSoundPlay(FSLsound obj); // play the sound
FSLAPI void FSLAPIENTRY fslSoundRewind(FSLsound obj); // rewind the sound
FSLAPI void FSLAPIENTRY fslSoundStop(FSLsound obj); // stop the sound from playing
FSLAPI void FSLAPIENTRY fslSoundPause(FSLsound obj); // pause the sound
FSLAPI bool FSLAPIENTRY fslSoundIsPlaying(FSLsound obj); // is the sound playing?
FSLAPI bool FSLAPIENTRY fslSoundIsPaused(FSLsound obj); // is the sound paused?

FSLAPI void FSLAPIENTRY fslSoundSetLooping(FSLsound obj, bool loop_sound); // should the sound loop?
FSLAPI void FSLAPIENTRY fslSoundSetPositionVec(FSLsound obj, float* position); // set position (float[3])
FSLAPI void FSLAPIENTRY fslSoundSetPosition(FSLsound obj, float x, float y, float z); // set position
FSLAPI void FSLAPIENTRY fslSoundSetVelocityVec(FSLsound obj, float* velocity); // set velocity (float[3])
FSLAPI void FSLAPIENTRY fslSoundSetVelocity(FSLsound obj, float x, float y, float z); // set velocity
FSLAPI void FSLAPIENTRY fslSoundSetPitch(FSLsound obj, float pitch); // set pitch (0,1]
FSLAPI void FSLAPIENTRY fslSoundSetGain(FSLsound obj, float gain); // set gain (0,oo]
FSLAPI void FSLAPIENTRY fslSoundSetMaxDistance(FSLsound obj, float max_distance); // set max distance
FSLAPI void FSLAPIENTRY fslSoundSetReferenceDistance(FSLsound obj, float ref_distance); // set reference distance
FSLAPI void FSLAPIENTRY fslSoundSetConeOrientationVec(FSLsound obj, float* direction); // set cone direction
FSLAPI void FSLAPIENTRY fslSoundSetConeOrientation(FSLsound obj,
float x, float y, float z); // set cone direction
FSLAPI void FSLAPIENTRY fslSoundSetConeInsideAngle(FSLsound obj, unsigned int val); // set inside angle
FSLAPI void FSLAPIENTRY fslSoundSetConeOutsideAngle(FSLsound obj, unsigned int val); // set outside angle
FSLAPI void FSLAPIENTRY fslSoundSetConeOutsideVolume(FSLsound obj, int val); // set outside volume

FSLAPI bool FSLAPIENTRY fslSoundIsLooping(FSLsound obj); // is sound looping?
FSLAPI void FSLAPIENTRY fslSoundGetPosition(FSLsound obj,
float& x, float& y, float& z); // get position
FSLAPI void FSLAPIENTRY fslSoundGetVelocity(FSLsound obj,
float& x, float& y, float& z); // get velocity
FSLAPI float FSLAPIENTRY fslSoundGetPitch(FSLsound obj); // get pitch
FSLAPI float FSLAPIENTRY fslSoundGetGain(FSLsound obj); // get gain
FSLAPI float FSLAPIENTRY fslSoundGetMaxDistance(FSLsound obj); // get max distance
FSLAPI float FSLAPIENTRY fslSoundGetReferenceDistance(FSLsound obj); // get reference distance
FSLAPI void FSLAPIENTRY fslSoundGetConeOrientation(FSLsound obj,
float& x, float& y, float& z); // get cone orientation
FSLAPI unsigned int FSLAPIENTRY fslSoundGetConeInsideAngle(FSLsound obj); // get cone inside angle
FSLAPI unsigned int FSLAPIENTRY fslSoundGetConeOutsideAngle(FSLsound obj); // get cone outside angle
FSLAPI int FSLAPIENTRY fslSoundGetConeOutsideVolume(FSLsound obj); // get cone outside volume
FSLAPI void FSLAPIENTRY fslSoundSetSourceRelative(FSLsound obj, bool is_relative); // should the sound be relative to the listener
FSLAPI bool FSLAPIENTRY fslSoundIsSourceRelative(FSLsound obj); // is the sound relative to the listener
FSLAPI void FSLAPIENTRY fslSoundSetRolloff(FSLsound obj, float val); // set rolloff factor (default: 1.0)
FSLAPI float FSLAPIENTRY fslSoundGetRolloff(FSLsound obj); // get rolloff factor

FSLAPI int FSLAPIENTRY fslSoundGetBufferLength(FSLsound obj); // get length in milisec
FSLAPI int FSLAPIENTRY fslSoundGetBufferPosition(FSLsound obj); // get the current position in milisec
FSLAPI void FSLAPIENTRY fslSoundSetBufferPosition(FSLsound obj, int m); // set the position in milisec (will be applied on the next fslSoundPlay call)
FSLAPI FSL_SOURCE_INFO FSLAPIENTRY fslSoundGetInfo(FSLsound obj); // get info about the sound buffer

FSLAPI void FSLAPIENTRY fslSoundPauseAllSounds(); // pause all sounds that are currently playing
FSLAPI void FSLAPIENTRY fslSoundUnPauseAllSounds(); // unpause all sounds that have been paused
FSLAPI void FSLAPIENTRY fslSoundStopAllSounds(); // stop playing all sounds that are playing
FSLAPI void FSLAPIENTRY fslSoundSetPitchAllSounds(float pitch); // apply the following pitch to all sounds
FSLAPI void FSLAPIENTRY fslSoundSetGainAllSounds(float gain); // apply the following gain to all sounds


// Listener Functions
FSLAPI void FSLAPIENTRY fslSetListenerPositionVec(float* position); // set listener position (float[3])
FSLAPI void FSLAPIENTRY fslSetListenerVelocityVec(float* velocity); // set listener velocity (float[3])
FSLAPI void FSLAPIENTRY fslSetListenerOrientationVec(float* at, float* up); // set listener orientation (view direction) (float[3],float[3])
FSLAPI void FSLAPIENTRY fslSetListenerPosition(float x, float y, float z); // set listener position
FSLAPI void FSLAPIENTRY fslSetListenerVelocity(float x, float y, float z); // set listener velocity
FSLAPI void FSLAPIENTRY fslSetListenerOrientation(float atx, float aty, float atz,
float upx, float upy, float upz); // set listener orientation (view direction)
FSLAPI void FSLAPIENTRY fslSetListenerDistanceModel(FSLenum model); // set distance model
FSLAPI void FSLAPIENTRY fslSetDopplerParameters(float factor, float velocity); // set doppler factor and velocity (default: 1.0)
FSLAPI void FSLAPIENTRY fslSetSpeedOfSound(float val); // set reference speed used in doppler calculation(default: 343.3)
FSLAPI void FSLAPIENTRY fslSetMetersPerUnit(float meters); // set listener distnace representation


// Environmental Audio Functions
FSLAPI void FSLAPIENTRY fslSetListenerEnvironment(FSL_EAX_LISTENER_PROPERTIES* lpData); // setup listener environment
FSLAPI void FSLAPIENTRY fslSetListenerEnvironmentPreset(FSL_LISTENER_ENVIRONMENT type); // set environment from type
FSLAPI void FSLAPIENTRY fslSetListenerDefaultEnvironment(); // set the environment to deafult
FSLAPI FSL_EAX_LISTENER_PROPERTIES FSLAPIENTRY fslGetCurrentListenerEnvironment(); // get current listener environment
FSLAPI FSL_EAX_LISTENER_PROPERTIES FSLAPIENTRY fslLoadListenerEnvironment(const char* strFile); // load listener environment from script file
FSLAPI FSL_EAX_LISTENER_PROPERTIES FSLAPIENTRY fslLoadListenerEnvironmentFromZip(const char* strPackage,
const char* strFile); // load listener environment from script file located in a *.zip file
FSLAPI FSL_EAX_LISTENER_PROPERTIES FSLAPIENTRY fslCreateListenerEnvironment(const char* strData,
unsigned int size); // create listener environment from script data


// Buffer Environmental Audio Functions
FSLAPI void FSLAPIENTRY fslSetBufferEnvironment(FSL_EAX_BUFFER_PROPERTIES* lpData, FSLsound source); // setup buffer environment
FSLAPI void FSLAPIENTRY fslSetBufferDefaultEnvironment(FSLsound source); // set the environment to deafult
FSLAPI FSL_EAX_BUFFER_PROPERTIES FSLAPIENTRY fslGetCurrentBufferEnvironment(FSLsound source); // get current buffer environment
FSLAPI FSL_EAX_BUFFER_PROPERTIES FSLAPIENTRY fslLoadBufferEnvironment(const char* strFile); // load buffer environment from script file
FSLAPI FSL_EAX_BUFFER_PROPERTIES FSLAPIENTRY fslLoadBufferEnvironmentFromZip(const char* strPackage,
const char* strFile); // load buffer environment from script file located in a *.zip file
FSLAPI FSL_EAX_BUFFER_PROPERTIES FSLAPIENTRY fslCreateBufferEnvironment(const char* strData,
unsigned int size); // create buffer environment from script data

// Source Manager
// Enables you to create more than fslGetMaxSources of sound objects. This is particulary usefull
// in computer games where you may want to handle more than fslGetMaxSources sound objects.
// A sound will automaticly be considered as free if it is not playing and is not paused.
// Notice that just as with sound streaming you need to call fslUpdate if you use the Source Manager
FSLAPI void FSLAPIENTRY fslInitSourceManager(int max_sources); // initialize source manager
FSLAPI void FSLAPIENTRY fslShutDownSourceManager(); // shutdown source manager
FSLAPI FSLsound FSLAPIENTRY fslSourceManagerGetSound(FSLbuffer b); // get the handle to a free FSLsound slot (returns 0 if there arent any free slots)
FSLAPI int FSLAPIENTRY fslSourceManagerCountFreeSlots(); // return the number of free slots


I haven't read through all of these functions myself yet - the above text block was pasted as-is from a header file in the FreeSL source code.
I'm going to go ahead and read through the methods available and try to wrap any that look interesting.

About your idea:
I can see how that would be useful. Would you be up to coding such an interface?

koirat

10-07-2010 23:41:02

Yes I can do it but I have to consult with current MogreFreeSL maintainer before making such a change. It's just that I do not know who is doing it right now.

materialDefender

11-07-2010 03:53:35

From what I understand, there is currently no MogreFreeSL maintainer. The original creator, grizzley90, seems to have been absent from the forums since May of 2009. Mstoyke has said that he would update MogreFreeSL, so I PM'd him, requesting his presence in this thread.

Attached is what I've done so far to update the wrapper a bit. I've added Visual Studio documentation, new functionality (such as fslSetAutoUpdate, which allows streaming to work) from FreeSL that wasn't previously wrapped, and also all the updates required to make it workable with Mogre 1.7.1.

Please feel free to suggest (or make!) improvements. :D

mstoyke

12-07-2010 11:13:45

Tadaa, here I am, I think I heard somebody say my name :)

Ok, if you like I can give you write access to the MogreAddons repository, so you can update the sources yourself. As I said before, we currently lack maintainers for most addons and I don't have much time to keep the addons up-to-date myself.

All I need is your username on bitbucket. In case you don't have one yet, it's easy and free to create one.

koirat

12-07-2010 13:10:01

Well I have got access to repository made by gantz, If this is the same repository mogre is using right now I can add such and interface. Tell me if this is proper repository and i will do this.

mstoyke

12-07-2010 15:21:39

We have switched to the repositories at bitbucket/mogre, so the repo is not bound to any user, but to the project name mogre instead. All the other repositories will be combined in one official place, so there will be less confusion about where to find things in the future. I will also remove my old mogre repository clones from my bitbucket/mstoyke account very soon, so there is no confusion about them. All changes are already merged into the (new) official mogre repository at bitbucket/mogre.

Currently I maintain these repositories (as I created them), but I want to add every other maintainer for Mogre or MogreAddons to it. If you send me your bitbucket username I will also add you to the writers of MogreAddons.

Maintainers will get admin rights to the mogre repositories and other contributors get write access to the repository.

materialDefender

13-07-2010 03:44:35

Would it be okay to have multiple maintainers (i.e. koirat and me) for one add-on, or would it be better to have a single maintainer and other contributors?

In any case, my bitBucket username is materialDefender.

If only one maintainer is allowed per add-on, I leave it up to koirat (if they wish to accept). :D
I think I'd probably make an acceptable maintainer, but I have a bad habit of only getting involved in projects when they don't work for me. :oops:

mstoyke

13-07-2010 11:36:19

I have no problem with 1,2 or 100 maintainers for a project or addon. But I don't like to be babysitting people, so if there are more than one maintainer for a project I want them to organize their work and development without my help. What I want to say is, there can be as much maintainers for anything as there are people willing to help, but if it causes trouble because people can't play in a team very well I will not hesitate to remove peoples access from the projects again.

Don't get me wrong, I never assumed that there will be any problems here. But I've made my experiences in the past, so I think I should communicate my opinions about certain things clearly from the very start...

So, now that this is said, I just added "materialDefender" to writers for mogre/MogreAddons at bitbucket. "koirat" is already added to the writers list since yesterday.

materialDefender

13-07-2010 16:15:57

I understand completely; we will do our best to coordinate our efforts. :D

Thank you for your time!

materialDefender

13-07-2010 21:42:36

Okay, MogreFreeSL is now up-to-date with my modifications on the bitBucket repository, and the wiki entry is up-to-date as well. :D

koirat

13-07-2010 22:48:03

You have mobilized me. I will try to add something tomorrow :).

Pyritie

11-08-2010 16:23:58

Not sure if this is the right thread but is there a way to automatically remove sounds once they've finished playing? (Or at least a way to periodically clean them up?)

Because at the moment I can only play 250 sounds and then after that it won't play anything else. I'm guessing it's because the finished ones aren't being removed or something.

materialDefender

18-08-2010 14:59:02

I haven't tested it myself, but have you tried calling soundManager.RemoveSound(soundObject) once soundObject.IsPlaying() == true?

I'll try to add functionality to MogreFreeSL giving the option of automatic sound deletion on playback finish this evening.


Sorry for the slow reply time, I haven't checked the forums in a while. As MogreFreeSL maintainer, I should really do it more often. :oops:

Pyritie

18-08-2010 16:46:58

Yeah, tried that. Nothing gets deleted, so my guess is that the sounds are still tagged as "playing" even after they've finished making sounds.

Oh and... erm... I kinda switched to Irrklang in the meantime >__> sorry

materialDefender

19-08-2010 00:52:00

Do you actually have more than 250 unique sounds? Or maybe you are using the sounds once and deleting them instead of re-playing them?

In any case, I've fixed the problems you identified in your PM, added a variable to SoundManager that returns the current number of sounds, and I've also set up an auto-delete function. To use it, set destroyAfterPlaying to true after initializing the target SoundObject:

soundObject = soundManager.CreateSoundEntity("noise.ogg", node, node.Name, false, false);
soundObject.destroyAfterPlaying = true;


It's not neccessary to call ShutDown() when you're done, Destroy() automatically does that.


It's okay if you like IrrKlang, I only just started maintaining MogreFreeSL and I won't take it personally. Just know that you can't [legally] sell anything with IrrKlang in it unless you buy IrrKlang Pro.

Pyritie

19-08-2010 00:53:45

No, I'm just creating the sound and then calling .Play(). Isn't that what I was supposed to do?

Thanks for updating this though

materialDefender

19-08-2010 01:12:38

No problem! :D

No, Play() is correct. I just was wondering if you maybe had multiple soundObject instances of the same sound file (i.e. creating a new one every time instead of calling Play() for the pre-existant one). This might not be the case, it was just that I was speculating as to how one could reach over 250 SoundObjects. :shock:

I have now committed the changes to http://bitbucket.org/mogre/mogreaddons.

Pyritie

19-08-2010 12:16:09

Oh lol, yeah I was making a new object for each sound :D

Actually I don't remember seeing anywhere in any documentation that you weren't supposed to do that :0
Though my memory sucks lately so maybe you did have something like that in, I dunno.

einherjer

19-08-2010 19:01:57

Hey everybody,

I'm trying to create an ambient sound from an OGG sound file located in a ZIP container. Loading the ambient sound directly from the file system (without ZIP) works.. I'm using the latest version from bitbucket.

Here is the relevant part of my code:

FSLSoundObject soundObject = FSLSoundManager.Instance.CreateAmbientSound("C:\\Sounds.zip", "Menu.ogg", "MC_Background", true);
soundObject.Play();

This does not work. The sound id is 0 but there is no Exception..

Here is the working code (loading the OGG directly from the file system):

FSLSoundObject soundObject = FSLSoundManager.Instance.CreateAmbientSound("C:\\Menu.ogg", "MC_Background", true, false);
soundObject.Play();



Thank you!

materialDefender

21-08-2010 19:06:31

I'd never tested loading from zip before - I only started using MFreeSL a few weeks ago. Thank you for reporting the error.
It turns out it was loading the sound file but not assigning the resultant ID to the soundID variable. :oops:


The new (fixed & tested) version is now on bitbucket for use.

Good luck in your endeavors! :D

koirat

31-08-2010 16:52:09

I got some bad news...

I was playing a little with MogreFreeSL, made some changes to the source but I have not commited it yet.

The problem is that function (and probably all bool return methods)
like:

public bool IsPlaying(){
return FreeSL.fslSoundIsPlaying( _sound );
}


Are returning always true. (This was mentioned in previous MogreFreeSL topic, I tried to resolve it by adding this attribute but it does not seams to work)
I have to tell you that this one back-stabbed me deeply.
There is no chance of telling if the sound is still playing, also I have not seen any thing like "GetSoundLength" so this problem just can't be resolved.

Also added AutoDelete functionality is not going to work, resulting in memory leak.

mstoyke

31-08-2010 18:58:37

Are returning always true. (This was mentioned in previous MogreFreeSL topic, I tried to resolve it by adding this attribute but it does not seams to work)

Is this a problem of the MogreFreeSL wrapper or the underlying FreeSL library?

materialDefender

01-09-2010 14:27:41

I assume you're referring to the "[return: MarshalAs(UnmanagedType.U1)]" attribute?

I saw the original post about this problem, and I tested for it (or fixed it, I can't remember) before I implemented the AutoDelete function. I didn't run into any problems - IsPlaying() was always accurate when I tested it on August 18th.

I hate to ask this, but are you sure you're using the latest source from the repo and the latest dlls under MogreFreeSL\Libraries? I know there were issues (specifically with streaming) with an older version of OpenAL/FreeSL...


I'll re-check what's on the repository later tonight, to make sure that it is functioning (for me, at least). I'll post with the results.

koirat

01-09-2010 19:24:16

I did not see any:
[return: MarshalAs(UnmanagedType.U1)]
In a source. So if you repaired it it must have been some another way.
I got a source from link you have posted same day as I posted this error.


I have copied all files from Library directory and overwrote my old ones.

I will check on it once again and I hope that it is my fault.

materialDefender

02-09-2010 05:07:01

I was unable to reproduce your issue. :(
I re-compiled MogreFreeSL from the repository source against Mogre 1.7.1 and tested it in my project. I'm using Visual C# 2008 Express Edition on Windows Vista Basic.

Here is my implementation:

//In Global variable declaration
FSLSoundManager smgr = FSLSoundManager.Instance;
FSLSoundObject soundobject;

//In variable initialization, etc.
root.FrameStarted += new Mogre.FrameListener.FrameStartedHandler(smgr.FrameStarted);
smgr.InitializeSound(FreeSL.FSL_SOUND_SYSTEM.FSL_SS_EAX2 ,cam);
soundobject = smgr.CreateSoundEntity("sounds.zip", "sound.ogg", node, name, false);
smgr.GetListener().ZFlipped = true;

//In a keypress handler
soundobject.Play();

//In a different keypress handler
MessageBox.Show(soundobject.IsPlaying().ToString());


When I pressed the MessageBox.Show() key before and after the sound played, it showed "false." When I pressed it while the sound was playing, it showed "true."

Any guesses as to why you're having this issue, when I'm not?


On the subject of "[return: MarshalAs(UnmanagedType.U1)]," when you said (This was mentioned in previous MogreFreeSL topic, I tried to resolve it by adding this attribute but it does not seams to work)
I thought you were referring to a post I found which suggested adding "[return: MarshalAs(UnmanagedType.U1)]" to fix IsPlaying() issues. I have never tested it, as I haven't had any problems with IsPlaying().

koirat

02-09-2010 10:29:09

Fortunately shame on me :| .
Yes it is working I have tested it again I have got a bug in my owe application.
Sorry for this disinformation and all the work you had to do to prove me wrong.
As an recompense I will add something useful to the source. :)

Btw. I see MogreFreeSL source is using VS different than 2008.
I do not want to make it inaccessible for you so I'm going to add code files without changing project file.
I would tell you when I'm done so you can grab it and include additional *.cs files to the project.

materialDefender

02-09-2010 13:00:19

That's alright, it only took a few minutes to test it out. I'm glad it all worked out, though!


I can't wait to see what the addition shall be... :D

koirat

03-09-2010 10:53:42

I have committed some changes. To make the long story short, I think that we should decouple MogreFreeSL from Mogre and make it just ManagedFreeSL.

I have added events when sound is removed.
Now not only camera can be a listener.
Sound position can be something different than Mogre.Node

I left methods with parameters of type Mogre.Node Mogre.Camera be I think that we should remove them also.

If you are not using frame listener but your own updater just don't forget to call Update instead of UpdateSoundObjects.
Update is a new method that calls (UpdateListener UpdateSoundObjects), you can update camera or sounds if you want with this methods.

btw:
If I did not call FreeSL.fslSetAutoUpdate(true);
my sound was played two times and after another tries it did not work (silence)
I heard about some issues with streaming but i did not use streaming. I just hope this are again my delusions and it's not that I broke something.

I did not commit VS solution files so do not forget to add new files to the project before compiling.


Added:
SoundObjectsCollection property (read only collection of contained sounds)
SoundRemoved event (to FSLSoundObject and FSLSoundManager)
IsSoundRemoved property
FSLSoundRemovedEventArgs (FSLSoundManager SoundRemoved event args)
IFSLPositionProvider IFSLOrientationProvider (providers for sound position and orientation)
MogrePositionProvider (Mogre Vector3 based position provider)
IFSLListener (Mogre indepandant listener for ears)
MogreCameraFSLListener (Implementation of IFSLListener for Mogre.Camera)
Update() (calls UpdateListener and UpdateSoundObjects) use it instead of UpdateSoundObjects

Deleted:
FSLListener now this is done by IFSLListener
FSLSoundEntity all this functionality now cen be done via FSLSoundObject


Thinking about:
Deleting FSLAmbientSound (It could be done by FSLSoundObject also)
Making MogreFreeSL just ManagedFreeSL completly decupling it from Mogre.
Added files not starting with IFSL or FSL are just to provide easy integration into Mogre.

mstoyke

04-09-2010 01:09:48

I have committed some changes. To make the long story short, I think that we should decouple MogreFreeSL from Mogre and make it just ManagedFreeSL.
This sounds OK for me, if it will still be possible to use if with Mogre without hassle. Maybe split it up into the managed FSL part and a second module that provides the connection to Mogre entities. It is, at the moment, the only sound library I know that is really easy to use with Mogre, so if the changes make it more complex for users to use it with Mogre it would be a big disadvantage to change it in this way.

koirat

04-09-2010 16:41:10


Maybe split it up into the managed FSL part and a second module that provides the connection to Mogre entities.


Exactly, I have made some preparations already. It's just that I want to have some green light from community. After all It's not going to be possible to initialize FSLSoundManager by directly passing a camera to it. Or directly place sound by the Node position. So it is not perfectly painless switch.

What we can do is to prepare MFSLMogreHelper.dll (It is almost done, I just need to separate it from the current source)

this library will have:
MFSLMogreHelper.InitializeSound(... , Mogre.Camera camera);
MFSLMogreHelper.CreateSound(... ,..., Mogre.Node node );


Additional advantage to this is that you will not have to recompile FreeSL wrapper when something in ogre changes or when rebuilding Mogre. (like it was before)
Helper is a different story, but it will be very small so you can even include it into your source.

materialDefender

08-09-2010 14:19:56

Sorry for my absence over the last five days, I've been a bit under the weather. :(

I haven't finished looking through all of your updates yet, but it looks like you ended up adding [return: MarshalAs(UnmanagedType.U1)] to the call of fslSoundIsPlaying. Was this neccessary for you? As I said before, I've never had any issues with fslSoundIsPlaying.

Until we can go through and update the tutorial (assuming that will be neccessary with MFSLMogreHelper.dll), I'm going to direct Wiki users to the version of MogreFreeSL that matches the instructions.

I like how things are looking so far! I'll it all out tonight if I have time. :D

koirat

08-09-2010 14:35:55

[return: MarshalAs(UnmanagedType.U1)]
No I just forgot to delete it.

materialDefender

13-09-2010 03:10:38

I'm afraid I've been a bad joint maintainer of late, and I'm afraid that will have to go on a little longer. :oops:

I've been really swamped with work lately, and any time I have for programming, etc. goes towards my own projects...hopefully I'll have more time soon.


Until then, I trust your judgement! :D

koirat

13-09-2010 10:48:21

I was even worst :P.
I will try to find some time these week to completely decouple Mogre from MogreFreeSL and change wiki page.

fletch27502

22-09-2010 19:25:20

I using Visual Studio 2010 and the Mogre 1.7.1 release with .net 4, and I'm getting a strange error when attempting to Init the Sound Library.

if ( !FreeSL.fslInit( soundSystem ) )

is giving me a PInvokeStackImbalance Error.

PInvokeStackImbalance was detected
Message: A call to PInvoke function 'FSLOgreCS!FSLOgreCS.FreeSL::fslInit' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

I checked the FreeSl.dll that I'm using and the dll import declaration in the FreeSl class and everything seems ok. Any ideas what could be causing this?

TIA,
Scott

burns

04-11-2010 15:02:19

We had a windows update come through, and since then, about half our sounds seem to be acting very weird.

For example:
We have an automatic sliding door in our app. When the camera or a character it opens and loops a sliding sound ("Slide"). When it gets all the way open, the Slide is removed, and we create and play a clunk sound ("Clunk"). When the character moves away, the door closes, removing Clunk and creating and looping Slide.

This all worked fine before the windows update, but now, once we remove Slide and create Clunk, Slide will no longer play at any point in the future. It appears to be created and Play() fine, with no errors . . . just no sound comes out.

If I switch the logic for Clunk and Slide (so the door loops Clunk while opening and plays Slide once upon reaching the open state), Clunk loops fine always, but Slide does not play at the end. So, there must be something about the sound files themselves (not when and where or how they are played) that determines which will play again and again and again, and which will only play the first time. But we haven't figured out what that difference could be.

If we revert back to the previous version of Mogre Free SL, the problem goes away (every sound plays fine).

Does anybody have any clue what could be going on?

P.S. I believe the 3D sound calculation uses the Camera's Position (with respect to parent) instead of its RealPosition (look at FSLSoundManager.UpdateListener() on line 176 as opposed to MogreCameraFSLListener.Update() on line 31 . . . I believe the former is called, but the latter is not). As a result, the sound doesn't update properly if its the Camera's parent that is moving.

P.P.S. Thank you for maintaining this nice piece of software!

burns

04-11-2010 17:15:26

Oh, and we are using the following sound system:

FSL_SS_DIRECTSOUND3D

(though the same behavior appears regardless of which sound system . . . with the exception of NOSOUND, of course)

koirat

04-11-2010 20:23:59

@burns

Do you have
FreeSL.fslSetAutoUpdate(true);

Are you compiling this wrapper from source ?
This might not be very stable since I did not have a time to look further into it. And I did not know that it's still on the SVN.

Since materialDefender wrote

Until we can go through and update the tutorial (assuming that will be neccessary with MFSLMogreHelper.dll), I'm going to direct Wiki users to the version of MogreFreeSL that matches the instructions.


It looks like I will have to take a look at it soon.

burns

05-11-2010 15:45:21

No, we don't have

FreeSL.fslSetAutoUpdate(true);

We instead, call

FSLSoundManager.FrameStarted(..) from our own OnFrameStarted(..) callback function for Mogre's Root.FrameStarted event.

Yes, we're compiling the wrapper from (what we thought was the latest) source. Is there a release version of the source we should be grabbing from?

burns

05-11-2010 17:01:42

It appears calling RemoveSound(..) was causing some future CreateSoundEntity(..) calls to fail to load the sound (if we changed the code to try to load it twice, it always worked the second time). We fixed the problem in our code by removing out calls to RemoveSound(..). Now, as new sounds get loaded, they all get saved in a Dictionary until the object is destroyed at which point it calls RemoveSound(..) on them all.

And everything seems to work now. :)

mertainer

08-11-2010 16:02:07

I using Visual Studio 2010 and the Mogre 1.7.1 release with .net 4, and I'm getting a strange error when attempting to Init the Sound Library.

if ( !FreeSL.fslInit( soundSystem ) )

is giving me a PInvokeStackImbalance Error.

PInvokeStackImbalance was detected
Message: A call to PInvoke function 'FSLOgreCS!FSLOgreCS.FreeSL::fslInit' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

I checked the FreeSl.dll that I'm using and the dll import declaration in the FreeSl class and everything seems ok. Any ideas what could be causing this?

TIA,
Scott


I'm having the exact same problem, any hints on how to fix this?

burns

17-11-2010 21:42:51

I'm going to have to take back what I wrote in the following post. Though that fix worked fine on my machine and my co-worker's, it didn't on our QA machine. But we found that if the call in FSLSoundObject.SetSound(..) to FreeSL.fslLoadSound( soundFile ) returned 0 . . . we could just call it again immediately, and it would succeed. So, that's what we did.

The issue on the QA machine seemed to be related to having too many sounds (a sound card memory issue? I haven't a clue), so after every sound stopped playing, we removed it immediately. It's a lot of unnecessary loading and unloading . . . but it's what made it all work. :)

It appears calling RemoveSound(..) was causing some future CreateSoundEntity(..) calls to fail to load the sound (if we changed the code to try to load it twice, it always worked the second time). We fixed the problem in our code by removing out calls to RemoveSound(..). Now, as new sounds get loaded, they all get saved in a Dictionary until the object is destroyed at which point it calls RemoveSound(..) on them all.

And everything seems to work now. :)

Meharin

21-03-2011 18:08:23

I using Visual Studio 2010 and the Mogre 1.7.1 release with .net 4, and I'm getting a strange error when attempting to Init the Sound Library.
if ( !FreeSL.fslInit( soundSystem ) )
is giving me a PInvokeStackImbalance Error.


This is happening to me too. (I'm using latest Mogre checkout from build instructions.)

Meharin

06-05-2011 01:35:30

Hi guys!
Just letting you (koirat and materialDefender) know that I sent you a "pull request" via bitbucket regarding a fix for a stack imbalance exception.
See http://www.ogre3d.org/addonforums/viewtopic.php?f=8&t=14334.

materialDefender

08-05-2011 04:07:42

Ugh, I really haven't been a very good maintainer. In any case, Meharin's stack imbalance fix has been pushed to the main MogreAddons branch.

I've enabled reply notifications on this thread now, so I'll see this stuff in the future instead of just when I get pull requests. :oops:

Thank you Meharin!

materialDefender

08-10-2011 22:38:30

I've just pushed some fairly extensive restructuring of MogreFreeSL to BitBucket. Most of the changes concern more logical structuring and naming conventions. I also added a demo. I will update the Wiki shortly.

If you experience any troubles with the new version, please post in this thread.

Rough changelog:
Changed instances of "FSLOgreCS" to "MogreFreeSL" for more clarity, got rid of "FSL" prefix on classes.
Implemented functions wrapped under "FreeSL" class in "SoundManager."
Separated "SoundEntity" and "AmbientSound" lists in "SoundManager" to fix interface issues.
Changed accessibility levels of many classes and methods.
Added "Demo."

materialDefender

09-10-2011 19:27:27

The Wiki's updated, and I just pushed another update. It's a minor one, the only difference being the change of two method names and a short readme for the demo, but if you downloaded it yesterday you may want to update now to prevent future confusion.

Here are a few pointers for upgrading to the new version, if anyone needs it:

Use AmbientSound and SoundEntity instead of SoundObject:
  1. FSLSoundObject sound = smgr.CreateAmbientSound(); becomes AmbientSound sound = smgr.CreateAmbientSound()[/list:u]
    Remove any (AmbientSound) or (SoundEntity) casts:
    1. ((FSLSoundEntity)soundEntity).SetReferenceDistance(5); becomes soundEntity.SetReferenceDistance(5);[/list:u]
      Remove "FSL" from the start of any class names:
      1. FSLSoundManager becomes SoundManager
        FSLAmbientSound becomes AmbientSound
        etc.[/list:u]
        Remove any instances of the following, as they are now done by SoundManager.Instance.InitializeSound()
        1. FreeSL.fslSetAutoUpdate(true);
          FSLSoundManager.Instance.GetListener().ZFlipped = true;[/list:u]
          Change all references to FreeSL. The FreeSL class has been made internal, and all functions it contained are available through the SoundManager:
          1. FreeSL.fslSoundSetSpeedAllSounds(.5f); becomes SoundManager.Instance.SetSpeedAllSounds(.5f);
            FreeSL.FSL_SOUND_SYSTEM becomes FSL_SOUND_SYSTEM
            etc.[/list:u]

            Please note that you may now access the SoundManager's sounds by index. You can now, for example, cycle through all of the SoundManager's sounds:
            for(int i =0; i < smgr.NumberOfAmbientSounds; i++)
            {
            smgr.GetAmbientSound(i);
            }


            Last time I said to post if you had any issues, but please post if you have any suggestions or comments as well. I know some of the IntelliSense documentation isn't very helpful, as I do not actually know what some of the functions and enumerations do. I'll try to update that as I work with the library.