Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Wanted: util to add 2 wav files (Read 8668 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Wanted: util to add 2 wav files

Hi,

Does anyone have (or would anyone be willing to write) a simple Dos/Win32 command line utility that can take two 16-bit .wav files, add them together, and output the sum as a third .wav file?

e.g.

wavadd a.wav b.wav c.wav

would go through a.wav, sample by sample, adding the same sample in b.wav, and outputing the result to c.wav.


This would really help with the digital radio listening test that I'm putting together. As well as the original, there are two further files that I must distribute losslessly, but since they're almost the same as the original, it would take much less space to losslessly pack the DIFFERENCE between the original and coded (giving a smaller FLAC), and then add it back to the original at the other end. I need to do this from a bat file, so need a command line utility to take care of this.

Can anyone help please?

Cheers,
David.

EDIT: all files will be stereo, 16-bit, and either 44.1kHZ or 48kHz sampled. c.wav will never clip, so this doesn't need to be checked for. wavadd needs to be a small program.


Wanted: util to add 2 wav files

Reply #2
This sounded great, but...

I tried wavmerge a.wav b.wav c.wav
where a and b were 10 second long test files, 44.1kHz 16-bit, and c.wav didn't exist.

It crashed

[span style='font-size:8pt;line-height:100%']
Code: [Select]
WAVMERGE caused an invalid page fault in
module MSVCRT.DLL at 017f:7800d203.
Registers:
EAX=00650078 CS=017f EIP=7800d203 EFLGS=00010246
EBX=78001ec9 SS=0187 ESP=0063fc20 EBP=0063fc3c
ECX=00455844 DS=0187 ESI=00760ec2 FS=34af
EDX=00000ec6 ES=0187 EDI=00000000 GS=0000
Bytes at CS:EIP:
8b 14 31 8d 1c 31 89 55 f4 8b 56 fc 89 55 f8 8b
Stack dump:
7801270c 00760ec6 78001ec9 006501bc 7803b534 78001d9a 00455844 0063fc80 7800cc3f 0075000c 00760ec6 7801270c 00760e94 78001ec9 78001026 00000006
[/span]

any ideas?

Wanted: util to add 2 wav files

Reply #3
David, are you saying that you want to add two stereo wav files together to produce a third stereo wav file? Or, two mono files to make a stereo file? I wrote a little prog to do the second of these (it's at RareWares, m2s), but it wouldn't take much to do the first, I guess.


Wanted: util to add 2 wav files

Reply #5
David, depending on your windows version, the msvcrt.dll (C++ runtimes) may be outdated. More here: http://support.microsoft.com/?kbid=190536
Wavmerge runs fine on this w2k sp2 work-PC.

Thanks Sunhillow, I didn't know the tools you mention!

Wanted: util to add 2 wav files

Reply #6
Quote
David, are you saying that you want to add two stereo wav files together to produce a third stereo wav file? Or, two mono files to make a stereo file? I wrote a little prog to do the second of these (it's at RareWares, m2s), but it wouldn't take much to do the first, I guess.


I need the first, not the second.

This would perform the same process:

Load A.wav into Cool Edit.
Load B.wav into Cool Edit.
Swich to A.wav
Select All.
Copy.
Switch to B.wav
Mix paste 100% non-inverting.
Save As C.wav

It sounds trivial to me, but I can't program.

Subhillow,
I don't want to concatenate, but maybe CopyAudio will do the job - I'll try.

Cheers,
David.

Wanted: util to add 2 wav files

Reply #7
So you basically just want ((left channel + left channel) / 2) and the same for the right channel?

Wanted: util to add 2 wav files

Reply #8
I don't even want the divided by 2 - just left+left! (and right plus right).

D.

Wanted: util to add 2 wav files

Reply #9
The Microsoft Download didn't help with wavmerge. I wonder what's happening there?


Anyway, CopyAudio will do the job perfectly - thanks Sunhillow.


This does exactly what I want:

copyaudio --chanA="A+C" --chanB="B+D" a.wav b.wav c.wav

I've just got to figure out how little of the AFsp distribution I can get away with including in the download. Even the exe itself seems quite large for the job I want it to do.


So, if anyone can come up with a working 4.5kB (ish) file to do the same job, that would be even better!

Cheers,
David.

Wanted: util to add 2 wav files

Reply #10
I hadn't tested wavmerge under Win98, it seemed to crash there but work properly under NT. I fixed the bug, redownload using same link.

Wanted: util to add 2 wav files

Reply #11
Thanks Case - that works now.

But now I see that it concatenates - I want to add!

Cheers,
David.

Wanted: util to add 2 wav files

Reply #12
Sorry about that, I didn't read the whole thread, the crash caught my attention. I made Wavmix the other day, if your files have 44 byte headers it should work.

Wanted: util to add 2 wav files

Reply #13
Quote
I made Wavmix the other day, if your files have 44 byte headers it should work.

Perfect!!!!

If no problems crop up, that's what I'll use - it's exactly what I'm looking for.

Thanks Case. Are there any known "issues" with this?


Cheers,
David.

Wanted: util to add 2 wav files

Reply #14
Quote
Thanks Case. Are there any known "issues" with this?

You're welcome

It will work fine on most common wavs with 44 byte header, if you extract files from CDs or use Cool Edit to write wavs there won't be issues. Foobar and dBPowerAMP both write 2 bytes longer headers which will not be handled correctly and mixed wav will have two wrong bytes in its header. I have been too lazy to improve it.

Wanted: util to add 2 wav files

Reply #15
That'll be fine for my purpose. Thanks for replying.

Wanted: util to add 2 wav files

Reply #16
Looks like your 'files' folder has many little goodies to discover, Case! Did you ever describe them somewhere or are they just waiting to be discovered?

Wavmix even can do inverse mixing, something I couldn't figured out with SoXmix.

Edit: David I'd be curious how that filesize reduction will end up with your method. Also wonder how you prevent people accidentaly (or purposely) playing the artefact files and start judging on that...