View Single Post
  #8 (permalink)  
Old December 8th 03, 11:55 AM posted to rec.audio.tech,uk.rec.audio
Dick Pierce
external usenet poster
 
Posts: 1
Default Concatenate WAVs

Anthony Edwards wrote in message ...
On Sun, 7 Dec 2003 13:53:28 -0000, John E wrote:
Is there any software out there that *easily* (I know I can DL a wave editor
and do it manually but I want something easier) concatenates wave files? Or
even MP3s?


How could anything possibly be easier than bringing up a DOS prompt and
typing "copy /b file1+file2+file3 destination-file"?


By not having the slightest possibility of working, that's how.

Simply concatenating two WAV files, like you describe, WILL NOT
WORK. Yes, you'll end up with a file which is longer, and has all
the bits of both files, but will not be usable.

What you're ignoring in your proposal is the fact that WAV files,
a variant of RIFF files, have all sorts of information about the
content of the file in the header, INCLUDING the amount of data
in the file. The WAV file header first includes the total amount
of data in the file. Concatenate another file to the first, without
changing any of that data, and the header information about the
length of the data remains unchanged.

Second point you're ignoring is that every WAV file must have
one and only one format 'chunk' which provides the information
about sample rate, number of channels, sample width and so forth.
If it's a non-PCM format file, there is additional information and,
possible, additional chunks with further formaty information. Simply
concatenating another WAV adds a second format chunk which will
likely be ignored or, in some applications, even possibly cause
problems.

The third point that you're ignoring is that the actual audio data
is contained in a "chunk" named the 'data' chunk, which itself
contains information about how long it is. A WAV file can have but a
single data chunk, i.e., only one section containing audio data.
Again, concatenate a second WAV file, and the most likely result
is that when the end of the first data chunk is reached, most
programs will consider themselves done and ignore the remainder.

Putting these three points together we have a situation where a
simple concatenation of two WAV files is, in fact, an invalid
file. If the program reading the file could simply read sequentially
through whatever chunks it finds, it will get to the end of the first,
expect the start of another chunk, and, in fact, find something very
different. Each chunk starts with a four-character chunk identifier
followed by a four-byte, 32 bit chunk length indicator. In the case
of a concatenated WAV file, you would, instead find the 'RIFF' tag
followed NOT by the length of the file, but by the RIFF type indicator
'WAVE.' Reading that as a chunk length would send it flying off into
some unknown part of the file.

Basically, concatenated WAV files have an invalid format.

A fourth point not considered is how do you deal with the potential
of differences in the sample format. How do you deal with the simple
concatenation of two WAV files with different sample rates, for
example?

There are a myriad of lesser issues, for example, one could, assuming
all the problems above are dealt with, then question how do you deal
with things like the crossfade at the point of concatenation? It's
easy if the first ends in silence and the second starts in silence,
but anything beyond that can result in things like a very audible
click at the splice point.

While one COULD write software which could deal with all these issues,
the vast majority of WAV file readers/players CANNOT because these
issues are NOT expected in WAV files. ALL of the issues above are
addressed in a number of WAV editor packages already.

There may, in fact, be some available software package that does
precisely what the poster wants, but he can rest assured that if
he simply does:

"copy /b file1+file2+file3 destination-file"

it won't work.