# How to do a lowpass signal filtering in Processing?

**URL:** https://discourse.processing.org/t/how-to-do-a-lowpass-signal-filtering-in-processing/14251
**Category:** Coding Questions
**Created:** [September 28, 2019, 2:20am UTC](https://discourse.processing.org/t/how-to-do-a-lowpass-signal-filtering-in-processing/14251 "2019-09-28T02:20:32Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![KGS](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@KGS](https://discourse.processing.org/u/KGS)
#### Post date: [September 28, 2019, 2:20am UTC](https://discourse.processing.org/t/how-to-do-a-lowpass-signal-filtering-in-processing/14251/1 "2019-09-28T02:20:32Z")

</div>

I have data for pulse recording. Since it’s embedded with noise I need to filter the signal real TIme so I can visualize the pulse pattern. How can I do it with Processing software?

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [September 28, 2019, 3:41am UTC](https://discourse.processing.org/t/how-to-do-a-lowpass-signal-filtering-in-processing/14251/2 "2019-09-28T03:41:36Z")

</div>

just filter math

```auto
// low pass filter
// numeric recursive filter first order
// kll 1/2019

float framerate = 20, inval, fil; // tune framerate
float A=0.1, B = 1.0 - A; // filter tuning A
int bd=2, xpos=0;
color bg = color(0, 0, 60); // oszi look
color in_c = color(200, 200, 0);
color fil_c= color(0, 200, 0);

void setup() {
  size(600, 200);
  inval = height - mouseY;
  fil = inval;
  frameRate(framerate);
  noSmooth();
  background(bg);
  println("fil = inval * "+A+" + fil * "+B);
  println("reading mouseY");
}

void draw() {
  //surface.setTitle("LPF "+nf(frameRate, 1, 1)+" FPS");
  inval = height - mouseY; // get data
  fil = inval * A + fil * B; // the filter!
  scope(inval, fil); // show it
}

void scope(float inval, float fil) {
  stroke(bg); // clean line
  line(xpos, 0, xpos, height);
  stroke(in_c);
  ellipse(xpos, height-inval, bd, bd);
  stroke(fil_c);
  ellipse(xpos, height-fil, bd, bd);
  xpos++; if (xpos >= width ) xpos = 0;
}

```
