
Script to plot both a raw EMG signal and the filtered signal in HIDscope
Revision 2:1d29b91bc46a, committed 2015-10-26
- Comitter:
- roosbulthuis
- Date:
- Mon Oct 26 15:00:52 2015 +0000
- Parent:
- 1:f32f8eac8af1
- Child:
- 3:7cb317c00afb
- Commit message:
- Got rid of pass by reference for v1 and v2, now we get a signal if we plot the filtered signal in channel 0.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Oct 26 14:45:46 2015 +0000 +++ b/main.cpp Mon Oct 26 15:00:52 2015 +0000 @@ -21,7 +21,7 @@ double filter_right; //general biquad filter that can be called in all the filter functions -double biquad(double u, double &v1, double &v2, const double a1, +double biquad(double u, double v1, double v2, const double a1, const double a2, const double b0, const double b1, const double b2) { double v = u - a1*v1 - a2*v2; @@ -90,7 +90,7 @@ //highpass -double highpass_filter(double input, double &v1, double &v2) +double highpass_filter(double input, double v1, double v2) { double y1 = biquad(input, v1, v2, highp1_a1, highp1_a2, highp1_b0, highp1_b1, highp1_b2); double y2 = biquad(y1, v1, v2, highp2_a1, highp2_a2, highp2_b0, highp2_b1, highp2_b2); @@ -109,7 +109,7 @@ //lowpass -double lowpass_filter(double y3, double &v1, double &v2) +double lowpass_filter(double y3, double v1, double v2) { double y4 = biquad(y3, v1, v2, lowp1_a1, lowp1_a2, lowp1_b0, lowp1_b1, lowp1_b2); double y5 = biquad(y4, v1, v2, lowp2_a1, lowp2_a2, lowp2_b0, lowp2_b1, lowp2_b2); @@ -118,7 +118,7 @@ return filtered_signal; } -double filter(double input, double &v1, double &v2) +double filter(double input, double v1, double v2) { /* function passes the input through the three filters returns the final output value as filtered sample