function shiftedSamples = properpitchShiftVariableLength(samples, FS, shiftRatio)

N = length(samples);
Nfft = N;
W = hanningz(N);

shiftOffset = shiftRatio;
shiftedN = Nfft/shiftOffset;

samplesW = samples.*W;

spectrum = fft(samplesW, Nfft); 
% shiftedSpectrum = zeros(Nfft,1);
% 
% if (shiftOffset > 1)
%     for n = Nfft:-1:1
%         n;
%         shifted_n = floor(n/shiftOffset); 
%         if (shifted_n < 1)
%             shifted_n = 1;
%         end
%         shiftedSpectrum(n) = (1/shiftOffset)*spectrum(shifted_n);
%     end
% elseif (shiftOffset < 1)
%     for n = Nfft:-1:1
%         n;
%         shifted_n = ceil(n/shiftOffset); 
%         if (shifted_n > (Nfft/2))
%             shiftedSpectrum(n) = 0;
%         else
%             shiftedSpectrum(n) = (1/shiftOffset)*spectrum(shifted_n);
%         end
%     end
% else
%     shiftedSpectrum = spectrum;
% end
% Adjust the original spectrum for aliasing
for i = 1:(Nfft/2)
    i;
    spectrum(Nfft-i+1) = 0; % For removing aliasing 
end
shiftedSamples = real(ifft(spectrum, shiftedN));






