WASAPIPROC_BASS question

Started by AndyMK, 4 Mar '25 - 12:45

AndyMK

Hi Ian. I am currently using BASS_WASAPI_Init to open loopback streams from different processes and add them to a mixer feeds an ASIO device. In BASS_WASAPI_Init, i am using WASAPIPROC_BASS and a DECODE stream configured with STREAMPROC_PUSH. The loopback streams are attached to a virtual audio device so that audio from apps never make to the speakers and are forced through my app and this works fine. I get audio coming out of the speakers from all apps that use WASAPI or DSOUND. The problem is, the audio interface hardware clock compared to the virtual audio interface drifts after some time causing the ASIOproc to be starved of data. To get around this, I wasa initializing BASS_WASAPI with a WASAPIproc and used a lock free ring buffer in the proc to monitor/resample and transfer data to the the mixer channel stream. It's messy, i hate it but it works fine. Can you think of a way where i can use WASAPIPROC_BASS and somehow monitor the the WASAPI stream buffer going to the mixer so that i can resample it before it runs out?

Ian @ un4seen

You could perhaps modify your existing monitor/resample code to monitor the WASAPIPROC_BASS stream and adjust its playback rate? For example, the ASIOPROC could look something like this:

DWORD CALLBACK AsioProc(BOOL input, DWORD channel, void *buffer, DWORD length, void *user)
{
DWORD queue = BASS_StreamPutData(wasapistream, 0, 0); // get amount of data in WASAPI stream
// calculate a playback rate based on that here
BASS_ChannelSetAttribute(wasapistream, BASS_ATTRIB_FREQ, newrate); // apply the rate
return BASS_ChannelGetData(mixer, buffer, length); // process the mixer
}

Still a bit messy (ie. the "calculate a playback rate" part), but perhaps less than currently? :)

AndyMK