Hook a processor to a channel
Parameters
-
chan
- channel number to register f and d on. Use MIX_CHANNEL_POST to process the postmix stream.
-
f
- The function pointer for the effects processor.
-
d
- The function pointer for any cleanup routine to be called when the channel is done playing a sample. This may be NULL for any processors that don't need to clean up any memory or other dynamic data.
-
arg
-
Return Value
Zero on errors, such as a nonexisting channel
Remarks
Hook a processor function f into a channel for post processing effects. You may just be reading the data and displaying it, or you may be altering the stream to add an echo. Most processors also have state data that they allocate as they are in use, this would be stored in the arg pointer data space. When a processor is finished being used, any function passed into d will be called, which is when your processor should clean up the data in the arg data space.
The effects are put into a linked list, and always appended to the end, meaning they always work on previously registered effects output. Effects may be added multiple times in a row. Effects are cumulative this way.
int Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg)
Example
// make a passthru processor function that does nothing...
void noEffect(int chan, void *stream, int len, void *udata)
{
// you could work with stream here...
}
...
// register noEffect as a postmix processor
if(!Mix_RegisterEffect(MIX_CHANNEL_POST, noEffect, NULL, NULL))
{
printf("Mix_RegisterEffect: %s\n", Mix_GetError());
}
See Also
SdlMixer Class | Tao.Sdl Namespace | Mix_UnregisterEffect | Mix_UnregisterAllEffects