So I have a basic juce type Music Player that I have effortlessy put together All praise to this excellent library. Now my only snag is
with trying to ReWrite the file that is currently playing with its altered speed/pitch.
Specifically, the problem is the resulting wave file will skip periodically.
My best guest (which at best will be fairly Noobish) is that the write buffer size or something like that will also need to be altered by the
same ratio that the samplerate was. If that is even the problem, I can’t seem to figure out exactly how to go about fixing it.
Any clues to help me along in the right direction would be so helpful and appreciated tremendously.
I’ve included the relevant portion of my write function below.
[code]bool CCAudioPlayer::writeNewWavefile (String location/not used while testing/)
{
WavAudioFormat wav;
// File file(location);
//TemporaryFile tempFile(file);
File file (File::getSpecialLocation (File::userDocumentsDirectory)
.getNonexistentChildFile ("Testfile", ".wav"));
//Get the format reader from the source currently playing
AudioFormatReader *reader = currentAudioFileSource->getAudioFormatReader ();
if(reader != nullptr)
{
file.deleteFile () ;
ScopedPointer<OutputStream> out(file.createOutputStream ());
if(out != nullptr)
{
double ratio = masterResamplingSource->getResamplingRatio ();
ScopedPointer <AudioFormatWriter> writer (wav.createWriterFor (out , reader->sampleRate * ratio ,reader ->numChannels , (int) 24 ,reader->metadataValues ,0));
if(writer != nullptr )
{
out.release ();
bool ok = writer->writeFromAudioReader (*reader, 0,-1);
writer = nullptr;
// return tempFile.overwriteTargetFileWithTemporary ();
return true;
}
}
}
return false;[/code]