Converting a mono wav file to stereo

Help Please!

Here is the file... I know that I have to create 2 channels and a processor that can handle a stereo signal but I'm not sure what the exact code is..


#include <iostream>
#include <fstream>
#include <string>
#include <assert.h>
#include "stdint.h"

struct WaveHeader {
char riffChunkID[4];
int32_t dataSize;
char riffType[4];
char waveChunkID[4];
int32_t waveChunkSize;
uint16_t compressionCode;
uint16_t numChannels;
uint32_t sampleRate;
uint32_t averageBytesPerSec;
uint16_t blockAlign;
int16_t significantBitsPerSec;
// Extra Param Size not used in PCM
char dataChunkID[4];
int32_t dataChunkSize;

} ;


static char const *const INPUT_WAVEFILE = "D:\\class\\drum.wav";
static char const *const OUTPUT_WAVEFILE = "D:\\class\\output.wav";

using namespace std;

class Wave {
private:
ifstream wav;
WaveHeader header;
int32_t* waveData;
int numSamples;
public:

bool openWave(string fileName) {
wav.open(fileName, ios::binary);
if(wav.fail()){
cout << "Failed to locate input file" << endl;
return false;
} else {
return readWave();
}
};


bool readWave() {
// Read in the file
//
wav.read((char*)(&header), sizeof(WaveHeader));
numSamples = header.dataChunkSize / 2;
cout << numSamples << endl;
// Create a dynamic array of samples
waveData = new int16_t[numSamples];
wav.read((char*)(waveData), header.dataChunkSize);
}
return true;
Topic archived. No new replies allowed.