Filtering using FFT for audio signal
조회 수: 28 (최근 30일)
이전 댓글 표시
This code i have written for low pass filters but my main objective is to filter out multiple frequency. Please help me/ guide me to modify this further to achieve that.
Fs= 8000 ;
%sampling freq
T=1/Fs;%sampling period
nBits = 16 ; %number of bits per sample
nChannels = 1 ; %number of channel
ID = -1; % default audio input device
recObj = audiorecorder(Fs,nBits,nChannels,ID);
% recObj = audiorecorder;
disp('Start speaking.')
recordblocking(recObj, recordingtime);
disp('End of Recording.')
% play(recObj)
data = getaudiodata(recObj);
filename = 'Sample.wav';
audiowrite(filename,data,Fs)
y= audioread('Sample.wav');
sound(data,Fs);
pause(recordingtime+1)
%using fft to observe the signal
NFFT = length(y); %length of signal
Y = fft(y); %N point DFT
F = ((0:1/NFFT:1-1/NFFT)*Fs).';
%respponse
magnitudeY = abs(Y); % Magnitude of the FFT
phaseY = unwrap(angle(Y)); % Phase of the FFT
figure;
subplot(3,1,1)
plot(F,magnitudeY)
title('Orignal signal')
xlabel('frequency')
ylabel('Amplitude response')
% To see the effects of changing the magnitude response of the signal,
Ylp = Y;
Fn = Fs/2; % Nyquist Frequency
fc = 1500; % Cutoff Frequency (Hz)
fcnm = fc/Fn; %normalized
n1=1:round(fc/Fs*NFFT); %low frequency band
n2=(1+NFFT)-round(fc/Fs*NFFT):NFFT; %mirror low frequency band
%lowpass filter
Ylp(length(n1)+1:n2(1)+1)=0;
figure;
plot(F,abs(Ylp))
title('LPF')
xlabel('frequency')
ylabel('Amplitude response')
댓글 수: 0
답변 (1개)
Chaitanya Mallela
2020년 8월 21일
Refer the link
which describes the filter design allowing specific frequency components and filters out unwanted frequencies.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Digital Filter Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!