%% newdoppler.m   
% written by Vishal Paul Joy
% 28th May 2013
%this function is used for creating a delay
%to call this function use delay_ (wave_name2,Fs)
%where wave_name2 is an array file(use wavread to read wav file) and Fs is the sampling frequency.
%example delay_ (waveread('wav.wav',44100))
%returns m which is an array containing the resulting effect.
% this function will be called from the newdoppler function
%See Also: WAVREAD and SOUND
function m= delay_ (wave_name2,Fs) % This function requires two values for its execution ( wav file and sampling frequency).
delay_samples = input ('enter the  delay required ');   % user defined delay value.
extra_samples = zeros(delay_samples, 1);                % creating zeroes for the dealy 
signal_delayed = [extra_samples; wave_name2];           % zeroes are added to the start of the wave file in order to create a delayed wave 
signal_no_delay = [wave_name2; extra_samples];          % zeroes are added to the end for the next step.
resulting_signal = signal_delayed + signal_no_delay;    % adding the wave file with the delayed wave file in order to create the reverb effect.
m=resulting_signal;                                     % resulting wave is stored in m.
%normalise
nor1 = max(abs(m));                                     % normilizing 
m = m./nor1;
m=m.*0.01;
wavwrite(m, Fs, 'out_reverb.wav');                      % writing the wave created into a file.
