Jump to content
  • Advertisement
Sign in to follow this  
ferr

FMOD Problem

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Sound stops activating after a short amount of time, here's some pseudo-code: if user presses the W key { ... move the player forward ... //play walking sound handle = FSOUND_Stream_Open("step2.ogg",0, 0, 0); if(!FSOUND_IsPlaying(1)) { FSOUND_Stream_Play(1,handle); } } It works correctly for about 6 or so steps then suddenly does nothing. any help? I also have music playing, and it continues to play after the walking sounds cease, so it's not as if FMOD stops working entirely edit: I just did some further testing, I loaded up the program and let it sit there for about a minute, then tried to walk around and no walking sound activated. i set a debug mark on the line with "FSOUND_Stream_Play(1,handle);" and after waiting about a minute before hitting W it doesn't throw back to debug! what the hell is going on? nothing else should be in channel 1 (the other music is in channel 2, btw.) [Edited by - ferr on August 18, 2005 2:55:04 PM]

Share this post


Link to post
Share on other sites
Advertisement
This is just a guess, but maybe it doesn't like the fact that you are opening so many streams. Try loading the sound into a single sample, or stream, at load time and do what you are doing at the moment. You might want to catch all the return vars and check which one fails, the load or the play function.

Share this post


Link to post
Share on other sites
Quote:
Original post by stro
This is just a guess, but maybe it doesn't like the fact that you are opening so many streams. Try loading the sound into a single sample, or stream, at load time and do what you are doing at the moment. You might want to catch all the return vars and check which one fails, the load or the play function.


Nice guess! That solved the problem.

Share this post


Link to post
Share on other sites
It seems that only semi-fixed it. The stepping sound still seems to cut off.. just lasts a little longer now.

I have the open stream setup in an Initialization function that only gets called once and my movement calls are pretty much the same.. if channel isn't being used, use it.

Has anyone here used FMOD? Is this a proper method for playing something like a movement sound:
...
//if player presses W

if(!FSOUND_IsPlaying(1))
{
FSOUND_Stream_Play(1,walkHandle);
}
...

I just messed around some with it, when I press W every 2 seconds (letting the sound go through its course) I can get it to play as many times as I like, but when holding down W (in other words, I'm hitting the if statement on EVERY frame) it quits after about 8 or so steps. Does the FMOD API just not like being called upon so often? I don't think it could be that, though.. I have FMOD playing music also, and its if statement to check if it's done playing is hit on every frame.. and it has never quit, I've had it playing for 10-15 minutes at a time without a problem..

..so FMOD has no problem with being hit constantly in one instance (music) and it has no problem playing a sound stream over and over in another instance (not holding down W) ...any help?

edit: Strange solution.. I looked at Task Manager and noticed Firefox was using up about 50% CPU, so I closed it and now sounds work perfectly in the game.. what the hell?

[Edited by - ferr on August 18, 2005 3:16:45 PM]

Share this post


Link to post
Share on other sites
Here is what I do in my playsound function. I let fmod choose an open channel, and store it for later. Then I have an updatesounds() function that I call that checks for finished sounds and frees them so the channels can be reused.


size_t Sound::Mgr::PlaySound( const std::wstring& name,
const float32& volume,
const uint8& priority )
{
if ( IsDisabled() )
{
return false;
}

FSOUND_SAMPLE* pSample = 0;

if ( g_pApp->GetSampleMgr().FindItemByName( name, pSample ) )
{
Sound::Instance anInstance;

anInstance.mID = mIDGen.GenerateID();

anInstance.mType = Type_Normal;

anInstance.mSoundName = name;

anInstance.mChannel = FSOUND_PlaySoundEx( FSOUND_FREE, pSample, 0, true );

if ( anInstance.mChannel != Sound::InvalidChannel )
{
anInstance.mSourceID = Obj::INVALID_ID;

FSOUND_SetVolume( anInstance.mChannel, min( 255, max( 0, (uint8)( volume * 255.0f ) ) ) );

FSOUND_SetPriority( anInstance.mChannel, priority );

mInstances[ anInstance.mID ] = anInstance;

UpdateInstance( anInstance );

FSOUND_SetPaused( anInstance.mChannel, false );

return anInstance.mID;
}
}
return 0;
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!