0

I have two audio files and my task is to figure out a minimum phase transfer function that matches the files as closely as possible (there is lots of noise in the files so perfect match is not possible). I know the characteristics of the filters and have to figure out the Q and frequency. I have the files imported into Python already using soundfile, so that is not an issue.

Due to various reasons, the best bet is to match the phase instead of the amplitude. How would I calculate the phase difference of the two files and output a (smoothed) plot with natural frequencies (hz) in the x-axis? I think a sizeable plot would be enough to match the filter using eyes.

Order of operations I came up with:

  1. Calculate Fourier transform (Or FFT if this is not possible).
  2. Convert FFT into polar notation (magnitude/phase).
  3. Subtract the phases from each other.
  4. (Smooth) and plot the results.

The first step is easy enough using numpy:

import numpy.fft
FFT=numpy.fft.fft(data)

I wonder if there is some command that can automatically extract the magnitudes and phases out of the FFT for the 2nd step. Thus far no luck. This is the step I most need help at.

For the 4th step, first create the index frequencies using fftfreq command, and then remove the negative parts of the plots (which are stored after the positive in the arrays). Plot afterwards:

freq=numpy.fft.fftfreq(N,1/44100)
freq=freq[:N/2]
FFTPhase=FFTphase[:N/2]
import matplotlib.pyplot as plt
plt.plot(FFTphase[freq])

Only problem is that I recieve an error message: "IndexError: arrays used as indices must be of integer (or boolean) type"

Dole
  • 339
  • 4
  • 16

0 Answers0