Fluid.bufmelbands~ not outputting bands at certain fft settings

So I’m working on tidying up that spectral compensation patch from the other thread and I’m noticing some weird funny business where I’m not getting values returned for certain bands from fluid.bufmelbands~.

Here’s a patch which shows what I mean:


----------begin_max5_patcher----------
6085.3oc68r1biajbed2eEH5bU4wIwZdiAIeYum9RE6KNwNkqT1WoBjDRBdA
AX..kVYW29aO8LC.H.H.3PP.JY6UePhZvioeOc2SOM+o29lqVl7gfrqb9Wc9
Nm27le5su4M5gTC7lh++MWsw+Cqh7yz21UqR1rIHN+pqMWKO3C45wEKbf66t
zf+OG+nrD3edePlS9Cgw2m47TPX55xGIJLNXUxtX8yQJFbaZPF7Z8yCShusy
63tj3767WEnFCWLV3Z8bmr7Gtg4U99i2sILNJHOq9cpd5rveT+zDzBz96MYW
d4MWN5xcKWFEz9wi82nG6p+RPziA4gq7Kmws94qTH5soAqxMDSLxi.yhCVPV
fQTLkKQdXLGIkW6Pn5qwA3v4uodE+829V0ut9L4A7ENqdvO9d.Tbt6tbGEB6
78WcWHvi+9qbByu1Y4tbm+cm0Iw+ivkCBbd5gmgwcxdHYWzZfokmGjNRFE2R
Fk6qKFEVxULCBirfQELgGlQXLIi6csCkQOKFEPNS2EVN6qCy1F4+7lj0Zvid
HsgSGj1zjHTNpZRzuAfkmEjmqz3JeMlaO+4sAFr8pqb9a8SKjddZRAWzjTfH
vftR80HSrLKagyxj77jMNAwqcRtyIaK.Oo613Dkj79Lm61s58Aca6fdTQRpk
hj7wHRZD9xBaxMmMAUfOnX.BPbEKPtXgGGyITvDiKVcA2o1ZBcAXmXG.12rJ
Jb06ASG2cWPpy+T9C.4VanIqvPhhS47TZHX7H1IO4edjbKlkbK1OC3VDs1BS
RZwrHD5rvrHKbL7k6RAvLywOM.VG9I+mybB1rM+4QZS2VEH5qJa5RoVif4cH
0mOKK7NSTeaWQk7Zj5S83MVEAb5Y9X.3ENO.twnVd8JKIZ3oinc5NcXVnUJW
vA62HM8hHlXZBZAXX1e8RvgPaoInWPZhfqW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SFmdpNX6On5UoyuJw9RM.OAY0CeD40IO4GSdF8Zl7iNrgXapiqRrf0I
geRjT9ghS7CBUTd5Swqhb5xa6SX+AeX5Ry1.YAF8yLIs1dqy6cOHrEsOXeHV
FE.KYZ1IveeRx6uZxD4Bie+XjPttwumf7uV8pA1BRVsXOUnZU8CueBym8p4c
uDrbq85bO0NJU5PiXV7Lclahi+Xm78efZw9cjPe6z5e53KjOzTNIpIG1Mcd4
bVJR4JwwcgtctQPdrhRVPWWlEexUZQ0RXUyd3rwqF8UDKvo965Oiqi+bw2Ng
Vc0GKb20lN4yj.VM5XOSccTbxclmQ1UdlYe.rzl+DIU0T6vNtX8trisIcafN
qyYKYcXGzw5n+spq4LU.X8tii0P3kwH4gc9F6SfhMc6lIB.azUaNsT7LPmrY
h.tVcrFqAOq5RMSDL9eGr9jgO2JuewUwVfJVwXpgulcKG6Ig1zgbFt63LsH.
4miHvAswG6EQro08b1.31coaiBNImSYHieMDNR3okgIRtfHszCM2pZRT8cKm
zj2ak0iIU0LMXUP3iCuyccIyTEb2dfCUu.HmFfqceQxJJukcCnQzGjNaDJKH
dc1qsUPNrILMc5dcVrq1zzkNarpp4J0+tQOTCUZBl+r7f61EEkezMXoc4XJ4
brIi3BpK0Tz6BP6ZnM7RcVWb02pnJn.UFDbkSKQ0fTmLNQjtRieFzJIYJwi1
5qigwEp9KH8P0lqdMcdAdRkMmmO8jeh87PFu+.4LVwVZKPHJtYAV2DvUM8ki
jFKjhMnCmkVP8AqFEaYw.kE4eLLM+Ym+z8IVTYjGqV7OcBq4nyo2AOELkssf
EpaTMu8u+1+e.a4ZGJC
-----------end_max5_patcher-----------

It appears that there’s something strange with regards to @fftsettings and @maxfreq where there appear to be gaps in the bands.

Stuff like this:
Screenshot 2020-06-21 at 7.16.06 pm

Or this:
Screenshot 2020-06-21 at 7.16.23 pm

Is it the case that depending on your @numframes, @fftsettings and overall @numbands, there will be “holes” in what can be represented.

Is this a bug or a byproduct of the process/algorithm?

If the latter, perhaps this could be explained in the help/reference and/or capped to ranges that will still produce values (like how @numbands gets capped).

Also, is there a way to figure out (without guessing) what would be the most resolution I can get out of @numframes 256? I was aiming to limit it to 200-10k Hz as my low frequency resolution will be pretty dogshit anyways, but I still wanted some resolution in the higher end.

Those settings, however, produce tons of gaps. I’ve played with the min/max freq a bunch and it provides some different results, but no obvious pattern to the gaps.

Bumping the fft settings up to @fftsettings 512 64 works right away, but since my @numframes is still 256, I think I’m just filling the rest with things outside of my desired window(?). Or, in other words, the max fft size can’t be greater than the @numframes can it?

I don’t think this should happen, no: presumably when the resolution is isn’t great in the lf, something is going screwy selecting the bins that contribute to a particular mel filter. That said – not having looked in detail – the algorithm may just not be tractable when the number of bands gets too close to the available resolution. I will enquire of the guru…

The fft size can be greater than numframes, yes, because the fft size is only constrained to be at least the window size. So you could use @fftsettings 256 64 512

1 Like

That’s what started occurring to me when I was whipping up the example patch. Either way, it’s something that’d be good to know for reference/knowledge purposes.

This starts getting real brainfuck-y for me. But would @fftsettings 256 64 512 pad out the rest of the frames (meaning whatever (potentially) suspect math is going on will still render usable bits) or is it then working with a “bigger” number of frames? (with the rolling buffer setup here, I believe what would be in samples 257-512 would be random since it’s what happened at some unrelated point in the past while the loop was going).

It pads the window (256 samples) with zeros to bring it up to 512 samples for the FFT.

https://jackschaedler.github.io/circles-sines-signals/zeropadding.html

1 Like

Awesome!

And to follow up with a naive FFT101 (128?) question. This is beneficial in this specific circumstance because “something else” is going on correct?

As in, with such short windows, should I zero-pad the other spectral descriptors (and/or loundess) as well?

:rofl:

Possibly ‘something else’, tbc. The mel bands process basically involves making a filter bank in the spectral domain, and it looks like some coefficients end up being zero. Possibly this is a quantisation error when the number of bins relative to the requested number of bands is too small, possibly it’s intrinsic. But, yes, it’s a workaround here because the zero padding gives us an effective interpolation between FFT bins.

I think it’s only of possible benefit when frequency estimation is involved, so I certainly wouldn’t bother in the case of loudness (which, IIRC, only uses an FFT for the true peak estimation anyway). It’s important to remember that it’s not ever a substitute for just using a longer window in the first place: i.e. it doesn’t magically give you access to information that wasn’t there before. However, you may find that the interpolation from zero padding yields better results for you with things like spectralshape~. For pitch~ it might not make much difference, because there’s already quite a lot of work being done there to try and come up with interpolated frequency estimates. Also remember this comes at a (slight) extra processing cost.

1 Like

Awesome, I’ll test this out, particularly with regards to the processing time.

At the moment all the things I’m analyzing (in real-time) (loudness, spectralshape, melbands) come in around 0.3-0.4ms, which I can totally live with. Particularly since I’m shrunk my overall analysis window from 512samples to 256samples. I basically now have around 6ms less latency “for free”.

My @fftsettings were the same at the bigger analysis window (I just had more frames for the fluid.bufstats~-ing), so will see the impact of speed now.