I'm doing the following in VS2010 manually. 1. Read in 2 wave files, say "1.wav" and "2.wav". 2. Insert 2.wav to the middle of 1.wav. 3. Write the result wave stream to an output file "out.wav".
I can now read in the wave files successfully using the following structure
typedef struct {
char ChunkID[4]; /* RIFF Header */ //Magic header
unsigned long ChunkSize; /* RIFF Chunk Size */
char Format[4]; /* WAVE Header */
char Subchunk1ID[4]; /* FMT header */
unsigned long Subchunk1Size; /* Size of the fmt chunk */
unsigned short AudioFormat; /* Audio format 1=PCM,6=mulaw,7=alaw, 257=IBM Mu-Law, 258=IBM A-Law, 259=ADPCM */
unsigned short NumChannels; /* Number of channels 1=Mono 2=Sterio */
unsigned long SampleRate; /* Sampling Frequency in Hz */
unsigned long ByteRate; /* bytes per second */
unsigned short BlockAlign; /* 2=16-bit mono, 4=16-bit stereo */
unsigned short BitsPerSample; /* Number of bits per sample */
char Subchunk2ID[4]; /* "data" string */
unsigned long Subchunk2Size; /* Sampled data length */
BYTE Data[18000];
} WavFile;
But some of the parameters of the 2 wave files are not the same. For example, if SampleRate of 1.wav is 8000, SampleRate of 2.wav is 44100, what will SampleRate of out.wav be?