BASS.NET: Switch record files from audio source

Started by Dev01,

Dev01

I work with bass.net, and I'd like to record the audio stream of an audio source, which could come from a URL or WASAPI device, into an MP3 file. Every hour of recording, I'd like to switch recording to a new file WITHOUT losing samples. What's the best practice?

Ian @ un4seen

You can ensure that no data is missed during the encoder switch over by locking the stream during it. For example, you could set a timer to do this every hour:

BASS_ChannelLock(stream, true); // lock the stream
BASS_Encode_StopEx(encoder, BASS_ENCODE_STOP_ASYNC); // stop the old encoder
encoder = BASS_Encode_MP3_StartFile(stream, options, flags, filename); // start the new encoder
BASS_ChannelLock(stream, false); // unlock the stream

You can replace BASS_Encode_StopEx with BASS_Encode_Stop if you're not using the BASS_ENCODE_QUEUE flag.