% make sound louder/quieter clear all; Fs = 44100; % sampling frequency dur = 1; % duration of sound (in sec) % time vector t = [0 : 1/Fs : dur-1/Fs]; % 1 second --> length(t) = 44100 % frequency freq = 440; f = sin ( 2*pi * freq * t ); %%%%%%%%%%%%%%%%%%%%% % scale sound amp = .5; % amplitude; also try with e.g. 10^-.5 (see note below) f_amp = amp * f; sound(f_amp,Fs) plot( t(1 : 2*round(1/freq*Fs)) , f(1 : 2* round(1/freq*Fs)) ) hold on plot( t(1 : 2*round(1/freq*Fs)) , f_amp(1 : 2* round(1/freq*Fs)) , 'r') % side note: % 10^(+-0.5) for every 10dB % e.g. 10^1.0 --> 20 dB louder % e.g. 10^-1.5 --> 30 dB quieter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Do not be put off by warning 'data clipped' message. % Wavwrite needs an input vector in the range -1 to +1, else it will clip. % The warning means that you have sounds that exceed 1 or -1 but the clipping will leave them unaltered