🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #312

wav concatenation

#312
From: bcbnewbie
Date: Tue, 11 Jan 2005 16:30
76 lines
2407 bytes
hi all,

i'm using the code below to concat 2 wav files.  what is wrong?
the output is the first wav without the second.
I presume  that the error is during the header copy...

->

AnsiString TForm_Main::ConcatenateWav(AnsiString wavein1Name,
                                      AnsiString wavein2Name)
    {

   long* longValue1,* longValue2;
   AnsiString waveoutName;
   FILE *waveout,*wavein1,*wavein2;


AnsiString folder = getFileFolder(wavein1Name);
AnsiString title1 = getFileTitle(wavein1Name);
AnsiString title2 = getFileTitle(wavein2Name);

        waveoutName = folder;
	waveoutName+=title1;
	waveoutName+=title2;
	waveoutName+=".wav";

   waveout = fopen(waveoutName.c_str(), "wb");

char cTemp[44];
char cTemp2[44];

wavein1 = fopen(wavein1Name.c_str(), "rb");
wavein2 = fopen(wavein2Name.c_str(), "rb");

long numRead=fread(cTemp,44,1,wavein1);

longValue1= (long *)(&cTemp[4]);

numRead=fread(cTemp2,44,1,wavein2);

cTemp2[4]+=*longValue2;

longValue2= (long *)(&cTemp2[40]);
cTemp2[40]+=(*longValue2);

fseek(waveout, 0, SEEK_SET);
fwrite(&cTemp, sizeof(cTemp), 1, waveout);

DoCopy(wavein1, waveout);
DoCopy(wavein2, waveout);

fclose(wavein1);
fclose(wavein2);
fclose(waveout);

return waveoutName; //path
}

void TForm_Main::DoCopy(FILE *fin, FILE *fout)
    {
   char buf[8192];
   int num_io;
   fseek(fin, 44, SEEK_SET);
   fseek(fout, 0, SEEK_END);
    while (1)
        {
        num_io = fread(buf, 1, sizeof(buf), fin);
        if (!num_io)
            break;
        fwrite(buf, num_io, 1, fout);
        }
    }

thank you very much for your help,

Ed
Technical Details
Message-ID: <f76d06b2.0501110830.52bf91f9@posting.google.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10d0fc,9e802fe4a551d15,start
X-Google-Attributes: gid10d0fc,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!not-for-mail
From: bcbnewbie@yahoo.com (bcbnewbie)
Newsgroups: borland.public.cppbuilder.multimedia
Subject: wav concatenation
Date: 11 Jan 2005 08:30:08 -0800
Organization: http://groups.google.com
Lines: 76
Message-ID: <f76d06b2.0501110830.52bf91f9@posting.google.com>
NNTP-Posting-Host: 207.253.126.89
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1105461008 5686 127.0.0.1 (11 Jan 2005 16:30:08 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 11 Jan 2005 16:30:08 +0000 (UTC)