首页 > > 详细

辅导matlab设计、matlab讲解、调试matlab设计、matlab Assignment解析

function AddNoise(ps)
% AddNoise Add simple noise to an audio file.
% Loads an audio file using audioread, adds a simple noise vector and
% writes a wav file using audiowrite to the same folder.
% The processed audio file is stored as "(filename)_noise.wav".
%
% AddNoise(filename) Process audio file given by parameter filename.
%
% See also audioread, audiowrite.
A = 0.5; %Amplitude of noise
f = 1000; %Hz - Base frequency of noise
[y,Fs] = audioread(ps.wav);
y=y(1:20*Fs,:);
t = (0:1/Fs:length(y)/Fs-1/Fs)';
noise = A*sin(2*pi*f*t);%+A*sin(2*pi*1.3*f*t)+A*sin(2*pi*1.5*f*t);
y(:,1)=y(:,1)+noise;
y(:,2)=y(:,2)+noise;
[pathstr,name,ext] = fileparts(filename);
outfilename = fullfile(pathstr, [name, '_noise', '.wav']);
audiowrite(outfilename,y,Fs);
end
 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!