Author Topic: BASS and raw data  (Read 141 times)

Rastislav Kiss

  • Posts: 7
BASS and raw data
« on: 20 Oct '17 - 14:34 »
Hello all,
I am again here after longer time, now with another question. I started to play around with Steam audio
(https://valvesoftware.github.io/steam-audio/)
, because of its hrtf positioning abilities. It is really simple to use, so I get it to position given sound into the file after few minutes of reading its documentation. So, now I am starting to thinking, how to connect this stuff with a BASS engine. It does have a interface to do this, better told for Steam audio it is only way to do it, because SA does not have audio playing ability itself, or I did not found it. So it shouldn't be problem from this side. But I am thinking how to process received data by BASS. After game scene is modelled in Steam audio and its Binaural renderer is ready to use, it can manage sounds as objects in space. I give to it a raw 32 bit float audio data representing my sound, and it applies all physics, acoustic, rendering and such stuffs to calculate new raw audio data, which I can receive and play in audio player, editor or engine. And this is the problematic part, is there some efficient way how to make BASS use this raw format, best without recoding? And if yes, which way is the best to use, when there would be constantly playing loops, which can't start playing again?

Thank you in advance.

Best regards

Rastislav

Ian @ un4seen

  • Administrator
  • Posts: 20426
Re: BASS and raw data
« Reply #1 on: 20 Oct '17 - 17:09 »
If the Steam library provides sample data that you can output any way you want, I think using WASAPI output would be best to minimize latency. You can use BASSWASAPI to do that. If the Steam library can provide the sample data in any format you want, you can simply call BASS_WASAPI_Init to initialize the output device and then BASS_WASAPI_GetInfo to get its sample format to give the Steam library. You can then get the sample data from the Steam library in your WASAPIPROC callback function. It could look something like this:

Code: [Select]
BASS_WASAPI_Init(-1, 0, 0, BASS_WASAPI_EVENT, 0, 0, WasapiProc, NULL); // initialize default output device
BASS_WASAPI_INFO info;
BASS_WASAPI_GetInfo(&info); // get sample format info
// initialize Steam library with the sample format here
BASS_WASAPI_Start(); // start the output

...

DWORD CALLBACK WasapiProc(void *buffer, DWORD length, void *user)
{
// put "length" bytes of data from the Steam library in "buffer" here
}