音频信号处理-谱减法的简单matlab实现

it2025-12-11  1

谱减法在频域对信号进行去噪处理,是一种较为简单粗暴的音频信号去噪方法,原理网上有很多,这里就把谱减法的matlab实现上传,以供参考。

clear all; clc; filedir=[]; % 指定文件路径 filename1='正常.wav'; % 指定文件名 filename2='背景.wav'; file1=[filedir filename1] ; % 构成路径和文件名的字符串 file2=[filedir filename2] ; [x1,fs1] = audioread(file1); [x2,fs2] = audioread(file2); x2 = x2(1:size(x1)); x = x1; N = length(x); % 帧长 % 正变换 fft_y = fft(x1); fft_n = fft(x2); E_noise = sum(abs(fft_n)) / N; mag_y = abs(fft_y); phase_y = angle(fft_y); % 保留相位信息 mag_s = mag_y - E_noise; mag_s(mag_s<0)=0.5*abs(mag_s); % 逆变换 fft_s = mag_s .* exp(1i.*phase_y); s = ifft(fft_s); figure subplot(311); plot(x1); title('原始干净信号'); subplot(312); plot(x2); title('噪声信号'); subplot(313); plot(real(s)); title('谱减法去噪后信号');
最新回复(0)