0
0

I just want to make sure that I’m using streams correctly because they don’t seem to be fading out like they should. Before they were streams they faded out as expected, so I’m probably missing something here. I’m using FMOD designer and the event system BTW.

On PC, I do something like the following (pseudo-code):

[code:jf4v9jgs]
FMOD::Memory_Initialize()
FMOD::EventSystem_Create()
EventSystem::init()
EventSystem::setMediaPath()
[/code:jf4v9jgs]

then

[code:jf4v9jgs]
EventSystem::load()
EventProject::getEventByProjectID()
Event::setCallback()
[/code:jf4v9jgs]

then in the event callback

[code:jf4v9jgs]
switch( EVENT_CALLBACKTYPE )
case EVENT_CALLBACKTYPE_SOUNDDEF_CREATE:
{
System::createStream()
System::playSound()
}
case EVENT_CALLBACKTYPE_EVENTFINISHED:
{
channel_that_sound_played_on->stop()
}
[/code:jf4v9jgs]

Is this the correct way of stopping a stream? I couldn’t find this information in the documentation.

update:

Yes, I’m most definitely doing something wrong.

My test app loads our game gui and plays some gui music. When the level is loaded, I stop the gui music and start the level’s ambiance track.

When I try bringing up the in-game GUI (which plays the same gui music) , I get the following error on the PSP when trying to create another stream to start the gui music back up.

[code:jf4v9jgs]FMOD: CodecAT3::openInternal : Error. Out of ATRAC handles! Reduce simultaneous AT3s or switch from AT3PLUS to AT3.[/code:jf4v9jgs]

So it seems pretty appearant that I need to close my stream or possibly in this case check to see if I have already created the stream. For the sake of play many different streams in the future in-game, what is the correct way to stop and close a stream?

Thanks!

  • You must to post comments
0
0

In EVENT_CALLBACKTYPE_SOUNDDEF_CREATE you only need to create an FMOD::Sound, you shouldn’t play it. Also you’ll need a corresponding EVENT_CALLBACKTYPE_SOUNDDEF_RELEASE in which you should release the FMOD::Sound. These callbacks are only for creating and releasing sounds, not playing them. FMOD will take care of the playing and stopping.

EVENT_CALLBACKTYPE_EVENTFINISHED is called after an event has been stopped so you don’t need to do any stopping yourself here either.

  • You must to post comments
0
0

Hrmm…Ok I’ve tried what you said (removing the play and stop) and adding the call to release, but now the sound never plays.

Here’s the body of my callback:

[code:u72w9fht]
AUDIO_RESULT AUDIO_CALLBACK MenuMusic_Callback( OAudioEvent* event, AUDIO_EVENT_CALLBACKTYPE type, void* param1, void* param2, void* param3)
{
event;
param2;

AUDIO_RESULT result = AUDIO_OK;

switch (type)
{
case AUDIO_EVENT_CALLBACKTYPE_SOUNDDEF_CREATE:
{
OPath* sAssetPath = gGameAssetDrive->GetCurrentDirectory();
if ( !sAssetPath || sAssetPath->PlatformPath().Length() == 0 )
{
gLog.Error(cLogAudio, "MenuMusic_Callback() Failed to retrieve game asset drive path.\n");
return result;
}

     OString filename;
     filename.sprintf("%s\\Audio\\%s.ogg", sAssetPath->PlatformPath().c_str(), (char *)param1);

     // Try creating the ogg stream
     result = gAudio.CreateStream(filename.c_str(), (AUDIO_HARDWARE | AUDIO_LOOP_NORMAL), &mGuiMusicSound);
     gAudio.ErrorCheck(result);

     break;
  }
  case AUDIO_EVENT_CALLBACKTYPE_SOUNDDEF_RELEASE:
  {
     mGuiMusicSound->release();
     break;
  }
  default:{}

}

return result;
}
[/code:u72w9fht]

  • You must to post comments
0
0

You need to pass the Sound * you created back to FMOD as specified in the docs for Event::setCallback() e.g.

[code:2coa9nrz]case FMOD::EVENT_CALLBACKTYPE_SOUNDDEF_CREATE :
{
char *name = (char *)param1;
int entryindex = *((int *)param2); // it’s a sounddef entry index on entry
FMOD::Sound **s = (FMOD::Sound **)param2; // and we return our Sound * through it on exit

result = sys->createSound(name, FMOD_2D | FMOD_SOFTWARE, 0, s);
if (result != FMOD_OK)
{
    return result;
}

break;

}
[/code:2coa9nrz]

  • You must to post comments
0
0

Ok thanks for clearing that up. It works as expected now on the PC.

I do have a couple of questions though. It only works if I specify FMOD_SOFTWARE. Is there a way to get the FMOD_MODE set for that event to be used when creating the stream? It feels strange to have to specify this in code, but maybe that’s standard procedure.

Also, this change does not fix the problem on the PSP. Is there something else I’m supposed to do that applies only to the PSP platform? I’m playing between two ATRAC3 files (the GUI music and the level ambient) on the PSP whereas that’s two ogg files on the PC.

Thanks!

  • You must to post comments
0
0

Currently yes, you do have to specify the whether it’s FMOD_HARDWARE or FMOD_SOFTWARE. As for PSP, atrac3 is not supported in software so use FMOD_HARDWARE for that.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.