[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Joining two wave files
- From: Patrick Rapin <toupie300@...>
- Date: Sun, 4 Sep 2011 15:55:01 +0200
> 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)
I do not have code right now to do this, but it seems pretty easy in Lua.
WAV files consist of a 44-bytes header [1], followed by RAW PCM data.
Provided that the WAV files use the same mode (i.e. stereo, 44.1kHz, 16 bits),
what you have to do is:
- Open first file, read 44 bytes from it
- Open second file, read 44 bytes from it
- Verify that the headers are identical, except the Subchunk2Size field
- Compose the resulting header, by summing the Subchunk2Size fields
- Open destination file, write the result header
- Read remaining of file1, write it to file3
- Read remaining of file2, write it to file3
[1] https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
Patrick Rapin