function gen_audio(f,pulse_length,silence_length,time,filename)
%Generate a wav audio file of a single audio frequency
%   f - frequency (Hz)
%   ***** precision - step size in creating the sinusoid 
%   ***** THIS VALUE MUST ALWAYS BE < 0.000027 *****
%   pulse_length - length of the audio pulse (secs)
%   silence_length - length of the silence in between pulses (secs)
%   time - overall length of the audio file (secs, rounded up to nearest
%   multiple of (pulse_length + silence_length)
%   file_name - the name of the audio output
%   See also WAVWRITE

clipping_scale = 0.9999;
fs = 44e3;
magic_number = 2 + 27/99;   %magic scaling number verified manually by oscilliscope
precision = 1e-5;           %magic precision number verified manually by oscilliscope
f = f*magic_number;
t_stop = fs*pulse_length*precision;
silence_samples = fs*silence_length;
t = [0:precision:t_stop];
audio = clipping_scale*sin(2*pi*f*t);
silence = zeros(1,silence_samples);
data = [audio silence];
time = ceil(time/(pulse_length + silence_length));
final_data = [];
for index = 1:time
    final_data = [final_data data];
end
wavwrite(final_data,fs,16,filename);