Hello,
I wrote the code below to plot .wav/.mp3 files in both time and frequnency domains then filter each selected sound and plot again (bandpass filtering). The first part of the code works fine. Then the filter designer GUI pops up and I export the filter in Hd and run the rest of the code. The output (.wav or .mp3 and the last plot) seem to be the issue. Can you please help? I can not pinpoint what I did wrong.
%% Filtering% clear all; clc;close all;[signal,Fs] = audioread('Rooster_un3 copy.mp3');%% Check channels and convert to monoif size(signal,2)==2y= mean(signal,2);elsey=signal;endNsamps = length(y);t = (1/Fs)*(1:Nsamps); soundsc(signal,Fs)%% Time_domain plottingsubplot(3,1,1)plot(t, y)xlim ([0,5])xlabel('Time (s)')ylabel('Amplitude')title ('Signal in Time-domain')%% Fast Fourier TransformyFT = fft(y); %% Prepare plot FTy_fft = abs(yFT); %Retain Magnitudey_fft = y_fft(1:floor(Nsamps/2)); %Discard Half of Pointsf = Fs*(0:Nsamps/2-1)/Nsamps; %Prepare freq data for plot%% Frequency_domain plottingsubplot (3,1,2)plot(f, y_fft)xlim([0 20000])xlabel('Frequency [Hz]');ylabel('Magnitude');title ('Signal in Frequency-domain') %% Filtering% filterDesigner%% Generating bandpass filter and plottingFilteredSignal = filter (Hd,y_fft);FilteredSignalTransform =ifft (FilteredSignal);subplot (3,1,3)plot (abs(FilteredSignalTransform(:,1)));xlim([0 20000])xlabel('Frequency [Hz]');ylabel('Magnitude');title ('Filtered Signal in frquency_domain');sound (FilteredSignal,Fs)audiowrite('Filtered.wav',FilteredSignal,Fs)
PLEASE note that to run this code completely you need to design a filter.
Thank you,
Best Answer