User defined ASIO channel callback function.
DWORD CALLBACK AsioProc( BOOL input, DWORD channel, void *buffer, DWORD length, void *user );
input | Dealing with an input channel? FALSE = an output channel. |
channel | The input/output channel number... 0 = first. |
buffer | The buffer containing the recorded data (input channel), or in which to put the data to output (output channel). |
length | The number of BYTES to process. |
user | The user instance data given when BASS_ASIO_ChannelEnable was called. |
When an output channel's function returns less data than requested, the remainder of the buffer is filled with silence, and some processing is saved by that. When 0 is returned, the level of processing is the same as if the channel had been paused with BASS_ASIO_ChannelPause, ie. the ASIO buffer is simply filled with silence and all additional processing (resampling/etc) is bypassed.
ASIO is a low latency system, so a channel callback function should obviously be as quick as possible. BASS_ASIO_GetCPU can be used to monitor that. Do not call the BASS_ASIO_Stop or BASS_ASIO_Free functions from within an ASIO callback. Also, if it is an output channel, BASS_ASIO_ChannelSetFormat and BASS_ASIO_ChannelSetRate should not be used on the channel being processed by the callback.
Prior to calling this function, BASSASIO will set the thread's device context to the device that the channel belongs to. So when using multiple devices, BASS_ASIO_GetDevice can be used to determine which device the channel is on.
DWORD CALLBACK MyAsioProc(BOOL input, DWORD channel, void *buffer, DWORD length, void *user) { DWORD c = BASS_ChannelGetData(decoder, buffer, length); // decode some data if (c == -1) c = 0; // an error, no data (could pause the channel at this point) return c; }