ChannelControl::setCallback

FMOD Studio API

Firelight Technologies FMOD Studio API

ChannelControl::setCallback

Sets a callback to perform action for a specific event.

C++ Syntax

FMOD_RESULT ChannelControl::setCallback(
  FMOD_CHANNELCONTROL_CALLBACK callback
);

Parameters

callback

Pointer to a callback to receive the event when it happens.

Return Values

If the function succeeds then the return value is FMOD_OK.
If the function fails then the return value will be one of the values defined in the FMOD_RESULT enumeration.

Remarks

Currently callbacks are driven by System::update and will only occur when this function is called. This has the main advantage of far less complication due to thread issues, and allows all FMOD commands, including loading sounds and playing new sounds from the callback. It also allows any type of sound to have an end callback, no matter what it is. The only disadvantage is that callbacks are not asynchronous and are bound by the latency caused by the rate the user calls the update command.

Callbacks are stdcall. Use F_CALLBACK in between your return type and function name.

FMOD_RESULT F_CALLBACK mycallback(FMOD_CHANNELCONTROL *chanControl, FMOD_CHANNELCONTROL_TYPE controlType, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbackType, void *commandData1, void *commandData2)
{
    if (controlType == FMOD_CHANNELCONTROL_TYPE_CHANNEL)
    {
        FMOD::Channel *channel = (FMOD::Channel *)chanControl;
        // Channel specific functions here...
    }
    else
    {
        FMOD::ChannelGroup *group = (FMOD::ChannelGroup *)chanControl;
        // ChannelGroup specific functions here...
    }

    // ChannelControl generic functions here...

    return FMOD_OK;
}

See Also




Version 1.10.03 Built on Feb 1, 2018