-
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 6 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,8 @@ | ||
#ifndef HIGH_PASS_H | ||
#define HIGH_PASS_H | ||
|
||
#include <stdio.h> | ||
|
||
int high_pass(int alpha, int scale); | ||
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. There are no functions for the user to pass a value through the filter. 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. Documentation for the function should be in the header file and use doxygen, javadoc style comments. |
||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
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" | ||
|
||
//Samples can be modified | ||
#define SAMPLES 12 | ||
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. Make this modifiable by the user. They should not have to edit code in embedded base. This also should be available to be edited on a per high-pass filter level. |
||
|
||
//Scale Var allows adjustment of output strength | ||
//Alpha Var controls weight of prev input & sum difference | ||
float high_pass(int alpha, int scale) | ||
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. Should these values be ints? Floats might also be useful here. |
||
{ | ||
static float buffer[SAMPLES] = { 0 }; //initialize changing buffer | ||
static int index = 0; | ||
static float prev_sum = 0.0; | ||
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 implementation does not allow for using multiple filters at once. |
||
|
||
//buffer[index] = freq; //-> adding the freq input into the | ||
|
||
index = (index + 1) % SAMPLES; | ||
|
||
float sum = 0.0; | ||
|
||
//Iterates through all indices | ||
for (int i = 0; i < SAMPLES; i++) { | ||
sum += buffer[i]; | ||
} | ||
|
||
//Algorithm | ||
// | ||
float output = | ||
scale * (alpha * buffer[index - 1] + alpha * (sum - prev_sum)); | ||
|
||
prev_sum = sum; //updates the prev_sum | ||
|
||
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