Sorry for that bit of confusion.
I read the wav file using AudioformatReader,resample it to the required frequency using ResamplingAudioSource,do the writing using AudioFormatWriter into flac format and play the file in QuickTime
The distortion at 24 bits/sample is noise with actual audio.So the numbers are out of range.The timing is perfect.
Heres the code of what Im doing
double OutputsampleRate = 48000;//Does not Work for 96000
juce::File SrcFile = juce::File(/Input wav file path/);
juce::FileInputStream* InputStream = SrcFile.createInputStream();
if(InputStream == NULL)
{
return false;
}
juce::AudioFormat *WavFormat = new juce::WavAudioFormat();
juce::AudioFormatReader *WavFormatReader = WavFormat->createReaderFor (InputStream, true);
if(WavFormatReader == NULL)
{
SAFE_DELETE(InputStream);
return false;
}
juce::AudioFormatReaderSource *WavReaderSource = new juce::AudioFormatReaderSource(WavFormatReader,false);
juce::ResamplingAudioSource *Resample = new juce::ResamplingAudioSource(WavReaderSource,false);
Resample->setResamplingRatio(WavFormatReader->sampleRate/(double)OutputsampleRate); Resample->prepareToPlay(128,(double)OutputsampleRate);
double InputLength = (double) WavFormatReader->lengthInSamples;
double TotalSamplestoWrite = (int) (InputLength/(_wavFormatReader->sampleRate/OutputsampleRate));
juce::File FlacFile = juce::File(/Output Flac file path/);
juce::FileOutputStream* OutputStream = NULL;
juce::AudioFormatWriter* AudioFormatWriter = NULL;
juce::AudioFormat *AudioRenderer = NULL;
AudioRenderer = new juce::FlacAudioFormat();
OutputStream = FlacFile.createOutputStream();
if(OutputStream == NULL)
return false;
AudioFormatWriter = AudioRenderer->createWriterFor (OutputStream,OutputsampleRate,2,24,NULL,0);
//Works if bitspersample is 16
bool Success = AudioFormatWriter->writeFromAudioSource(Resample,TotalSamplestoWrite);
OutputStream->flush();
SAFE_DELETE(AudioFormatWriter);
The output file doesnt play with Winamp as well.
Regards
Praveen