Following my previous question: HRIR Minimum phase I managed to compute the minimum-phase phase of a FIR filter (in my particular case, HRTF filters).
However I am not sure of the phase values returned by my function.
The Python function is the following. It expects an arbitrary HRIR as input. I am using a 44100 long FFT to have the freqency bins perfectly aligned at integer frequencies at 44100Hz sampling rate (so for example a sinusoid at 1000Hz will have a magnitude of exactly 1 with no spectral leakage)
import numpy as np import matplotlib.pyplot as plt from scipy.signal import hilbert from scipy.fft import fft, ifft, fftfreq def min_phase_coversion(HRIR): HRIR_fft = fft(HRIR,44100) xf = fftfreq(len(HRIR_fft), 1/44100) phase=np.angle(HRIR_fft) minimum_phase = np.imag(-hilbert(np.log(np.abs(HRIR_fft)))) plt.figure() plt.plot(xf, phase) plt.plot(xf,minimum_phase) plt.plot() plt.grid() plt.show()
For the following plots I am using the KEMAR MIT dataset, in particular the plot have been computed for the HRIR at
[azimuth=144°, elevation=30°, distance=1.4m]. The selected HRIR is the following (one per ear):
However, looking at the plot, I can't understand the values returned by
Is the returned phase unwrapped? Or am i doing something wrong? The original phase "wraps" as expected once it gets over +3.14 or under -3.14 (+/- pi), while the minimum one doesn't.