I've got my plugin working fast and efficiently by operating on blocks instead of sample by sample as Urs suggested. I'm using JUCE and have the Mac version working great and while bringing the Windows version up to speed, I ran into one issue dealing with buffer sizes and compiler differences.
in my processBlock function, I allocate some buffers so I can operate efficiently on the entire buffer:
Code: Select all
// obviously simplified...
void MyAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
const int numSamples = buffer.getNumSamples();
float* inBuffer = buffer.getReadPointer(0);
float* outBuffer = buffer.getWritePointer(0);
// temp buffers...this is fine in Xcode, but VS doesn't like it
float aBuffer[numSamples];
float bBuffer[numSamples];
float cBuffer[numSamples];
// process intermediate steps and put in temp buffers
doSomething1(inBuffer, aBuffer, numSamples);
doSomething2(inBuffer, bBuffer, numSamples);
doSomething3(inBuffer, cBuffer, numSamples);
// use the temp buffers to create final output
doMore(aBuffer, bBuffer, cBuffer, outBuffer, numSamples);
}
I was thinking about doing something like this:
Code: Select all
// temp buffers
#if MAC
float aBuffer[numSamples];
float bBuffer[numSamples];
float cBuffer[numSamples];
#else
#define kMaxBufferSize 2048
float aBuffer[kMaxBufferSize];
float bBuffer[kMaxBufferSize];
float cBuffer[kMaxBufferSize];
#endif
I guess it's possible to do this:
Code: Select all
// temp buffers
std::vector<float> aBuffer(numSamples);
std::vector<float> bBuffer(numSamples);
std::vector<float> cBuffer(numSamples);
Thoughts?