0
0

Hey guys,

I’m suspecting this is a basic configuration or data issue but I thought I’d reach out and see if anyone can advise. I have a sound where I’d like to leverage the callback "FMOD_EVENT_CALLBACKTYPE_SOUNDDEF_SELECTINDEX" so that the game can pick a random sound based on some complicated rules. We’ve created a sound group in our fev that is set to be program controlled but our callback never gets run with this as the callback type. Is there anything special we need to do to enable this callback other than setting the group? Any debugging suggestions?

Thanks

  • You must to post comments
0
0

Hi there,

Did you set the Sound Definition play mode to "Programmer Selected"? Are you calling EventSystem.Update() regularly? Is your callback set in the correct event instance, before you start playing it?

If you did those things you should be receiving the callbacks.

[edit]
Almost forgot… here is the example code that comes with fmod. Be sure to check the "examples.fdp" in your API folders to see how the event and definition are organized.
[code:b7i0f6pi]
/*=============================================================================
Programmer Selected Sound Definition Example
Copyright (c), Firelight Technologies Pty, Ltd 2007-2011.

Demonstrates how to use the "programmer selected sound definition" feature of
the FMOD event system
=============================================================================*/

include "../../api/inc/fmod_event.hpp"

include "../../api/inc/fmod_errors.h"

include <windows.h>

include <stdio.h>

include <stdlib.h>

include <conio.h>

const char *MEDIA_PATH = "..\media\";

static int g_sounddef_entry_index = 0;

void ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
exit(-1);
}
}

FMOD_RESULT F_CALLBACK eventcallback(FMOD_EVENT *event, FMOD_EVENT_CALLBACKTYPE type, void *param1, void *param2, void *userdata)
{
switch (type)
{
case FMOD_EVENT_CALLBACKTYPE_SOUNDDEF_SELECTINDEX :
{
char *name = (char *)param1; // [in] (char *) name of sound definition
int *index = (int *)param2; // [out] (int *) the sounddef entry index to use

        *index = (g_sounddef_entry_index &lt; *index) ? g_sounddef_entry_index : *index - 1;
        printf(&quot;FMOD_EVENT_CALLBACKTYPE_SOUNDDEF_SELECTINDEX '%s': %d\n&quot;, name, *index);

        break;
    }
}

return FMOD_OK;

}

int main(int argc, char *argv[])
{
FMOD_RESULT result;
FMOD::EventSystem *eventsystem;
FMOD::EventGroup *eventgroup;
FMOD::Event *event;
int key;

ERRCHECK(result = FMOD::EventSystem_Create(&amp;eventsystem));
ERRCHECK(result = eventsystem-&gt;init(64, FMOD_INIT_NORMAL, 0, FMOD_EVENT_INIT_NORMAL));
ERRCHECK(result = eventsystem-&gt;setMediaPath((char *)MEDIA_PATH));
ERRCHECK(result = eventsystem-&gt;load(&quot;examples.fev&quot;, 0, 0));
ERRCHECK(result = eventsystem-&gt;getGroup(&quot;examples/FeatureDemonstration/SequencingAndStitching&quot;, FMOD_EVENT_DEFAULT, &amp;eventgroup));

printf(&quot;======================================================================\n&quot;);
printf(&quot;Programmer Selected Sound Definition.\n&quot;);
printf(&quot;Copyright (c) Firelight Technologies 2006-2011.\n&quot;);
printf(&quot;----------------------------------------------------------------------\n&quot;);
printf(&quot;Press 'Space' to start the 'Programmer Selected' event\n&quot;);
printf(&quot;Press '&gt;'     to increase sound definition entry index\n&quot;);
printf(&quot;Press '&lt;'     to decrease sound definition entry index\n&quot;);
printf(&quot;Press 'Esc'   to quit\n&quot;);
printf(&quot;======================================================================\n&quot;);
printf(&quot;Sound definition entry index = %d\n&quot;, g_sounddef_entry_index);

key = 0;
do
{
    if (_kbhit())
    {
        key = _getch();

        switch(key)
        {
            case ' ' :
                ERRCHECK(result = eventgroup-&gt;getEvent(&quot;ProgrammerSelected&quot;, FMOD_EVENT_DEFAULT, &amp;event));
                ERRCHECK(result = event-&gt;setCallback(eventcallback, 0));
                ERRCHECK(result = event-&gt;start());
                break;

            case '&gt;' : case '.' :
                ++g_sounddef_entry_index;
                printf(&quot;Sound definition entry index = %d\n&quot;, g_sounddef_entry_index);
                break;

            case '&lt;' : case ',' :
                --g_sounddef_entry_index;
                g_sounddef_entry_index = (g_sounddef_entry_index &lt; 0) ? 0 : g_sounddef_entry_index;
                printf(&quot;Sound definition entry index = %d\n&quot;, g_sounddef_entry_index);
                break;
        }
    }

    ERRCHECK(result = eventsystem-&gt;update());
    Sleep(10);

} while (key != 27);

ERRCHECK(result = eventsystem-&gt;unload());
ERRCHECK(result = eventsystem-&gt;release());
return 0;

}

[/code:b7i0f6pi]

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.