You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.4KB

  1. /*
  2. * dRowAudio_AllpassFilter.h
  3. *
  4. * Created by David Rowland on 09/04/2009.
  5. * Copyright 2009 dRowAudio. All rights reserved.
  6. *
  7. */
  8. #ifndef _DROWAUDIO_ALLPASSFILTER_H_
  9. #define _DROWAUDIO_ALLPASSFILTER_H_
  10. #include "includes.h"
  11. #define BUFFERSIZE 4096
  12. /**
  13. Allpass Comb Filter.
  14. This allpass filter is a feedback and feedforward comb filter in series.
  15. It has a unity frequency response but a complex phase response,typically
  16. delaying sharp transients.
  17. */
  18. class AllpassFilter
  19. {
  20. public:
  21. /** Creates a default filter ready to be used.
  22. */
  23. AllpassFilter() throw();
  24. /// Destructor
  25. ~AllpassFilter() throw();
  26. /** Sets the feedback coefficient.
  27. This needs to be kept below 1 for stability.
  28. The higher the value, the longer the delay will last.
  29. */
  30. void setGain(float newGain) throw();
  31. /// Sets the time the samples are delayed for.
  32. void setDelayTime(double sampleRate, float newDelayTime) throw();
  33. /// Processes a single sample and returns a new, filtered value.
  34. float processSingleSample(float newSample) throw();
  35. /// Processes an array of samples which are modified.
  36. void processSamples (float* const samples,
  37. const int numSamples) throw();
  38. private:
  39. CriticalSection processLock;
  40. float* delayRegister;
  41. int registerSize, registerSizeMask;
  42. float delayTime, gain;
  43. int delaySamples, bufferWritePos, bufferReadPos;
  44. JUCE_LEAK_DETECTOR (AllpassFilter);
  45. };
  46. #endif //_DROWAUDIO_ALLPASSFILTER_H_