I am implementing a morse code decoder in Octave. It already works, but not on very noisy signals, like the following:
I had the following idea to reduce the noise:
- Perform fft to find the "beep" frequency of the morse tone
- Use a bandpass filter to attenuate all other frequencies.
Unfortunately, I apparently can't do step 2. After filtering, my signal looks like this:
This shows about the first two milliseconds of the signal.
My code looks like the following. Please tell me:
whether my basic idea is promising
how to improve my code in a way that it actually does what I want
[x, f_sampling] = wavread(filename); t = fft(x); l = length(t); magnitudes = (abs(t/l))(1:l/2+1); f = f_sampling*(0:(l/2))/l; [peaks, locations] = findpeaks(magnitudes); [maximum,index] = max(peaks); f_main = f(locations(index)) f_cutoff = [0.1 0.9]*2*f_main/(f_sampling) [b, a] = cheby1(20, 1, f_cutoff); y = x / max(x); y = filter(b, a, x);
findpeaks
part. I was initially wondering if you were interested in filtering out a specific "beep" frequency. Since you are already doing the FFT, why not set everything except the two "highest peaks" (the f and its symmetric) to zero and then IFFT? $\endgroup$ – A_A Oct 30 '16 at 22:29freqz
to visualize the filter's frequency response and see if it actually matches what you expected to get. $\endgroup$ – MBaz Oct 30 '16 at 22:33