🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.multimedia
1 messages
1 total messages Started by bcbnewbie Tue, 11 Jan 2005 16:30
wav concatenation
#312
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads