-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/highpass #206
base: main
Are you sure you want to change the base?
Feature/highpass #206
Changes from 7 commits
4e9db2f
e5441af
824f3ef
dbf5358
c526b7c
bab8efe
25814f7
389d3d1
d86aea2
a21e9db
ba74657
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef HIGH_PASS_H | ||
#define HIGH_PASS_H | ||
|
||
#include <stdio.h> | ||
|
||
typedef struct { | ||
//Function Parameters | ||
float alpha; | ||
float scale; | ||
|
||
float prev_output; | ||
|
||
} high_pass_st; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The convention when defining a type (atleast in our codebases) is to append _t to the type, so this should be high_pass_t |
||
|
||
void high_pass_init(float alpha, float scale, high_pass_st filter); | ||
/** | ||
@brief Initialization for high pass values | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doxygen comments go above the function, and explain the parameters and what the function returns (if it returns anything) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to fill in doc comments |
||
|
||
float high_pass(high_pass_st filter, float input); | ||
/** | ||
@brief Function for high pass filter | ||
*/ | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete notes from this if they won't be relevant to future programmers. |
||
Understanding High-Pass Filter Implementation | ||
|
||
Goal is to customize the cutoff frequency/strength | ||
|
||
One style: | ||
-alpha factor -> smoothing factor used to make the changes smoother | ||
-scale factor -> scales the output given by algo | ||
these two params correlate to strength | ||
|
||
Or user could pass desired cutoff frequency and that would be used | ||
|
||
Algorithm: | ||
1. first possibility | ||
output = alpha * last_output + (1-alpha) * input | ||
|
||
output = alpha * last_output + alpha * (avg - prev_avg) | ||
|
||
*/ | ||
|
||
#include "high_pass.h" | ||
|
||
void high_pass_init(float alpha, float scale, high_pass_st filter) | ||
{ | ||
filter->alpha = alpha; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is incorrect syntax and will not compile |
||
filter->scale = scale; | ||
|
||
filter->prev_output = 0.0; | ||
} | ||
|
||
//y[n]=x[n]−SMA[n] | ||
//The output is equal to the input - the moving average | ||
float high_pass(high_pass_st filter, float input) | ||
{ | ||
float output = | ||
filter->scale(input - (filter->alpha * input + | ||
(1 - filter->alpha) * prev_output)); | ||
|
||
filter->prev_output = | ||
filter->alpha * input + (1 - filter->alpha) * prev_output; | ||
|
||
return output; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PCA changes shouldn't be in this PR