Filtering using FFT for audio signal
27 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Chaitanya Mallela
am 21 Aug. 2020
Refer the link
which describes the filter design allowing specific frequency components and filters out unwanted frequencies.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Digital Filter Design finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!