% frameProcessing.m This function adjust length of signal for video analysis

function [ ZI ] = frameProcessing( blockIndex, stepSize, bufferSize, spsFormat, nfft, freqWindowing, ...
                                   virtualMicNumber, fullScaleLevel, extX, extY, extXI, extYI, surfpoint, sps32type )

    % calculating FFT on spsFormat
    frfChunk                = spsFormat( ( blockIndex-1 ) * stepSize + 1 : ( blockIndex-1 ) * stepSize + bufferSize, : );
    frf                     = fft( frfChunk, nfft, 1 ) / (nfft/2);
    frfhalf                 = frf( 1 : nfft/2 + 1, : ) .* freqWindowing;
    complexSum              = real( frfhalf ).^2 + imag( frfhalf ).^2;
    rmsChunk                = ( sum( complexSum, 1, 'omitnan' ) )' ./ 2;
    splChunk                = ( 10 * log10( rmsChunk ) + fullScaleLevel )';
        
    if virtualMicNumber == 122 || ( virtualMicNumber == 32 && sps32type == 1 )
        [ splChunk ]        = extendSPLdir( splChunk );
    end
      
    [ ZI ]                  = splInterpolation( splChunk, virtualMicNumber, extX, extY, extXI, extYI, surfpoint, sps32type );

end