On Sat, May 20, 2023 at 05:15:03PM +0200, Florian Paul Schmidt wrote:
1. Are there any glaring oversights with this
approach?
The minimum phase step is not really necessary, you could just use the
linear phase version, the output of the IFFT rotated by half its size.
If you do the minphase operation, the best way to do this using an FFT
that is at least 4 times as long as your IR. In other words, take the
linear phase version in the time domain, add zeros, then do the
minphase calculation.
2. What is a sensible approach to regularize this
approach. If spectrum
1 has any components near zero magnitude then the division is ill
suited. It works fine for my experiments with distorted guitars, but I
wonder whether I should e.g. just clamp the values of spectrum 1 to
something like -70 dB?
This probably should not depend on the absolute values, just on the
ratio, i.e. the calculated gain. If r = s2 / s1 you could impose a
smooth maximum:
g = r / sqrt (1 + M * r * r) with M in the range 1e-3 to 1e-2
Or you could even reduce the gain if r is really very high (which
probably means there is nothing of value in s1 at that frequency:
g = r / (1 + M * r * r * r) with M in range 1e-5 to 1e-4
Try this in gnuplot:
plot [0:100] x / sqrt (1 + 1e-2 * x * x), x / sqrt (1 + 1e-3 * x * x)
plot [0:100] x / (1 + 1e-4 * x * x * x), x / (1 + 1e-5 * x * x * x)
to get an idea of what these will do.
Average levels in the two input files should be more or less
matched, before applying any of these.
3. If the user wants to smooth the spectrum before
calculating the
responses what would be sensible approaches? I thought about smoothing s
with a filter that has a varying bandwidth when expressed in FFT bins or
Hz, but constant, when expressed in e.g. octaves or decades. I'm not
sure how to do that though. Any thoughts?
That is a good idea. Above say 500 Hz anything smaller than say 1/3
octave probably doesn't matter much.
There are many ways to do this. One would be to use the exact per-bin
levels at low frequencies, and a moving average that increases in
length as frequency goes up. Use an odd number of bins to sum (to
avoid shifting peaks), and sum powers, not amplitudes.
The window used in the analysis will also provide some smoothing,
with a raised cosine anything at the center of a frequency bin will
also show up 6 dB lower in the two adjacent bins. That limits the
resolution as low frequencies, but that probably not a bad thing.
Ciao,
--
FA