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

**URL:** <https://iplug2.discourse.group/t/filters-hp-filter-only-works-when-the-lp-filter-is-activated/475>\
**Category:** Made with iPlug2\
**Created:** [15 September 2021 16:44 UTC](https://iplug2.discourse.group/t/filters-hp-filter-only-works-when-the-lp-filter-is-activated/475 "2021-09-15T16:44:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SKyZz](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@SKyZz](https://iplug2.discourse.group/u/SKyZz)\
**Post date:** [15 September 2021 16:44 UTC](https://iplug2.discourse.group/t/filters-hp-filter-only-works-when-the-lp-filter-is-activated/475/1 "2021-09-15T16:44:35Z")

</div>

Guide: [Making Audio Plugins Part 13: Filter - Martin Finke's Blog](http://www.martin-finke.de/blog/articles/audio-plugins-013-filter/)

```auto
 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.
    }
  }

```

```auto
    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;
    }

```

```auto
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;
};

```

```auto
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

---

<div class="post-metadata">

**Author:** ![olilarkin](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/olilarkin/32/2_2.png) [@olilarkin](https://iplug2.discourse.group/u/olilarkin)\
**Post date:** [15 September 2021 17:17 UTC](https://iplug2.discourse.group/t/filters-hp-filter-only-works-when-the-lp-filter-is-activated/475/2 "2021-09-15T17:17:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SKyZz](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@SKyZz](https://iplug2.discourse.group/u/SKyZz)\
**Post date:** [15 September 2021 17:19 UTC](https://iplug2.discourse.group/t/filters-hp-filter-only-works-when-the-lp-filter-is-activated/475/3 "2021-09-15T17:19:05Z")

</div>

Sorry. I won’t do it anymore…
