Author Topic: Joining wav audio files ?  (Read 80 times)

titobal

  • Posts: 11
Joining wav audio files ?
« on: 7 Mar '19 - 12:54 »
Hello,

I would like to know if it is possible with bass to join several wav audio file.

I would like to do this big_audio_wav_file = wavefile1 + wavefile2 + wavfile3 etc ....

Thanks

Ian @ un4seen

  • Administrator
  • Posts: 21593
Re: Joining wav audio files ?
« Reply #1 on: 7 Mar '19 - 15:10 »
You could use the BASSenc add-on for that. You would create decoding channels for each of the source WAV files and send them one after another to a WAV writer. Something like this:

Code: [Select]
DWORD encoder;
for (int n = 0; n < numfiles; n++) {
DWORD decoder = BASS_StreamCreateFile(FALSE, files[n], 0, 0, BASS_STREAM_DECODE); // create a decoder for the file
if (!n) // if it's the 1st file...
encoder = BASS_Encode_Start(decoder, "joined.wav", BASS_ENCODE_PCM, NULL, NULL); // set a WAV writer on it
else // otherwise...
BASS_Encode_SetChannel(encoder, decoder); // move the WAV writer to it
while (1) { // processing loop...
BYTE buf[20000];
int got = BASS_ChannelGetData(decoder, buf, sizeof(buf)); // process the decoder (and feed the WAV writer)
if (got < 0) break; // done
}
BASS_StreamFree(decoder); // free the decoder
}
BASS_Encode_Stop(encoder); // close the WAV writer

Please see the documentation for details on the mentioned functions. Note that the source WAV files should all have the same sample format.

titobal

  • Posts: 11
Re: Joining wav audio files ?
« Reply #2 on: 14 Mar '19 - 17:03 »
Thank you Ian ! Super as always you are  ;)