0
0

Hello!

We have a problem with the keyOff function in the code in C#.
We have an event with start-cycle-stop sounds and a sustain point. The event works perfectly in both Designer, Sandbox and Event Player but when we try to use the keyOff function in code it just stops/cuts the event. In other words "key off" behaves as though we had called for "stop event".

Grateful for any help we can get!

/PA

  • You must to post comments
0
0

Hi pokeskater, welcome to the forums.

I have just tested the ‘cycle’ event from examples.fev and it works fine for me in C#. Can you test your code and see with the examples.fev cycle event?

  • You must to post comments
0
0

Thank you for your quick reply.
After some experimenting we got it to work.
Love working with FMOD, thanks for a great product!

/PA

  • You must to post comments
0
0

Glad to hear it’s all working for you.

-Pete

  • You must to post comments
0
0

I am having the same problem — a keyoff event that works in the Event Player and the Sample Code, does not work in the main game I am working on.

What happens is that the sound plays, but the keyoff event works as a stop. In the game code, I get the same behavior when I use the examples.fev and the appropriate event in that bank.

I have FMOD_ASSERT around all these calls (defined below):

define FMOD_ASSERT(x) \

{ \
FMOD_RESULT result = x; \
if ( result != FMOD_OK ) \
{ \
const char * text = FMOD_ErrorString( result ); \
Assert( result == FMOD_OK, ( "FMOD result %d: %s\n", result, text ) ); \
} \
}

FMOD is failing silently (grrrr).

Regardless of which FEV/Event/Param I call keyOff on, the result is the same — behaves as "stop." When I debug into the call, the event and parameter are both being found.

My code looks something like this:

AudioManager::AudioManager()
{
FMOD_ASSERT( mpSystem->init(32, FMOD_INIT_NORMAL, 0) );

FMOD_ASSERT(FMOD::EventSystem_Create(&mpEventSystem));
FMOD_ASSERT(mpEventSystem->init(64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL));
FMOD_ASSERT(mpEventSystem->setMediaPath(resultPath));
}

void AudioManager::LoadEventFile(const char * path)
{
if ( mpEventSystem )
{
FMOD_ASSERT(mpEventSystem->load(path, 0, 0));
}
}

void AudioManager::StartEventInstance(SharedString name)
{

if ( mpEventSystem )
{
FMOD::Event *pEvent;

FMOD_ASSERT(mpEventSystem->getEvent(name.c_str(), FMOD_EVENT_DEFAULT, &pEvent));

if ( pEvent )
{
FMOD_ASSERT(pEvent->start());
}
}
}

void AudioManager::TriggerEventKeyoff(SharedString eventName, SharedString parameterName)
{
if ( mpEventSystem )
{
FMOD::Event *pEvent;

FMOD_ASSERT(mpEventSystem->getEvent(eventName.c_str(), FMOD_EVENT_DEFAULT, &pEvent));

if ( pEvent )
{
int i, numParams;

pEvent->getNumParameters(&numParams);

for ( i = 0; i < numParams; ++i )
{
FMOD::EventParameter *pParam;

FMOD_ASSERT(pEvent->getParameterByIndex(i, &pParam));
//FMOD_ASSERT(pEvent->getParameter(parameterName.c_str(), &pParam));

if ( pParam )
{
FMOD_ASSERT(pParam->keyOff());
}
}
}
}
}

void AudioManager::Update()
{
FMOD_ASSERT( mpSystem->update() );
FMOD_ASSERT( mpEventSystem->update() );
}

What am I doing wrong? (And why doesn’t FMOD spit an error at me when I do it?)

  • You must to post comments
0
0

Hi pokeskater,

Inside AudioManager::TriggerEventKeyoff you are calling EventSystem::getEvent again. This will get a new instances of that event.

This is a feature not a bug, FMOD allows you to get as many instances as you like of a given event, it will internally manage the resources. You can control the maximum number of instances which can be active at any time using the "Max Playbacks" event property in FMOD Designer. You can control what happens when you get more events than you have allowed with max playbacks using the "Max Playbacks Behaviour" event property. For example, some of the behaviour options are "Steal Oldest", "Steal Newest", "Just Fail".

This allows you to freely call getEvent when you like and let FMOD do the heavy lifting of managing the instances.

The default properties are:
Max Playbacks = 1
Behaviour = Steal oldest

The reason the event stops when you call getEvent the second time is because the new instance is stealing the first (older) instance. You should be holding onto the FMOD::Event handle returned from the first getEvent and using that to keyoff your event parameter.

It is possible to dig up event instance handles out of EventSystem and I can give you more info on this if you need, but I don’t think that is the best way to approach this. You would be better off extending each of the FMOD classes than trying to wrap all of them up in a monolithic AudioManager.

-Pete

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.