%%%%%%%%%%%%%Tempo Function designed by Trenton Smith 2016%%%%%%%%%%%%%%%%
% This function is used to convert BPM into the corresponding 1/4,1/8,1/16
% and 1/4(triplet)millisecond time.
 
% Mode 1 = 1/4 delay
% Mode 2 = 1/8 delay
% Mode 3 = 1/16 delay
% Mode 4 = 1/4(triplet) delay
 
% If 0 is selected delay time = 5ms (smallest possible delay in this
% arangement

% If a delay time greater than 4 is selected that number now represents the
% delay in milliseconds. 



function delaytime = tempo(mode,bpm) 
if mode > 4
    delaytime = mode
elseif mode == 1 
    delaytime = 600000/bpm
elseif mode == 2
    delaytime = 300000/bpm
elseif mode == 3
    delaytime = 150000/bpm
elseif mode == 4
    delaytime = (600000/bpm)*.667
elseif mode == 0
    delaytime = 5
    
else
    display 'No BPM Selected'
end
    
    