-
Notifications
You must be signed in to change notification settings - Fork 43
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
create filter module #23
Comments
swharden
added a commit
that referenced
this issue
Nov 1, 2020
I'll package this up in a module, but for the record here is some discrete code to apply a 2kHz low-pass filter: // convert input data to frequency domain
Complex[] fft = FftSharp.Transform.FFT(Values);
double[] fftFreqs = FftSharp.Transform.FFTfreq(SampleRate, fft.Length, oneSided: false);
// silence portions where frequency is outside the limits
double FrequencyLimit = 2000;
for (int i = 0; i < fft.Length; i++)
{
if (Math.Abs(fftFreqs[i]) > FrequencyLimit)
{
fft[i].Real = 0;
fft[i].Imaginary = 0;
}
}
// take the inverse FFT and collect the real component
FftSharp.Transform.IFFT(fft);
double[] Filtered = new double[fft.Length];
for (int i = 0; i < fft.Length; i++)
Filtered[i] = fft[i].Real; |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you start with a signal, take the FFT, edit the complex numbers, then take the iFFT, you result with a signal whose spectral components can be filtered. Create a module to make filtering easy. Something like:
The text was updated successfully, but these errors were encountered: