I am processing audio and trying to obtain a 90º phase shift when processing block by block.
I have implemented a Hilbert Transformer (from Lyon's 3rd. Ed. & MATLAB). MATLAB code below (I believe this is similar to what MATLAB
function result = my_hilbert(s) fprintf("Using My Hilbert\n"); n = length(s) %fftLength = 2 ^ nextpow2(2 * n - 1); fftLength = n H = zeros(1, fftLength); H(1) = 1; H(2:n / 2) = 2; H(n / 2 + 1) = 1; x = zeros(1, fftLength); x(1:n) = s X = fft(x) Y = X .* H y = ifft(Y) result = y(1:n); end
This implementation seems to assume one is processing the complete audio stream in a single call.
I need to be able to achieve a phase shift but will be processing one block (block size between 1024 and 2048 samples) at a time.
When I simply call this implementation on each block I receive audible pops around the block boundaries.
I have considered overlap+add but when using an FFT length other than length of the input, the results are no longer the same as MATLAB's hilbert() function.
How can one obtain a 90º phase shift when processing block by block without these discontinuities?