Hi
I tried to load a wav file and write it again as a new file (just to test the writing)
So I did this:
File originalFile("c:/tmp/originalFile.wav");
File newFile("c:/tmp/newFile.wav");
if(newFile.existsAsFile())
newFile.deleteFile();
FileOutputStream fos(newFile);
MemoryBlock mb;
originalFile.loadFileAsData(mb);
WavAudioFormat waveAudioFormat;
MemoryInputStream mis(mb,true);
AudioFormatManager formatManager;
formatManager.registerBasicFormats();
AudioFormatReader* reader = formatManager.createReaderFor (&mis);
StringPairArray metaData = WavAudioFormat::createBWAVMetadata("","","",Time::getCurrentTime(),0,"");
writer = waveAudioFormat.createWriterFor(&fos,reader->sampleRate,reader->numChannels,reader->bitsPerSample,
metaData ,0);
writer->writeFromAudioReader(*reader,0,reader->lengthInSamples);
When I run it I get the newFile with the size of the original file, but It won’t play.
I tried comparing the binaries and checking the WAV spec but I still don’t know why it doesn’t play.
I also tried playing with the metadata parameters and I tried to use the metadata from the original file (empty) and I also tried the whole thing with an AIFF format.