function DAFx_out = FunctionDirectPitchShift(DAFx_in, FS, shiftOffset) 

%----- USER DATA -----
time_stretch_factor = shiftOffset;

%---- Shifting the input ----
DAFx_out = DAFx_in;

% The order of operation is chosen to be the one that minimizes the computation time
% of time stretching algorithm.
if (shiftOffset <= 1)
    % Time stretch first and then scale frequency since output of frequency
    % scaling is longer than the original sound length
    DAFx_out = SOLA_Time_Stretch(DAFx_in, FS, time_stretch_factor);
    DAFx_out = properpitchShiftVariableLength(DAFx_out, FS, shiftOffset);
else
    % Scale frequency first and then time stretch since the output of 
    % frequency scaling is shorter than the original sound length 
    DAFx_out = properpitchShiftVariableLength(DAFx_in, FS, shiftOffset);
    DAFx_out = SOLA_Time_Stretch(DAFx_out, FS, time_stretch_factor);
end

