Author Topic: BASS_ChannelGetData with a recording channel  (Read 789 times)


  • Posts: 37
Could someone explain to me how I can use BASS_ChannelGetData with a recording channel please? I am writing a LTC timecode reader in Delphi, so I am not actually recording the audio, but rather loading it into another buffer to analyse and then discard every 20ms or so. I am finding that my analysis code is too complex to contain in a callback and am getting threading issues, so I would rather try putting the whole reader in a separate thread and then pass the critical values back to the main thread at intervals. I cannot work out how to get the recordthread data into a data array for analysis without using a callback. Thank you in advance!

Ian @ un4seen

  • Administrator
  • Posts: 22741
Re: BASS_ChannelGetData with a recording channel
« Reply #1 on: 6 Mar '19 - 17:08 »
You would first remove the RECORDPROC from your BASS_RecordStart call, and then have your worker thread repeatedly call BASS_ChannelGetData to get the data for processing. If you need a certain amount of data to process (eg. 20ms worth), you can use the BASS_DATA_AVAILABLE flag first to check how much is available. For example, the worker thread's code could look something like this:

Code: [Select]
int need = BASS_ChannelSeconds2Bytes(hrecord, 0.020); // 20ms
float *buffer = new float[need / sizeof(float)]; // allocate buffer for the data (assuming floating-point)
while (!stop) {
int got = BASS_ChannelGetData(hrecord, NULL, BASS_DATA_AVAILABLE); // check how much is available
if (got >= need) { // it's enough
got = BASS_ChannelGetData(hrecord, buffer, need); // get the data
// process the data...
} else
Sleep(20); // wait for more data to arrive
delete[] buffer;


  • Posts: 37
Re: BASS_ChannelGetData with a recording channel
« Reply #2 on: 7 Mar '19 - 19:44 »
Great! Thanks Ian...
I've got that working and it will give me much more flexibility!
Your help and fine software is very much appreciated!