how to get back audio after filtering and applying ifft
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
clc;
clear all;
srate = 10000;
time= 0:1/srate:2;
f=500;
x1=sin(2*pi*f*time); %random noise
%sound(x1);
subplot(421);
plot(x1); %ploting noise
title('signal1');
f=900;
x2=sin(2*pi*f*time); %random noise
%sound(x2);
subplot(422);
plot(x2); %ploting noise
title('signal2');
signal3=signal1+signal2;
subplot(423);
plot(signal3);
swavex=fft(signal3)/npnts;
hz=linspace(0,srate/2,floor(npnts/2)+1);
subplot(424);
m1=2*abs(swavex(1:length(hz)));
%sound(m1);
plot(hz,2*abs(swavex(1:length(hz))));
set(gca,'xlim',[0 max(f)*1.3]);
xlabel('freq (hz)'),ylabel('amplitude (a.u)')
[m2,l]=findpeaks(m1)
s=size(swavex);
z1=[ones(1,600) zeros(1,19401)];
a1=swavex.*z1;
subplot(425);
stem(a1);
xlabel('freq (hz)'),ylabel('amplitude (a.u)')
title('filtered signal');
srate2=0.5;
time2=0:1/srate2:2;
npnts2=length(time2);
reconSig = ifft(a1);
hz=linspace(0,srate/2,floor(npnts2/2)+1);
m2=2*abs(reconSig(1:length(hz)));
subplot(426);
plot(hz,2*abs(reconSig(1:length(hz))));
set(gca,'xlim',[0 max(f)*1.3]);
xlabel('freq (hz)'),ylabel('amplitude (a.u)')
sound(m2);
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Simulation, Tuning, and Visualization 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!