Hello,
I’m working in a plugin that does all the processment in double precision, as it’s required by the algorithm. The processBlock() stores the results in AudioBuffer and I want to output these results to a file for further processment. The number of output samples is the numSamples/96, therefore just a few new samples are produced at each processBlock(). The new samples are then accumulated in a bigger AudioBuffer. I want to write these results into a wav file using AudioFormatWriter, but I’m not sure if this is the easiest approach, therefore that’s my first question:
1. Question: should I write the results in a wav file or is there a better method like a text file?
I have to write all the results accumulated on the Buffer for the whole stream of data, therefore I’m using a Timer to write the results on the wav file every 10 seconds. However, I also have another Timer attached to my Editor in order to update the GUI. And this is my second question:
2. Question: is it safe to run two Timers simultaneously, one attached to the Processor and the other attached to the Editor? I also ask myself if is it better to store 10s of results in a big AudioBuffer and write 10s of results in the wav file at once on the timerCallback() or if it would be better to write the new results on the wav file directly in processBlock() every time it’s called, which I assume would not be threat safe.
I’m also struggling with the AudioFormatWriter class:
juce::AudioBuffer mWavBuffer; //buffer to write wave file
juce::AudioBuffer mResultsBuffer; //buffer which stores the double precision (bit depth) results
juce::WavAudioFormat format;
std::unique_ptrjuce::AudioFormatWriter writer;
juce::File resourceFile = juce::File::getCurrentWorkingDirectory().getChildFile(“Result.wav”);
But I would like to set a specific directory for the file (I’m using Windows), like this:
juce::File resourceFile = (“C:\Users\user\Documents\AudioPlugins\Result.wav”);
But then I get an error which says that the format is not right. Therefore:
3. Question: how should I write the location for the wav file?
When I set the file location by getCurrentWorkingDirectory() method, the wav file is created only if I run the standalone version of the plugin, but if I run the VST3 version in Reaper, no wav file is created in the VST3 directory folder.
4. Question: Am I restricted to Windows writing permissions when running the VST3 through Reaper?
Another problem is that the method writeFromSampleBuffer() accepts only float AudioBuffers, therefore, I’m trying to convert the double buffer which has the results to a float buffer before writing the wav file:
void AudioProcessor::timerCallback()
{
mWavBuffer.makeCopyOf(mResultsBuffer, false);
if (writer != nullptr)
writer->writeFromAudioSampleBuffer( mWavBuffer, 0, mResultsBuffer.getNumSamples());
}
I’m also not sure if this type conversion is safe and how it could be avoided.
I would also like to point that I found lots of topics related to output files issues, however none of them addressed all my issues, then I decided to make this new one ![]()
I appreciate any help/suggestion and I thank you all.
