The code allows for the delay time (milliseconds) and gain to be specified.
See also:
Please do not redistribute this code. In the event that it contains a bug, this will ensure that it can be fixed without the buggy copies floating around indefinitely.
Last Modified: 6/28/98
/*********************************************************
Allpass.h - An allpass filter designed to build reverberators
Copyright (c) 1998, Scott Lehman, slehman@harmony-central.com
This code may be used and modified freely provided that credit
is given to the author in any public release. Any derivative
programs must be distributed freely and/or the modified source
code made publicly available. All code is provided AS IS and
without warranty of any kind.
*********************************************************/
#ifndef ALLPASS_H
#define ALLPASS_H
#include "Processor.h"
class Allpass : public Processor {
public:
Allpass(float delay, float gain); //delay in milliseconds
void Initialize(void);
void Process(void);
void Cleanup(void);
~Allpass(){;}
private:
float delay, gain;
float * bufferStart, * bufferEnd, * readPtr;
float * inputSignal, * outputSignal;
int i, numSamples;
Allpass(Allpass&){};
};
#endif
|
/*********************************************************
Allpass.cpp - An allpass filter designed to build reverberators
Copyright (c) 1998, Scott Lehman, slehman@harmony-central.com
This code may be used and modified freely provided that credit
is given to the author in any public release. Any derivative
programs must be distributed freely and/or the modified source
code made publicly available. All code is provided AS IS and
without warranty of any kind.
*********************************************************/
// *************** Comb(float, float) ***************
Allpass :: Allpass(float delayTime, float feedbackGain)
{
SetNumInputs(1);
SetNumOutputs(1);
gain = feedbackGain;
delay = delayTime; //delay time is in milliseconds
}
// *************** Initialize(void) ********************
void Allpass :: Initialize (void)
{
int bufferLength = int(delay*samplingRate/1000);
bufferStart = new float[bufferLength];
bufferEnd = bufferStart + bufferLength;
//zero out the buffer (create silence)
for(i=0; i<bufferLength; i++)
bufferStart[i] = 0.0;
//set read pointer to start of buffer
readPtr = bufferStart;
//assign pointers to the only input and output
inputSignal = inputs[0];
outputSignal = outputs[0];
return;
}
// **************** Process(void) ********************
void Allpass :: Process (void)
{
float temp;
for(i=0; i<frameLength; i++) { //for each sample...
temp = *readPtr;
*readPtr = gain * temp + inputSignal[i];
outputSignal[i] = temp - gain * *readPtr;
if(++readPtr >= bufferEnd) //if reach end of buffer, wrap
readPtr = bufferStart;
}
}
// ***************** Cleanup(void) ******************
void Allpass :: Cleanup (void)
{
delete [] bufferStart;
return;
}
|