lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

于 2011-9-4 21:35, Luciano de Souza 写道:
Hi listers,

Is there a way to join to wave files into a single one? I prefered to do it in Lua in order to keep the code multiplatform, but if it's not possible, how to do it in Linux?

wave.join('file1.wav', 'file2.wav', file3.wav)

The desirable result is that file3.wav is the concatenation of file1 and file2, being file1 the first and file2 the last sound.


you may have to parse the file header to make sure the two source files are with same sample rate, bit rate,
sample precision (a.k.a. bits per sample), and number of channels, and parameters like such.

if they are the same, then you just create an new file, keep the parameters same with the input files,
but set the data size to the sum of the input source files, and concat the payload data bytes, put them in chunks.

if they are not the same, you can't concat them directly. you must convert either souce file to be same with the other, then do
the concat.

you may google for the `.wav' file header format, it is quite simple.