Well, how about this? Not tested, but I think it should work.
Code:
void IPlugSideChain::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames) {
// Mutex is already locked for us.
double* in1 = inputs[0];
double* out1 = outputs[0];
// nFrames to processingBuffer
processingBuffer.Add(in1,nFrames*sizeof(double));
while (processingBuffer.Available() >= sizeof(double)*FFT_BUFFER_SIZE) {
// Read out FFT sized chunk from processingBuffer
double data[FFT_BUFFER_SIZE];
processingBuffer.GetToBuf(0, data, FFT_BUFFER_SIZE*sizeof(double));
processingBuffer.Advance(FFT_BUFFER_SIZE*sizeof(double));
hamming(data, FFT_BUFFER_SIZE);
// Add processed data to outputBuffer
outputBuffer.Add(data, FFT_BUFFER_SIZE*sizeof(double));
}
// Not necessary if you have pre-added zeros to outputBuffer:
// if (outputBuffer.Available() < nFrames*sizeof(double)) {
// int n = nFrames*sizeof(double) - outputBuffer.Available();
// memset(out1, 0, n);
// n /= sizeof(double);
// nFrames -= n;
// out1 += n;
// }
// output nFrames from outputBuffer
outputBuffer.GetToBuf(0, out1, nFrames*sizeof(double));
outputBuffer.Advance(nFrames*sizeof(double));
}
Quote:
Originally Posted by mviljamaa
Also reinterpret_cast seems not necessary? Why?
|
I believe any pointer type can be automagically casted to void*. Note that reinterpret_cast is required when casting from void* to another pointer type.