How to find the frequency of a morse code (sinusoidal signal) mixed with an audio music signal from a .wav file?

7 次查看(过去 30 天)
I have a .wav file which is a mono (1-channel) 11,025 samples per sec, 16-bits per sample which contains an audio file mixed with a morse code signal (sinusoidal wave) with unknown frequency.
I need help with writing a matlab code to determine the frequency of the sinusoidal signal and separate the morse code signal and the music signal using window filtering (fir1) and save them in two separate .wav files.
% Read project wave file
[Y,Fs]=audioread('sound.wav');
L=length(Y);
% take L-point FFT, compute magnitude, compute 20log10 of mag
y=fft(Y,L);
M=abs(y);
dB=20*log10(M);
% plot the 20log10 magnitude result
nF=((0:Fs/L:(Fs-Fs/L))/(Fs-Fs/L))*2*pi;
plot(nF,dB);
title('frequency domain');
xlabel('Normalized frequency(hz)');
ylabel('magnitude(dB)');
% FIR Filter using window method
m1=fir1(500,0.020,blackman(501));
n1=filter(m1,1,Y);

回答(1 个)

Star Strider
Star Strider 2022-11-27
Start with the pspectrum function to analyse the signal, using the 'spectrogram' option, or just use fft, although if the Morse signal and the music have common frequencies, fft may not be the most robust approach.
After that, a simple FIR filter is straightforward with fir1, although I usually start with kaiserord.
.
  4 个评论
Star Strider
Star Strider 2022-11-28
First, even for FIR filters, the filtfilt function is the best option to do the actual filtering, not filter.
The filter appears to be a lowpass filter. Consider using a bandpass filter instead if the Morse signal has a single frequency, or a restricted band of frequencies.. This will produce a cleaner result.
I always sugest analysing the filter using the freqz function to be certain it is doing what you want it to do, and has been designed correctly.
The filter itself is a separate object and is not part of the sound file. If you want to store the sound files (before and after filtering) and the filter itself, save all of them to a .mat file. Be sure to include the sampling frequency ‘Fs’ as one of the variables.
It is also possible to use audiowrite separately to store the filtered signal. You can still save the filter as a .mat file separately.
It all depensds on how you choose to approach this and what you want to do.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Measurements and Spatial Audio 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by