Author Topic: Getting the length of a BASSMix channel  (Read 302 times)


  • Posts: 77
Getting the length of a BASSMix channel
« on: 21 Jun '17 - 20:06 »

I have a resampling channel created with BASS_Mixer_StreamCreate with one source channel (via BASS_StreamCreateFile) plugged in. Both the source and the resampling stream are created with the BASS_STREAM_DECODE flag.

Now, I need to read the whole resampled audio data into a buffer. How should I go about getting the required buffer length? There is no BASS_Mixer_ChannelGetLength function and the normal BASS_ChannelGetLength function returns BASS_ERROR_NOTAVAIL.


Ian @ un4seen

  • Administrator
  • Posts: 21372
Re: Getting the length of a BASSMix channel
« Reply #1 on: 22 Jun '17 - 14:50 »
You could get the original length and use BASS_ChannelBytes2Seconds and BASS_ChannelSeconds2Bytes to translate it for the new sample format, something like this:

Code: [Select]
QWORD origbytes = BASS_ChannelGetLength(source, BASS_POS_BYTE); // get original length in bytes
double secs = BASS_ChannelBytes2Seconds(source, origbytes); // translate to seconds
QWORD newbytes = BASS_ChannelSeconds2Bytes(mixer, secs); // translate to mixer output bytes