How to extract ENF (Electrical Network Frequency) form audio signal. I want extracted ENF pattern from the audio signal using MATLAB code

조회 수: 10 (최근 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
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
Hemant Nagvanshi
Hemant Nagvanshi 2014년 7월 20일
편집: Walter Roberson 2015년 9월 29일
[STFT,F,T,P] = spectrogram(x,250,200,250,Fs);
x - signal
what about
250
200
250
what are they
Is
250 - window length
200 - noverlap
250 - ???
Wayne King
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 CenterFile Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by