View Single Post
Old 06-22-2015, 01:33 AM   #16
Human being with feelings
Tale's Avatar
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,045

Well, how about this? Not tested, but I think it should work.

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

	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));

		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));
Originally Posted by mviljamaa View Post
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.

Last edited by Tale; 06-22-2015 at 09:39 AM. Reason: Corrected faulty output zeros code
Tale is offline   Reply With Quote