iPlug2 Forum

[Filters] HP filter only works when the LP filter is activated

Guide: Making Audio Plugins Part 13: Filter - Martin Finke's Blog

 double HPFilter::process(double inputValue) {
    buf0 += cutoff * (inputValue - buf0 + feedbackAmount * (buf0 - buf1));
    buf1 += cutoff * (buf0 - buf1);
    switch (db)
    {
      case DB6: return inputValue - buf0; break;
      // etc.
    }
  }

  double LPFilter::process(double inputValue) {
    buf0 += cutoff * (inputValue - buf0 + feedbackAmount * (buf0 - buf1));
    buf1 += cutoff * (buf0 - buf1);
    switch (db)
    {
      case DB6: return buf0; break;
      // etc.
    }
  }

    for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++in3, ++in4, ++out1, ++out2)
    {
          *in1 = highFilter.process(*in1);
          *in2 = highFilter.process(*in2);
          *in1 = lowFilter.process(*in1);
          *in2 = lowFilter.process(*in2);

          *out1 = *in1;
          *out2 = *in2;
    }
class HPFilter {
public:
  HPFilter() :
    cutoff(0.01),
    resonance(0.0),
    db(DB6),
    buf0(0.0),
    buf1(0.0)
  {
    calculateFeedbackAmount();
  };
  double process(double inputValue);
  inline void setCutoff(double newCutoff) { cutoff = newCutoff; calculateFeedbackAmount(); };
  inline void setResonance(double newResonance) { resonance = newResonance; calculateFeedbackAmount(); };
  inline void setDB(FilterDB newDB) { db = newDB; calculateFeedbackAmount(); };
private:
  double cutoff;
  double resonance;
  FilterDB db;
  double feedbackAmount;
  inline void calculateFeedbackAmount() { feedbackAmount = resonance + resonance / (1.0 - cutoff); }
  double buf0;
  double buf1;
};
class LPFilter {
  public:
    LPFilter() :
      cutoff(0.99),
      resonance(0.0),
      db(DB6),
    buf0(0.0),
    buf1(0.0)
  {
    calculateFeedbackAmount();
  };
  double process(double inputValue);
  inline void setCutoff(double newCutoff) { cutoff = newCutoff; calculateFeedbackAmount(); };
  inline void setResonance(double newResonance) { resonance = newResonance; calculateFeedbackAmount(); };
  inline void setDB(FilterDB newDB) { db = newDB; calculateFeedbackAmount(); };
private:
  double cutoff;
  double resonance;
  FilterDB db;
  double feedbackAmount;
  inline void calculateFeedbackAmount() { feedbackAmount = resonance + resonance / (1.0 - cutoff); }
  double buf0;
  double buf1;
};

Problem: The HP filter only works when the LP filter is activated. The LP filter works everything. Could anybody help, please? What could be the problem? Thanks.

@olilarkin

This is not really IPlug2 . It’s also not right just to tag me when you get stuck on something.

Sorry. I won’t do it anymore…

1 Like