function tremolo(input_file, output_file, step)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% tri_tremolo.m                                              %
% M Script that multiplies a low frequency oscillator (LFO)  %
% by the sample wave to provide a tremolo effect             %
% Possibility for extension:                                 %
%       -different LFO shapes (triangle, square, combination %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%clear all;
%close all;

% Reads a WAVE file specified by the string 'sample.wav', returning the sampled data in 'in_wave'.
% Amplitude values are in the range [-1,+1].
% Fs is the sample rate in Hertz. NBITS is the number of bits per sample used to encode the data 
[in_wave,Fs,NBITS] = wavread(input_file);


% 1e-4 to 1e-3
%delta=0.8e-4;
delta=step;
minf=-0.5;
maxf=0.5;

% Create triangle wave LFO
trem=minf:delta:maxf;
while(length(trem) < length(in_wave) )
    trem=[trem (maxf:-delta:minf)];
    trem=[trem (minf:delta:maxf)];
end

trem = trem(1:length(in_wave));
 %figure(1);
 %hold on;
 %plot(trem, 'b');
 %title('Triangle Wave LFO');

% Create a vector of zeros of length 'in_wave' for the output wave
out_wave = zeros(length(in_wave),1);
% for each sample
for n=1:length(in_wave),    
    
    out_wave(n)= in_wave(n).*trem(n);
   
end

% Write tremolo output to 'tremolo_out' file
wavwrite(out_wave,Fs,NBITS,output_file);

figure(2);
hold on;
plot(in_wave, 'b');
plot(out_wave,'g');
title('Sample wave form and New Tremolo wave form');
% figure(3);
% after=fft(out_wave);
% plot(after,'b');
% figure(4);
% before=fft(in_wave);
% plot(before,'b');