Author Topic: mix down several of files to one new  (Read 836 times)

dsmits

  • Posts: 31
mix down several of files to one new
« on: 15 Mar '15 - 17:54 »
I have several of files that i want to mix down to one single file. There can be whitespaces between the tracks and also some overlap. Also want to use sliding volumes. For  normal playing its great to do this with bass but can i also mix it down to a single file with bass?

Ian @ un4seen

  • Administrator
  • Posts: 22167
Re: mix down several of files to one new
« Reply #1 on: 16 Mar '15 - 16:28 »
The BASSmix and BASSenc add-ons can be used to do that. It could look something like this...

Code: [Select]
HSTREAM mixer=BASS_Mixer_StreamCreate(freq, chans, BASS_MIXER_END|BASS_STREAM_DECODE); // create a mixer that ends with its sources
BASS_Encode_Start(mixer, "mix.wav", BASS_ENCODE_PCM|BASS_ENCODE_AUTOFREE, 0, 0); // set an encoder on it (WAV writer in this case)
// add files to the mix...
for (int a=0; a<files; a++) {
HSTREAM decoder=BASS_StreamCreateFile(FALSE, filename[a], 0, 0, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE); // create a decoder for the file
BASS_Mixer_StreamAddChannel(mixer, decoder, BASS_STREAM_AUTOFREE); // add it to the mix and auto-free at end
}
// processing loop...
while (BASS_ChannelIsActive(mixer)) { // not at the end
BYTE buf[20000]; // processing buffer
BASS_ChannelGetData(mixer, buf, sizeof(buf)); // process the mix
}
BASS_StreamFree(mixer); // free the mixer (and encoder due to AUTOFREE)

If you would like to delay the start of any files, BASS_Mixer_StreamAddChannelEx can be used instead of BASS_Mixer_StreamAddChannel. For the sliding volumes, volume envelopes could be applied via BASS_Mixer_ChannelSetEnvelope. Please see the documentation for details on the aforementioned functions.