function z=addnoise(y,n); % ADDNOISE: Adds tones to a sound (so that you can try to remove % the tone afterwards). % % y=ADDNOISE(y,1) adds a single tone to y. % y=ADDNOISE(y,2) adds another single tone to y. % y=ADDNOISE(y,3) adds three tones to y. % % Example: % y=auread("bart1.au"); % load in some sound % sound(y); % play the sound % z=fft(y); % compute Fourier transform % plot(abs(z)); % look at the spectrum % % y=addnoise(y,1); % now add some noise % sound(y); % play that % z=fft(y); % recompute Fourier transform % plot(abs(z)); % look at new spectrum % Authors: % Karl Bauer and Alexander Perlis % SouthWest Regional Institute in the Mathematical Sciences % c/o Department of Mathematics % The University of Arizona % Tucson, AZ 85721 % bauer@math.arizona.edu, aprl@math.arizona.edu % % Obtain the latest version of this software from: % http://www.math.arizona.edu/~rims/workshops/fourier/softwareMATLAB % % Bugs/problems/ideas: % None. % % Change history: % Dec 1997 Originally three separate programs by Karl Bauer % Dec 1997 Combined into a single program by Alexander Perlis %---------------------------------------------------------------------------- L=length(y); t=1:L; t=t/8192; switch n, case 1, f=8192/4, z=y+cos(2*pi*f*t); case 2, f=8192/3, z=y+cos(2*pi*f*t); case 3, f1=1235, f2=2476, f3=3431; z=y+cos(2*pi*f1*t)'+cos(2*pi*f2*t)'+cos(2*pi*f3*t)'; end; % [eof]