Click here to Skip to main content
Click here to Skip to main content

Concatenating Wave Files

, 16 Jun 2003
Rate this:
Please Sign up or sign in to vote.
An article about concatenating .WAV files "on the fly"
<!-- Add the rest of your HTML here -->


Those who deal with voiceprints and prompts often should have prerecorded waves for testing/development, and sometimes you want to output a "joined wave", and even more better - get it dynamically. This article tries to solve this problem and create merged wave output "on the fly".


It would be good for you to have a brief overview about wave format.

Using the code

The main points of CWave class are it's constructor :

CWave(string fileName) throw(LPCSTR);

and operator+

CWave operator+(const CWave& w) const throw(LPCSTR);

The concatenation is implemented as follows:

CWave CWave::operator+ (const CWave &w) const{
    if (fmt.wFormatTag!=w.fmt.wFormatTag)
        throw "Can't concatenate waves with different format tags";
    CWave ret_val;
    ret_val.fmt = w.fmt;
    ret_val.riff = w.riff; =;;

    ret_val.extraParamLength = w.extraParamLength;
    ret_val.extraParam = w.extraParam;
    ret_val.wave = new BYTE[];

    string folder = getFileFolder(fileName);
    string title1 = getFileTitle(fileName);
    string title2 = getFileTitle(w.fileName);
    ret_val.fileName = folder;

    return ret_val;

The usage is very simple:

CWave wave1("a1.wav");
CWave wave("b7.wav");
CWave wave3(wave1+wave2);
//by default fileName of wave3 instance is concatenation of wave1 and wave2 fileNames
//you can specify another fileName by:


For the time being the CWave class can deal with PCM waves, extraParams and "fact" chunks in wave header. You can parse another chunks if your waves contain ones. Also, the two wave files must have the same encoding format.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Furer Alexander
Web Developer
Israel Israel
No Biography provided

Comments and Discussions

GeneralDifferent sample rates/bps Pinmemberpimb213-Aug-09 4:46 
Questionsomething need u help Pinmembernaohboy25-Feb-08 22:46 
Questioncan u guide me i am new for mixer control Pinmemberrajneshmalik30-Aug-07 3:21 
Generalhelp me please about how i could read a waw file and write its values to a tex file Pinmembervangurad6663-May-07 1:52 
AnswerRe: help me please about how i could read a waw file and write its values to a tex file PinmemberFurer Alexander3-May-07 5:17 
GeneralCombine .WAV's from timecode value Pinmembercharliev4-Feb-07 7:01 
GeneralUsing EVC4 Pinmemberdano187-Mar-06 11:24 
GeneralAmplitude Equalisation at bounderies PinmemberYash856-Mar-06 1:48 
GeneralPlaying the concatenated file without saving to disk PinmemberYash858-Feb-06 12:02 
AnswerRe: Playing the concatenated file without saving to disk PinmemberFurer Alexander8-Feb-06 13:42 
GeneralRe: Playing the concatenated file without saving to disk PinmemberYash8511-Feb-06 13:40 
GeneralRe: Playing the concatenated file without saving to disk PinmemberFurer Alexander12-Feb-06 1:36 
Generalthis site is pointless and knowone cares PinsussAnonymous1-Aug-05 18:15 
GeneralThat demo zip is rubbish PinsussAnonymous1-Aug-05 18:13 
Generalpoo head PinsussAnonymous1-Aug-05 18:10 
GeneralProblem with MS SoundRec32 PinmemberB.Damian23-Mar-05 2:01 
GeneralRe: Problem with MS SoundRec32 PinmemberKoray Balci22-Jun-06 7:40 
Generalvery interesting Pinmemberabaddon32525-Feb-05 0:00 
GeneralWAV file mixing PinmemberNightfox16-Feb-05 16:55 
Generalgreat!! Pinmemberuttam h6-Mar-04 11:07 
QuestionConcatenating AVI Files ? Pinmemberattckboy2-Aug-03 4:04 
AnswerRe: Concatenating AVI Files ? PinmemberDaFrawg26-May-04 23:05 
Generalconvert one wave type to another Pinmemberpearlmagic14-Jul-03 0:33 
QuestionConcatenating MPG Files ? Pinmemberwobble20-Jun-03 6:08 
AnswerRe: Concatenating MPG Files ? PinmemberMarkusStrobl22-Jun-03 23:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150327.1 | Last Updated 17 Jun 2003
Article Copyright 2003 by Furer Alexander
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid