TP3_8: Noise removal done.
This commit is contained in:
BIN
TP3/Canto1.mp3
BIN
TP3/Canto1.mp3
Binary file not shown.
@@ -10,6 +10,7 @@ s = y(:,1);
|
||||
% F: vector of cyclical frequencies
|
||||
% T: vector of time instants
|
||||
% P: power spectral density (PSD)
|
||||
% signal, window, noverlap, nfft, fs
|
||||
[S, F, T, P] = spectrogram(s, 128, 96, 128, Fs);
|
||||
|
||||
figure(1)
|
||||
|
@@ -1,34 +0,0 @@
|
||||
%% clean environment
|
||||
clear; close all; clc
|
||||
|
||||
%% read input
|
||||
[signal, fs] = audioread("Canto1.mp3");
|
||||
|
||||
%% Compute the FFT
|
||||
signal_length = length(signal);
|
||||
fhat = fft(signal, signal_length);
|
||||
PSD = fhat.*conj(fhat)/signal_length; % Power spectrum density
|
||||
%[S, freq, T, PSDlel] = spectrogram(signal, 128, 96, 128, Fs);
|
||||
% signal, window, noverlap, nfft, fs
|
||||
freq_vector = linspace(1, fs, signal_length);
|
||||
L = 1:floor(signal_length/2);
|
||||
|
||||
cutoff_indices = abs(PSD)>0.002;
|
||||
PSD_clean = PSD.*cutoff_indices;
|
||||
fhat_filtered = cutoff_indices.*fhat;
|
||||
signal_filtered = ifft(fhat_filtered);
|
||||
|
||||
figure(1)
|
||||
plot(PSD)
|
||||
|
||||
figure(2)
|
||||
plot(PSD_clean)
|
||||
|
||||
figure(3)
|
||||
plot(signal)
|
||||
|
||||
figure(4)
|
||||
plot(signal_filtered)
|
||||
|
||||
%% output
|
||||
audiowrite('restored.flac', signal_filtered, fs);
|
Reference in New Issue
Block a user