Created
April 3, 2016 11:55
-
-
Save selenologist/ca2bab6352897f35f1ecc2ff6b2cc5ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* shoves new samples onto a kernel-sized history buffer */ | |
float convolve(const float input, | |
const float* kernel, const size_t kernel_length, | |
float* history){ | |
int index = kernel_length -1; | |
/* XXX: replace with better data structure without data copying | |
this is really inefficient! It does work though. | |
*/ | |
for(; index > 0; index--){ | |
history[index] = history[index - 1]; | |
} | |
history[0] = input; | |
float output = 0.0; | |
for(index = 0; index < kernel_length; index++){ | |
output += history[index] * kernel[index]; | |
} | |
return output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment