New FMOD SoundManager available in Wiki
-
- Gnome
- Posts: 349
- Joined: Tue Jul 05, 2005 2:51 pm
- Location: Connecticut, USA
New FMOD SoundManager available in Wiki
It's a work in progress, but it's functional now.
http://www.ogre3d.org/wiki/index.php?ti ... undManager
Feedback welcome.
http://www.ogre3d.org/wiki/index.php?ti ... undManager
Feedback welcome.
-
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
-
- Kobold
- Posts: 36
- Joined: Mon Nov 14, 2005 11:40 am
- Location: Verona, Italy
-
- Gnome
- Posts: 349
- Joined: Tue Jul 05, 2005 2:51 pm
- Location: Connecticut, USA
-
- Kobold
- Posts: 36
- Joined: Mon Nov 14, 2005 11:40 am
- Location: Verona, Italy
I tried the SoundManager yesterday. Very useful, thanks I found a minor problem with the stdafx.h. It includes the mmsystem.h ( or something like this I don't remember the header file name exactly sorry) which defines a PlaySound function that conflict with SoundManager::PlaySound. It raised a Link error. Probably I forget to do something, but I comment out the #include stdafx.h and all works fine.
Very nice work DrPain, thanks a lot.
Very nice work DrPain, thanks a lot.
-
- Kobold
- Posts: 36
- Joined: Mon Nov 14, 2005 11:40 am
- Location: Verona, Italy
-
- Gnome
- Posts: 349
- Joined: Tue Jul 05, 2005 2:51 pm
- Location: Connecticut, USA
Hmmm.. I've just really started using it myself. I'll have to look into that.
I'm working on fixing a crash issue at the moment (I believe unrelated to this manager), but after that's resolved, I'll take a look at it.
Anyone know if that feature is a CPU hog?
I do have a new version to upload. But I want to resolve the crash issue first to make sure it's really not a SoundManager problem.
I'm working on fixing a crash issue at the moment (I believe unrelated to this manager), but after that's resolved, I'll take a look at it.
Anyone know if that feature is a CPU hog?
I do have a new version to upload. But I want to resolve the crash issue first to make sure it's really not a SoundManager problem.
-
- Gnoll
- Posts: 699
- Joined: Sun Jan 02, 2005 5:45 pm
- Location: Velbert, Germany
- x 2
Maybe you could replace your hard-coded access code with this (You assume a fixed resource group and the code is limited to plain file access, as discussed in another thread):
It still avoids the full scale solution with defining an own ResourceManager and Resource class, so it isn't able to precache the sample. At least it can read the files from all supported backends. Initialize it after the init call with:
Declarations (For copy and paste):
Sorry, if there are any typos, I ripped the code out of my source code, which handles the rest a bit different.
Code: Select all
FMOD_RESULT F_CALLBACK SoundManager::FModOpen(const char *pFilename,int bUnicode,unsigned int *pFileSize,void **ppHandle,void **ppUserData)
{
try
{
Ogre::String *pGroup = new Ogre::String(Ogre::ResourceGroupManager::getSingleton().findGroupContainingResource(pFilename));
Ogre::DataStreamPtr dataStreamPtr = Ogre::ResourceGroupManager::getSingleton().openResource(pFilename,*pGroup);
if(dataStreamPtr.isNull() == true)
return FMOD_ERR_FILE_NOTFOUND;
(*pFileSize) = dataStreamPtr->size();
(*ppHandle) = new Ogre::DataStreamPtr(dataStreamPtr);
(*ppUserData) = pGroup;
dataStreamPtr.setNull();
}
catch(Ogre::Exception e)
{
return FMOD_ERR_FILE_NOTFOUND;
}
return FMOD_OK;
}
FMOD_RESULT F_CALLBACK SoundManager::FModClose(void *pHandle,void *pUserData)
{
Ogre::DataStreamPtr streamFMod = (*((Ogre::DataStreamPtr *) pHandle));
streamFMod->close();
delete (Ogre::String *) pUserData;
delete (Ogre::DataStreamPtr *) pHandle;
return FMOD_OK;
}
FMOD_RESULT F_CALLBACK SoundManager::FModRead(void *pHandle,void *pBuffer,unsigned int nSize,unsigned int *nRead,void *pUserData)
{
Ogre::DataStreamPtr streamFMod = (*(Ogre::DataStreamPtr *) pHandle);
(*nRead) = streamFMod->read(pBuffer,nSize);
if((*nRead) != nSize)
return FMOD_ERR_FILE_EOF;
return FMOD_OK;
}
FMOD_RESULT F_CALLBACK SoundManager::FModSeek(void *pHandle,unsigned int nPosition,void *pUserData)
{
Ogre::DataStreamPtr streamFMod = (*(Ogre::DataStreamPtr *) pHandle);
streamFMod->seek(nPosition);
return FMOD_OK;
}
Code: Select all
pSystem->setFileSystem(FModOpen,FModClose,FModRead,FModSeek,2048);
Code: Select all
static FMOD_RESULT F_CALLBACK FModOpen(const char *,int,unsigned int *,void **,void **);
static FMOD_RESULT F_CALLBACK FModClose(void *,void *);
static FMOD_RESULT F_CALLBACK FModRead(void *,void *,unsigned int,unsigned int *,void *);
static FMOD_RESULT F_CALLBACK FModSeek(void *,unsigned int,void *);
-
- Gnoblar
- Posts: 14
- Joined: Wed Mar 15, 2006 4:05 am
I think in SoundManager.cpp in CreateSound it should be
where FMOD_3D and FMOD_HARDWARE are added. Just because a sound isn't looped doesn't mean it shouldn't have 3D effects.
Also, I am having a wierd bug with the channels it seems. When I play too many sounds too quickly my program crashes. It seems to me that it takes a bit before the manager decides a channel is not needed anymore and if the channels fill up (to 32?) there is a crash.
Hopefully this thread isn't dead.
Code: Select all
case SOUND_TYPE_3D_SOUND:
{
result = system->createSound(fileName.c_str(), FMOD_DEFAULT | FMOD_3D | FMOD_HARDWARE, 0, &sound);
break;
}
Also, I am having a wierd bug with the channels it seems. When I play too many sounds too quickly my program crashes. It seems to me that it takes a bit before the manager decides a channel is not needed anymore and if the channels fill up (to 32?) there is a crash.
Hopefully this thread isn't dead.
Last edited by Isomorphic on Thu Mar 16, 2006 2:49 pm, edited 1 time in total.
-
- Gnoblar
- Posts: 14
- Joined: Wed Mar 15, 2006 4:05 am
Alright, I fixed the bug, not that I am really sure what was causing it. In
SoundManager::PlaySound(int soundIndex, SceneNode *soundNode, int *channelIndex)
This *channelIndex should equal -1 when it is an invalid sound channel, but for some reason, instead it equals some large number, which is the same during the run, but changes from reboot to reboot. So now, it does a quick check to see if the number is in the proper channel range.
SoundManager::PlaySound(int soundIndex, SceneNode *soundNode, int *channelIndex)
This *channelIndex should equal -1 when it is an invalid sound channel, but for some reason, instead it equals some large number, which is the same during the run, but changes from reboot to reboot. So now, it does a quick check to see if the number is in the proper channel range.
Code: Select all
if ((*channelIndex < 0) || (*channelIndex >= MAX_SOUND_CHANNELS)) *channelIndex = INVALID_SOUND_CHANNEL;
-
- Gnome
- Posts: 349
- Joined: Tue Jul 05, 2005 2:51 pm
- Location: Connecticut, USA
Sorry for the long delay. I've been immersed in other areas of code and am just getting back around to this.
SunSailor -
I'm actually toying with your idea of making the SoundManager a full-blown resource manager. It'll probably be a few weeks before I can get to that, but I am leaning more that way at the moment.
Isomorphic -
I've tried all kinds of scenarios to get it to crash with no luck.
Are you initializing the channelIndex to INVALID_SOUND_CHANNEL as instructed in the Wiki?
SunSailor -
I'm actually toying with your idea of making the SoundManager a full-blown resource manager. It'll probably be a few weeks before I can get to that, but I am leaning more that way at the moment.
Isomorphic -
I've tried all kinds of scenarios to get it to crash with no luck.
Are you initializing the channelIndex to INVALID_SOUND_CHANNEL as instructed in the Wiki?
-
- Gnoll
- Posts: 603
- Joined: Thu Jul 28, 2005 4:11 pm
- Location: Nice, France
- x 35
-
- Gnoblar
- Posts: 1
- Joined: Mon Apr 10, 2006 7:13 pm
- Location: Sweden
-Mikachu
FMOD supports several effects (DSP). Here's how to add an echo effect to a channel.
Where dspecho has been defined as
The effect can then be changed using setParameter:
FMOD supports several effects (DSP). Here's how to add an echo effect to a channel.
Code: Select all
FMOD_RESULT result;
result = channel->addDSP(dspecho);
ERRCHECK(result);
Code: Select all
FMOD::DSP *dspecho = fmodSystem->createDSPByType(FMOD_DSP_TYPE_ECHO, &dspecho);
Code: Select all
result = dspecho->setParameter(FMOD_DSP_ECHO_WETMIX, 0.3f);
ERRCHECK(result);
-
- Gnome
- Posts: 349
- Joined: Tue Jul 05, 2005 2:51 pm
- Location: Connecticut, USA
The SoundManager now supports loading from Archive files (zip files, or theoretically any other ResourceManager supported format).
This is brand new code. It has been tested, but not a lot.
But I figured it's better to get it out there and have the masses bang on it and report any problems.
A bug in PlaySound() was fixed that would prevent the same sound from re-playing when in the same sceneNode.
This is brand new code. It has been tested, but not a lot.
But I figured it's better to get it out there and have the masses bang on it and report any problems.
A bug in PlaySound() was fixed that would prevent the same sound from re-playing when in the same sceneNode.
-
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
This is appreciated!
Thank you for your numerous contributions so far!
Thank you for your numerous contributions so far!
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Halfling
- Posts: 52
- Joined: Sat Jan 22, 2005 8:44 pm
Hi!
As I'm still looking for a working sound manager I tried your's ... but it won't compile...
'syntax error 'constant' ' is pointing to the header's 'using namespace Ogre;'
I don't get it....
As I'm still looking for a working sound manager I tried your's ... but it won't compile...
the------ Build started: Project: Ogre_simpleSurround, Configuration: Release Win32 ------
Compiling...
Ogre_simpleSurround.cpp
d:\VS2005 Projects\Ogre_simpleSurround_FMOD\Ogre_simpleSurround\include\SoundManager_FMOD.h(12) : error C2059: syntax error : 'constant'
d:\VS2005 Projects\Ogre_simpleSurround_FMOD\Ogre_simpleSurround\include\SoundManager_FMOD.h(29) : error C2146: syntax error : missing ';' before identifier 'fileName'
d:\VS2005 Projects\Ogre_simpleSurround_FMOD\Ogre_simpleSurround\include\SoundManager_FMOD.h(29) : error C4430: missing type specifier - int
(...)
Build log was saved at "file://d:\VS2005 Projects\Ogre_simpleSurround_FMOD\Ogre_simpleSurround\obj\Release\BuildLog.htm"
Ogre_simpleSurround - 182 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
'syntax error 'constant' ' is pointing to the header's 'using namespace Ogre;'
I don't get it....
Better to reign in hell than serve in heaven
-
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
Looks like we should add a line before the using namespace Ogre line:
Code: Select all
#include <ogre.h>
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Halfling
- Posts: 52
- Joined: Sat Jan 22, 2005 8:44 pm
-
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
I had to insert an #include <windows.h> just before the include <ogre.h>.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Halfling
- Posts: 52
- Joined: Sat Jan 22, 2005 8:44 pm
-
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
Make sure that you are using the newest FMOD.
It works perfectly here. Provided that you are using it in an OGRE application.
It works perfectly here. Provided that you are using it in an OGRE application.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Halfling
- Posts: 52
- Joined: Sat Jan 22, 2005 8:44 pm
I downloaded FMOD just yesterday.... Ogre is 1.2.0
.. it's just, that something goes wrong with the namespace thing.
When including ogre.h in the soundmanager.h the header compiles fine .... but then VS gives me a syntax error : 'constant' at OgrePlatform.h right were Ogre namespace is defined ( namespace Ogre { )
including windows.h in the soundmanager.h didn't make a change...
----
ARGHH! silly me!
I renamed the SoundManager.h to SoundManager_FMOD.h ... and forgot to rename the cpp file as well.
.. it's just, that something goes wrong with the namespace thing.
When including ogre.h in the soundmanager.h the header compiles fine .... but then VS gives me a syntax error : 'constant' at OgrePlatform.h right were Ogre namespace is defined ( namespace Ogre { )
including windows.h in the soundmanager.h didn't make a change...
----
ARGHH! silly me!
I renamed the SoundManager.h to SoundManager_FMOD.h ... and forgot to rename the cpp file as well.
Better to reign in hell than serve in heaven
-
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
This kind of thing happens all the time - and we are spending way too much time on such stupid mistakes, because we think the problem is bigger than that.Katzenjoghurt wrote:ARGHH! silly me!
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Gargoyle
- Posts: 1092
- Joined: Wed Nov 09, 2005 12:56 pm
- Location: Adelaide, Australia
-
- Halfling
- Posts: 52
- Joined: Sat Jan 22, 2005 8:44 pm
... oh well... I better shouldn't tell you that I'm a computer science student in his 6th year. Nah. I rather keep this for me.
...and it goes on and on. (yeah ... as if shame wouldn't be big enough already.... I'm stuck once more)
The sources compile now, but the test program crashes when calling
in this line of SoundManager.cppnightLoop = soundMgr->CreateSound(String("whatsdiversity.wav"));
The wav is in the exe Folder. I tried the full path as well.... but I keep getting the same unhandled exception.... no matter if I type in a nonsense filename or the filename of any existing wav.int SoundManager::FindSound(String &fileName, SOUND_TYPE soundType)
{
int vectorIndex;
int vectorCapacity;
SoundInstance *nextSoundInstance;
=> vectorCapacity = soundInstanceVector->capacity(); <=
Anyone had this crash as well?
Better to reign in hell than serve in heaven