function halfFrf = avgFft( signal, nfft, overlap )

    % check orientation of input
    if size( signal, 2 ) > size( signal, 1 )
        signal          = signal';
    end

    fftStep             = round( nfft * ( 1 - overlap ) );
    win                 = hann( nfft );
    energyNormFactor    = ( rms( win ) ) ^-1;
    signalChNum         = size( signal, 2 ); 
    signal              = [ zeros( nfft - fftStep, signalChNum ); signal; zeros( nfft - fftStep, signalChNum ) ];
    signalLenght        = length( signal );
    stepNumber          = floor( ( signalLenght - nfft ) / fftStep ) + 1;
    halfFrf             = zeros( nfft/2+1, signalChNum, stepNumber );
    
    for i = 1 : stepNumber
        chunkFft        = signal( ( i - 1 ) * fftStep + 1 : ( i - 1 ) * fftStep + nfft, : );
        chunkFftWin     = chunkFft .* win;
        frf             = fft( chunkFftWin, nfft, 1 ) / nfft;
        halfFrf(:,:,i)  = 2 * frf( 1 : nfft/2 + 1, : ) * energyNormFactor;
    end

end
