Delete Frequency in FFT File and create new WAV-File

1 次查看(过去 30 天)
Hello supporters,
I have a 0,25 seconds audio file in wav format where i want to delete some frequencies.
1) First i make a FFT to get the spectrum
2) Then i put in some Frequency i want to delete and a tolerance
3) When i've deleted the Frequency i make a IFFT to get the origin signal without the deleted frequency
I'm little bit confused from my result i got after the IFFT. I've deleted all frequency above 400Hz and in my IFFT x(t) are higher frequencys than that?
Did i something wrong in the the shifting from the fft because its symmetric?
I've also attached the WAV File
Many thanks in advance for help!! BR Mathias
Plot.jpg
clear all;
close all;
%Wav File einlesen und die Daten in data und Abtastrate in Fs
[data,Fs]=audioread('Mono_120A_v20_02sec.wav');
%Ermittlung der Arraygröße
[nSamples,nChannels]=size(data);
%Länge der Audiodatei ermitteln
waveFileLength=nSamples/Fs;
t=[0:length(data)-1] / Fs;
%Signal darstellen
subplot(3,2,1)
plot(t,data)
title('Audio')
xlabel('Zeit')
ylabel('X(t)')
%FFT des Signal
y_fft = abs(fft(data)); %Retain Magnitude
y_fft = y_fft(1:nSamples/2); %Discard Half of Points
f = Fs*(0:nSamples/2-1)/nSamples; %Prepare freq data for plot
%Plot Sound File in Frequency Domain
subplot(3,2,2)
plot(f, y_fft)
grid on
xlim([0 20000])
% ylim([0 200])
xlabel('Frequency (Hz)')
ylabel('Amplitude')
title('Freqenzbereich 70A')
yy=fft(data);
yyy=fftshift(yy);
f=Fs.*(-nSamples/2:nSamples/2-1)/nSamples;
subplot(3,2,3)
plot(f,(yyy.*conj(yyy)/(nSamples*nSamples)));
title('FFT')
%%%%%%%%%%%%%%%%%%%
Fdelete = 15000; % Diese Frequenz soll gelöscht werden
tolerance = 14600; % Toleranz um die Frequenz
idx_p = find(f>Fdelete-tolerance & f<Fdelete+tolerance); % Löschen der Frequenzen
idx_n = find(f>(Fs-Fdelete)-tolerance & f<(Fs-Fdelete));
idx = [idx_p idx_n];
yyy(idx) = 0;
Fdelete = -15000;
tol = 14600; % Toleranz um die Frequenz
idx_p = find(f>Fdelete-tolerance & f<Fdelete+tolerance); % Löschen der Frequenzen
idx_n = find(f>(Fs-Fdelete)-tolerance & f<(Fs-Fdelete));
idx = [idx_p idx_n];
yyy(idx) = 0;
subplot(3, 2, 4)
% plot(f, yyy); title('After');
plot(f,(yyy.*conj(yyy)/(nSamples*nSamples)));
title('After')
%%%%%%%%%%%%%%%%%%%
subplot(3, 2, 6)
plot(t,data)
title('origin x(t)')
xlabel('Zeit')
ylabel('X(t)')
%%%%%%%%%%%%%%%%%%%
subplot(3, 2, 5)
y1=ifft(yyy,'symmetric');
plot(t,y1),grid on;
title('IFFT x(t)')

回答(1 个)

Mathieu NOE
Mathieu NOE 2020-11-10
Hello
I would rather do a notch filter on the time data
if multiple frequencies to eliminate, do a loop
notch filter - see example of digital filters attached

类别

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

产品


版本

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by