Board index » delphi » Merge two mono wav files to stereo interleaved wav file?

Merge two mono wav files to stereo interleaved wav file?


2006-08-06 10:14:26 AM
delphi2
Hi all,
Can anyone explain to me how to merge two mono wav files (Left.wav &
Right.wav) into a single stereo interleaved wav file? An example would be
wonderful :)
Thanks in advance,
Dave Atkin
 
 

Re:Merge two mono wav files to stereo interleaved wav file?

Hi,
It's quite easy task. First you must be sure that two mono fils have equal parameters (samples per second and bits per sample).
Files parameters must be something like this:
Channels:1
Samples per second: 48000
Bits per sample: 16
Average bytes per second: 96000
Aligne bytes: 2
Take wave header from one of the files and build it with the same settings, but only for two channels. The stereo wave file parematers must be something like this:
Channels:2
Samles per second: 48000
Bits per sample: 16
Average bytes per second: 192000
Aligne bytes: 4
Then you must multiplex audio data. The multiplexed stereo data consists of: Left sample, Right sample, Left sample, Right sample..... If your file's bits per sample is 16, than each sample is 2 bytes, so multiplexed data will be - two bytes from the left file, two bytes from the right file, two bytes form the left file, two bytes from the right file, and so on. Make sure that you take these bytes from the data chunk of the wave files.
Regards,
Tsviatko Jongov
tsviatko.jongov.com
"Dave Atkin" <XXXX@XXXXX.COM>writes:
Quote
Hi all,

Can anyone explain to me how to merge two mono wav files (Left.wav &
Right.wav) into a single stereo interleaved wav file? An example would be
wonderful :)

Thanks in advance,
Dave Atkin



 

Re:Merge two mono wav files to stereo interleaved wav file?

Hi Tsviatko,
Thanks for the info - it all makes sense now!
Dave Atkin
"Tsviatko Jongov" <XXXX@XXXXX.COM>writes
Quote

Hi,
It's quite easy task. First you must be sure that two mono fils have equal
parameters (samples per second and bits per sample).

Files parameters must be something like this:
Channels:1
Samples per second: 48000
Bits per sample: 16
Average bytes per second: 96000
Aligne bytes: 2

Take wave header from one of the files and build it with the same
settings, but only for two channels. The stereo wave file parematers must be
something like this:
Quote

Channels:2
Samles per second: 48000
Bits per sample: 16
Average bytes per second: 192000
Aligne bytes: 4

Then you must multiplex audio data. The multiplexed stereo data consists
of: Left sample, Right sample, Left sample, Right sample..... If your file's
bits per sample is 16, than each sample is 2 bytes, so multiplexed data will
be - two bytes from the left file, two bytes from the right file, two bytes
form the left file, two bytes from the right file, and so on. Make sure that
you take these bytes from the data chunk of the wave files.
 

Re:Merge two mono wav files to stereo interleaved wav file?

You can use WaveIOX.pas from www.tobybear.de to do the reading and parsing of the wave files as streams and
Procedure CvtInt16MonoToInt16Stereo
from www.thaddy.com/tdkdsplib.zip
to do the interleaving in BASM.
Works on the fly (with ASIO for example) with a proper buffersize.
I wrote it for recording software.
All sourcecode mentioned is freeware
Regards,
Thaddy
"Dave Atkin" <XXXX@XXXXX.COM>writes:
Quote
Hi all,

Can anyone explain to me how to merge two mono wav files (Left.wav &
Right.wav) into a single stereo interleaved wav file? An example would be
wonderful :)

Thanks in advance,
Dave Atkin



 

Re:Merge two mono wav files to stereo interleaved wav file?

Hi Thaddy,
Quote
>www.thaddy.com/tdkdsplib.zip
Excellent, thanks a lot!
I'm writing a program editor for the AKAI S6000 sampler (mostly for my own
use), and I would like to incorporate some basic sample-level functions - this
will help a great deal.
Best regards,
Dave Atkin