
function [Yfa] = DOPPLER_SHIFT_APPROACHING(fo,vs)

% Calculates the perceived frequency of a sound emitted from a source travelling directly
% towards a stationary receiver. The pitch will not fluctuate because the object
% travels directly towards a stationary receiver at a constant speed. The approaching frequency will be higher then the true frequency, and the
% receding frequency will be lower than the true frequency.

%==========================================================================

% Input Data
c  = 344;   % m/s
% fo = ();  % Hz - emitted frequency
% vs = ();  % m/s
fs = 44100; % sample rate
time = 2;   % duration of the new observed frequency in seconds

%--------------------------------------------------------------------------

% Output Data

fa = [c/(c-vs)]*fo; % calculates approaching frequency
Yfa = sin(linspace(0, time*fa*2*pi, round(time*fs)));

%--------------------------------------------------------------------------

sound(Yfa, fs);  % Listen to observed approaching frequency

audiowrite('approaching_pitch_shift.wav', Yfa,fs);

end %==========================================================================

