Reply
 
Thread Tools Display Modes
  #1   Report Post  
Mad Scientist Jr
 
Posts: n/a
Default code to merge and/or append and/or save sections of WAV files?

can someone post code on how to

* merge 2 mono wav files into a single stereo wav file (one file in
the left channel one in the right)
* append one wav file to another
* merge 2 stereo wav files into a single stereo wav file (specifying
the "mix" for each channel - the volume for file #1 left and file #2
left, and right, respectively)
* save a section of a wav file (starting second, end second)

VB.NET code or a .NET assembly would be best for my purposes, but any
language would work, all it should be doing that is system-specific
would be binary reading / binary writing the data from the WAV file on
disk...

thanks
  #2   Report Post  
Scott Dorsey
 
Posts: n/a
Default

Mad Scientist Jr wrote:

The .wav file is just a short 56-byte header, followed by 16-bit samples
one after the other. If it is stereo, the samples are interleaved between
channels.

A 20 or 24 bit wav file will have fullword samples instead of halfword, with
the unused bits being zeroed out. But I am assuming 16-bit stuff he

* merge 2 mono wav files into a single stereo wav file (one file in
the left channel one in the right)


Load the first 56 bytes of one file. Change the header byte saying that
it's mono and make it stereo (the rfc tell you this) and write it to the o
output. Skip the first 56 bytes of the other file. Load a short from one
file, write it to the output. Load a short from the other file and write
it to the output. Continue until you run out.

* append one wav file to another


Here you just load the header, dump it unchanged, and then dump the data
out, one halfword at a time. Then you discard the header from the second
file, and dump the data from that too.

* merge 2 stereo wav files into a single stereo wav file (specifying
the "mix" for each channel - the volume for file #1 left and file #2
left, and right, respectively)


Here you just read a word from each file alternately, multiply by a scaling
factor, add and dump. How you decide to deal with rounding is your issue.
--scott
--
"C'est un Nagra. C'est suisse, et tres, tres precis."
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recommended Hard Drive Partitioning for A/V Editing Smith Pro Audio 42 March 27th 04 08:40 PM
Richman's ethical lapses Michael McKelvy Audio Opinions 9 December 12th 03 08:16 AM


All times are GMT +1. The time now is 12:01 AM.

Powered by: vBulletin
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 AudioBanter.com.
The comments are property of their posters.
 

About Us

"It's about Audio and hi-fi"