How to extract ENF (Electrical Network Frequency) form audio signal. I want extracted ENF pattern from the audio signal using MATLAB code
11 次查看(过去 30 天)
显示 更早的评论
% STFT anaysis of 50 Hz siganl present in audio signal
clc, clear all, close all;
[x, fs] = audioread('Record_Trans.wav'); % get the samples of the .wav file
x = x(:, 1); % get the first channel
xmax = max(abs(x)); % find the maximum abs value
x = x/xmax; % scalling the signal
% define analysis parameters
wlen = 8192;
n = round(log2(wlen));
nfft = 2^n;
% define filter parameters
fn = fs/2;
fc = 50;
Fc=fc/fn;
[c,d]=butter(3,Fc);
z = filter(c,d,x);
N = 3;
w1 = 49/fn;
w2 = 51/fn;
Wp = [w1 w2];
[b,a] = butter(N,Wp); %butterworth bandpass filter of bw = 2 Hz
y = filter(b,a,x);
spectrogram(y,wlen,4096,nfft,fs,'yaxis');
axis([0.1 90 .1 100]); axis xy; colormap(jet); view(0,90);
This code will plot the spectrogram of the filtered audio sgnal containing electrical network frequency (ENF) 50 Hz. But I want the frequency vs time plot not spectrogram. Can anyone knows how to extract ENF from audio signal.
回答(1 个)
Wayne King
2014-7-20
编辑:Wayne King
2014-7-20
Do you just want to plot frequency vs. time for a single frequency component, for example 50 Hz?
In that case, you can simply extract the row in the short-time Fourier transform matrix and plot that row against time.
For example, I'll create a signal sampled at 1000 Hz with a 200-Hz component that occurs between 1 and 3 seconds:
Fs = 1000;
t = 0:1/Fs:5-1/Fs;
x = cos(2*pi*200*t).*(t>1 & t<3)+randn(size(t));
[STFT,F,T,P] = spectrogram(x,250,200,250,Fs);
The frequency spacing above is 4 Hz (Fs/250) so we know that 200 Hz will be located in bin 51 (the first bin is for zero frequency).
plot(T,10*log10(P(51,:)))
You see that the short-time periodogram has captured that the 200-Hz component is "on" for 1 < t <3
2 个评论
Wayne King
2014-7-20
This is documented in the spectrogram help, 250 is the NFFT, I kept it at 250 because that makes my frequency of interest (200 Hz) in this example fall directly on a DFT bin.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time-Frequency Analysis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!