BASS_Mixer_ChannelGetData

Retrieves the immediate sample data (or an FFT representation of it) of a mixer source channel.

DWORD BASS_Mixer_ChannelGetData(
    DWORD handle,
    void *buffer,
    DWORD length
);

Parameters

handleThe channel handle.
bufferPointer to a buffer to receive the data.
lengthNumber of bytes wanted, and/or the BASS_ChannelGetData flags.

Return value

If an error occurs, -1 is returned, use BASS_ErrorGetCode to get the error code. When requesting FFT data, the number of bytes read from the channel (to perform the FFT) is returned. When requesting sample data, the number of bytes written to buffer will be returned (not necessarily the same as the number of bytes read when using the BASS_DATA_FLOAT flag). When using the BASS_DATA_AVAILABLE flag, the number of bytes in the channel's buffer is returned.

Error codes

BASS_ERROR_HANDLEhandle is not a mixer source.
BASS_ERROR_NOTAVAILThe channel does not have buffering enabled.

Remarks

This function is like the standard BASS_ChannelGetData, but it gets the data from the channel's buffer instead of decoding it from the channel, which means that the mixer does not miss out on any data. In order to do this, the source channel must have buffering enabled via the BASS_MIXER_CHAN_BUFFER flag.

If the mixer is being played by BASS, the returned data will be in sync with what is currently being heard from the mixer. If another output system is being used, the BASS_ATTRIB_MIXER_LATENCY option can be used to tell the mixer what the latency is so that it can be taken account of, otherwise the channel's most recent data will be returned.

If the mixer is a submixer (source of another mixer) without its own latency set via the BASS_ATTRIB_MIXER_LATENCY option then the parent mixer's latency will be used. If the parent mixer is also a submixer then the process will be repeated, and so on, until a final latency value is obtained (if possible). This is only possible if the submixer(s) have the BASS_MIXER_POSEX flag set, to enable keeping a record of source positions.

The BASS_CONFIG_MIXER_BUFFER config option determines how far back data will be available from, so it should be set high enough to cover any latency.

See also

BASS_Mixer_ChannelGetLevel, BASS_Mixer_ChannelIsActive, BASS_ATTRIB_MIXER_LATENCY, BASS_CONFIG_MIXER_BUFFER

BASS_ChannelGetData