Need Help writing WAV to File after resampling

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]

Maybe my question was just too long.

Has anybody ever opened a Wave, changed its pitch while it was playing, and THEN

saved it back to disk with the altered pitch?

If so can you briefly explain how you did this without the resulting wave “Skipping every few seconds”?

I would so Love a response in any shape or form just to prove that my internet conn is working…Thanx!!

Hey, the internet is working, you were probably just a bit unlucky to draw a blank with folks here :smiley:

I suspect your guess about the write buffer size isn’t far off the mark, but I haven’t actually used these classes myself so I can’t confirm.

Well, thanx for the reply anyway Andrew. I’ll keep searching. I WILL find the answer…