% makes sinusoidal amplitude modulation of tone carrier
% clear all;
srate = 44100;
dur = 1;

fc = 500;       % carrier frequency

mrate = 5;     % modulation rate

mindex = 0.5;   % modulation index (for FM = proportional change in amplitude - 1 = 100%)

amp = 0.5;      % base amplitude carrier !!! watch for clipping with modualtion

wdms = 10;      % window to stop click(need wind.m in same directory)

% end of user input


t = [ 0 : 1/srate : dur-1/srate ];
y_fc = amp * sin(2*pi* fc * t);
y_am = 1 + (mindex * sin(2*pi * mrate *  t));
y = y_fc .* y_am;

y = wind(srate,wdms,y);

wavwrite(y, srate, ['am_tone.wav']);

sound(y,srate)

figure
plot(t,y);