# Making sense of (buf)stats

So in playing with `fluid.bufstats~`, there are a lot of powerful things it can do, and @tremblap suggested some useful things for calculating the “shortness” of a sound after the plenary, but I’m still not sure how to best leverage it for other purposes.

So I thought having a forum post that talked about some approaches and use cases would be useful.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

My first use case is figuring out how long a sample sounds, to keep as a statistic for querying a database.

@a.harker suggested getting a time centroid, by sending `irstats~` a `center` message. This, very usefully, gives the moment in time of the sample where half of the energy is on each side of the sample (I think). This is better than what I was initially thinking of using an `RT60` measurement, which I was told was problematic.

Then using `fluid.bufstats~`, and taking the “mean of the derivative” (more confusing sounding than it is, since it’s just the first value returned by `@numderivs 1` ) to see the change over time. @tremblap also suggested taking the standard deviation of the derivative too, though I’m not sure how to make ‘real world’ sense of that one.

So between those three stats, I’ll probably come up with some kind of weighting to get a single number of “long-ness” per sample.

So at this point I have a question about weightings and aggregate statistics. If I want to weigh together three numbers, which are in different units (the “time centroid” is a number in ms (or samples), and I have no idea what units the mean (normalized amplitude I guess for audio?) and standard deviation of the derivative are in), what would be a good way of doing so?

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Now the next use case would be to try to extract meaningful pitch information from a sample. In my specific use case the samples themselves are monophonic, or rather, should only contain one pitch per sample with nothing changing over time (with regards to pitch).

They are, however, metallic sounds, so odd harmonic structures sometimes (example attached below).

Since I’m in no rush for these analyses, I’m using a tiny hop size and a medium sized window size (`@fftsettings 1024 32 @algorithm 2`). I guess I could probably go bigger for the window size, but there aren’t really low pitched sounds here. Would there be any downsize to using something like `@fftsettings 8192 32` for pitched metallic sounds where I’m only interested in pitch?

Now the data I get back looks something like this.

First the pitch value:

And the confidence is this:

Now some samples aren’t quite as consistent as this, but my thinking and questions are more about how to computationally extract the “correct” pitch from this data.

So given that my samples shouldn’t change over time, I probably don’t need the derivatives (right?)

What statistics are meaningful to extract here? It looks like the median of pitch would work in this particular example, but should I weigh that against a confidence metric? So perhaps something like taking all of the points at which the confidence is in the 80th percentile, and then taking a median (or mean?) of the actual pitch from that reduced dataset??

Is something like that possible with `fluid.bufstats~`?

Here is a more problematic example from the same sample set.

Pitch:

Pitch zoomed all the way out:

Confidence:

(negative confidence?!)

So for a sample like this there is a high confidence bump in the middle, but oddly it does not correspond with a plateau in the pitch information.

The pitch data also jumps around all over the place, and other than that flat bit in the middle, I would be worried that a vanilla median would do the trick here. Percentiles would also be weird too I think.

This poses a trickier example I think.

I’ll also attach this sample as a point of reference.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

So again, not exactly sure what the best way to go about this stuff is with stats, but just presenting a couple specific use cases which it would be good to understand better, and hopefully have others post similar “problems” here, which we could collectively find “solutions” to.

easy.zip (229.9 KB)

problematic.zip (66.8 KB)

On thinking about this further, I guess I could use `fluid.bufstats~` to find out what the 80th percentile is, then use @weefuzzy’s abstraction to dump out the entire buffer into list land, and use logic to reduce/regroup everything back into a single list and then either `zl median` it, or dump it all back into the `bufstats~` universe (`uzi` -> `poke`?).

So I guess that is possible, but it does involve lots of “in between” steps going out/in of the `fluid.`-verse to do something like this.

I’m sure there will be other statistical problems that will come up too, so hoping for more robust `stats~` to handle cases like this.

That all got a bit involved. Maybe there’s a less baroque way of doing this (e.g. js). This will filter pitches by 80th %ile of the confidence, and then return the median of the filtered pitches, using the magic of jitter.

``````
----------begin_max5_patcher----------
IHQuIYOb2e6keIGIaKaZIJkE2su3DQIQx4GGNyv4C8K2LY57rmokSAuG7Avj
I+xMSlnZR1vDy0SltM94EIwkpGa5hrsaoo7o2puGm9LW09+3YdQ7BNfugB1R
WxhSqdjR9KIT0yT0R5tsrzDJW0iPSi4w7EaXoqerftfqmQvY924cKv2el7Ov
.O4ePheAO7ZOksiW0UdlVYKUCW17O8NHJZprwe8laj+baOoxeN9yTEIVxi4k
frUhKXk8mRQHjj1vQ3dPogtjR+ocbvhDZbJcIHmIlvzR.KEDClua0JZQ0ymv
RoKx1kpdIT+wgvPENf8tKXONfwWGN36zU7MEYOAheJ9E059WoEYmY8N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y5QpMNp7eIIJmL4M5FjH2jRTIuiRePXORFTxXoN8qIBaSIgQJW0M55Q
2iXFEC8fGi.GUq3jbY2KcxYBMcs3r+JP7siiqQAbzQ.brTrVHlKzbwCJMf6M
His0d.VasaTX2ArH++.X3lAsz7W8wvsHu2D0m.3XTlEVhh5fWB0Nuqi6RCFs
BrZ9EOU+97nZvL9PmTrlLksiGMc5XkvvxixYYJChtXFCGn9zp3q+LPT+p25L
gUbZhgKaGCIeKjBpVm4mCZZv5aITbbZpmUrTmdXvAYpgsNwXGxDHGaI7DNj4
ONxRn.OfygpMj1udztXGHx3gZk7Fc33TW7lykKc7yEl75XZiw90DYpt5zaN7
FHJxy5kiAU9gsE1v.OGroPSh7F3IgMLXjKxeAMef67zemGfApfmptbfl6Da4
kHCIqDwVdIxPJuOx1xwhDLjyBaWQh7+CX0XrkVVFuldTV2G4QtKD2Z51acB1
iZOA60IXZf9S2j4St2U8ksJHXpCo3fAkXMUkpNPxGmzLVPrXWVSET5mMUaR8
uWOGS5pShaM8iuH8GZhMBrCq1trnRZTvM1.A2dP0J2mJrwjJidjVhSzkKsD+
HGhEqR1wVJKAIEN7af60hPqULRhlTEJ+wn0oR47wn5svgjZebhpWs6V.djQ.
7ZfalOy.pOgPQdiXQtY9n.fl4c87XDWJbsfpRm3AUDKtVkZ0E0IgCf7k2FQK
5ONLDRGDrL.Xv4qmwgBC76LFfGBwCJP3UwCkEK.2uhFKqDuxKfPCfXAyWpW+
NTUingXWRwhwi+vTXqdyNcDesntNqi.pWqoKo0.xgGSw.KGeTs5mNoUWmVyi
XGA81NR66kKLVdNYr7sXr7INanfWjrZbj3ibT.T63LjNuf8I6up2yNOq.cem
fDdWCRzqwJ.ZAYED75mfitORXaFIWPS91r+H.6fQBYw.4h8Fg1v64BNOK36P
GMNZYmGTr6xg3fhb+fBb+3hau8Ba+vhZWLx+5M+e.l5oMyA
-----------end_max5_patcher-----------
``````
1 Like

Very handy indeed.

I could see something like this (chained stats) being useful in some cases, so wondering if having a more integrated way to do this in the future is on the radar.

Still unsure what the best way to go about extracting pitch from the 2nd “messy” example where confidence and pitch jump all over.

Hmm, I went to test this and play with it further today and it doesn’t seem to work. Or rather, sometimes it works once, but even then, it appears to be random/rare.

It also throws up the following error messages:

buffer~: “outputlast” is not a valid attribute argument
buffer~: “outputfirst” is not a valid attribute argument

Which appear to be coming from the `p clip by pitch confidence` subpatch.

I only have Max8(.0.5) installed on my machine, so don’t know if that’s the problem, but I remember being able to test this before and it working fine. (then again, maybe I only tested it once at a time, and was lucky each time it worked)

As so often, I broke it whilst tidying up (failing to query the whole length of a feature buffer when it changes). Fixed version at bottom.

These are irritating but meaningless, and are a residue of how `jit.buffer~` works. Because it wraps `buffer~`, any attributes typed into `jit.buffer~`'s box get forwarded at object creation, but `outputfirst` and `outputlast` are specific to `jit.buffer~`, so `buffer~` complains. Dumb but harmless. If you would prefer life with nothing in your console, feel free to replace the box attributes with message calls instead.

### Fixed code:

``````
----------begin_max5_patcher----------
2859.3oc6bs0iaiaE94Y9UPXfBrs6DCQpKTNOTLEEs8wtncepIACjsosYhLk
fDclIYwt+1KuIaIacg1wbrVj8EaPpKjmOd34b34h9k6uax7rWHkS.uE7Nvc2
8K2e2cptjcbmo8cS1l7xhzjR0sMYQ11sDFexC5qwIuvU8+OdgWjrfC3aHfsj
kzDV0sv1sMaGOkvUu.OSu4I7Eanr0OUPVv0S.3rfodO.BBlI+CF5I+CI9E7A
yCQWpFqr4e7MPTbsAfxpd+PSmk7ujRT28DYG+582K+4guQp7mS9DQQhk7DdI
HaknAs7roTDBIoM+Xeqnzna.k9S63fEojDFYIHmJn.RIfx.If46VshTTc+oT
FYQ1Nl5gPmMNDEovAeuog6wAe+tvgfawJ9lhrmAIOm7E059WIEYWv5c.VsBG
pVvi83a.+IZJQtY+ZCD9wJIdPL1Jfv6VJwSwW.9wqOFDpjEBCf1fAvYNDCXj
mECxIPPtPPHMGL+KFL3TDnIwVMYzcw+RNQSoS9Hk+z1DdAULI9P2Hh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ZUBQbzP.Vbv20FtYPKM+0vFtE686A0m.3qaoLTgh5X5AQwC
tKMbrVRSy6+T89ClUyObVmtWmmVlj2p2SLbE.LmjTtxcDVkXawtL85hsM85v
gNbVfsMsKwtDKv1thfcZ5IaY531xr8n7cDZ9f93oKaWXnxm9plNbtaSFiVw6
6rIgUIOqSywbOqSta2lq6A1lc2dCxOEn+3I4GnyhV02NHUqFOTVwRcpz44DJ
R5MCKA1fA2ffLtcWQJ5HEpZ3pbY1xotuC4H7sjeHB63IwYsFdi2bbJmzdtbn
SlZVWZHNDdhvVWXHigJxnRvfiXUrcZ.QCVFBZImABq8OHGU056rRMXKorLYM
4jTJGMyyeJNFg1W3117otpyu9S8lW4gJGiDp+DFEVEwvVyq7vvVSqbzUI656
BKBmbEIVScgpCy7oIFSCh02gDaWkR.g7ISQVT+CYisjt5j61P+QlHm.6qJBB
auVJ7cI.znNS5ABP8CAObTcB2pCBM4bnGtinH0HqChe8qqjUo6nKkUdiBG9M
viZYx0pAGQWpxT+TzpsLs1AEsjejIJuQGWu4M.O73A7Zfalh7W847I1yc01k
or7ER06iGyknTWBWKHpb98ZJh0uVAJE1KAG85Kfswm2AWKZQ+4YA2aEqcCpm
u19dg3LLHvBLv+FJdPABGDOTVr.73JRhr.zJuHD5bDKX9XzFzaw7gtcbHBzv
Y7Gl54zaV6wCtMGXeNHf58zzY0Z.43y8Xfk9cB4v9O6Df21wIp9gkF9LtW73
frXbvWgwI.aw.E5eEFoPeaFoqA1EBsYjBO78P3hGIUk6NHeGDdMnJ8XMHuGL
3pLVAmCcYtqicVIT6eRjNmxCv6acUlcCgDA3qBPfsBz8tBikcizoTkV14Q03
sbPNp1tOpttOslt6tdtOtVtEi7ud++Gfk4S81
-----------end_max5_patcher-----------
``````
1 Like

Ok, here’s a pitch tester patch for seeing how accurate the pitch analyzed (in this manner) is.

``````
----------begin_max5_patcher----------
4384.3oc6cs0iiaaE94Y+UPXzBjlLqAuIQo7PwlFzlWRPB5Ffh1cWLP1l1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IpF
0ghYqTU377jnjC1vUJ7Gdh4pkatIE26aTux68oHjmDVlRPDF1Uej7.Gmp4Jz
7LnhGh5P8gX0sRcwLpi9HOLwgnNBt2ig20VPjuoEf9dPp4H4oPx1p5iI8YOe
GBgUYatPsQOjjVtUoLk3Wd+aEIqRCVDluDyf0Ru1s4RRoxqt+dcwj0R.Mr3Y
pJ4U1Y78amGzUGPvbU3YpApDrixjF4ATGImpOhYNWE9bBOhud+Gk445xz.pG
TZRj4H4uBFW+Yq8PTlChnuUrOwy2bjCB5tWClIaw4J.rdShk2nlHQtLroKzC
BQz5O7rU0dJeHEwzLorAoLlgPw9Fh2ws74TAzQ+j2Ep1VAx3khCDeLx0PqEx
SXlGkTWbXR0swF4P4ebCOF75f3Lvq4qCmkDsXREZr+ACkBJsLdvRYz5iH7JG
Vp22Qo7xHsQYPcmlpOirmTuJaVoUdR8p6Q93RgVGC4H6yXjdj1Mh.McT0GqU
0XVOzx.zkJTY4c0sJQuG4C2URYGiH7fwvUVZ+8h7xo6jVZf8qNqpZhCpCZnI
qZotrYB63Gve5CoqL3rP+4gG0wfSlmxFsaa7nCerqRq1pO5vtdwp6GBVHco6
ypXga0YTFDIKS9t9aQa4EKcC6MrDwjS0omypj.8UmBMBDXZxCwGMEtitbJGa
RFIJ7a+XvwSfPrzbUiRRFgfMicvHDhL7D32kx4m.EpQOUPPIFixUSpN7D2OH
0rEKBNZxyiBccMdI3BkDmFJc8Q9NCOM9u4QQIOb7jnz4GlQ6FxSaqFzQ1q2q
clN9Pn2Pw.58uvuS5dxQS9rRyYcjSn6n4DTUMtCBAlZL5QQgVqazkJ658yGx
vxc5SBr9ca87kgg1wOCOh2n+GPFBpuUeB0E5m6ALCMnCDDAa5hY1y8guOPj.
9d0Fe5jSo8MgCqkc+1W7au3+AMRtlgC
-----------end_max5_patcher-----------
``````

Seems to work well with the first example, but not at all for the second example.

It seems to grab onto partials/harmonics for some samples, which is expected and not very “wrong”, but I wonder if there’s a way to try to tease out the fundamental (from the stats).

It also goes a bit funny with sounds that have “bounces” in it.

Attached are the samples that I’m testing with (which are all representative examples of the sample library at large).

samples1.zip (271.7 KB)

samples2.zip (780.6 KB)

I’m just popping out, but could you expand on what not working at all entails? I listened to a sine wave of the estimated median for each sample, and there were a couple of octave errors, but none of the pitches sounded completely off. What does `irstats~` tell us here?

Patch with [cycle~] thrown in for aural comparison

``````
----------begin_max5_patcher----------
4741.3oc6cs0iiaaE94Y+UPXzBzlNwf2jnTdnXaKZyKIHEMAnncyhAx1zdTV
YIWI5clIAc+sWdQRVx1hh1ijsSZ1Gl0VRz7b934FO7Ppe5M2MYV1y7hIfu.7
Nvc28Su4t6zWRcg6J+9cSVG877jnB8iMYMunHZEex8l6I3OKzWOzKfFTc0zs
qy1JR3BcaPkW0bIwKa3lNbxDv6Ku0lHw7GiSW8PNetvbWOFcJ7dfWPf9+fp+
hwSg0sIdgtiyl8CeNA0nmiSq5Xb4EKDujn6yISTW3+9l2n9y8uRNFiXjoTLE
xvU2KINkOOaapnYuODfgug+8oncfAw63fANbDAiT9Sx93.r3y9DPRSdm33eQ
7pznD6RAAgJdM.RT+GMzlT.16xy3yeYdB+SiAeyTrJyyWy2dV4a5UP5uPDkK
Rxx1Ln57Hsxtenle8XV4Zx0hqeJNcQ1SCIeSQlQ6.MeaL70Ieit7R4RA1OAP
CuTN0WqP6arwSI13azw0tQiIeuHZdG51PKLkw7bPoUZqBwWAS0qxyx9H+S.A
uPHI7iyd3dFTu2sgWCDvnZiXgVGdO9nK4Pjn5JQeju3AYKk81CQBQd7rsBSn
L2UCHRHJpHdtXaphSk2hRKG3taxxrjjrmVkjMKJQvWuIqwvp5t4qiREyyxUr
SbVZq6pr6wSWX3RMONYcQMTXtu1TQmOw5rEF9QSfSptbVd7pXIrlvSWIdrYq
Ewy+PyefpmrlzQX0CVd2MOFUvs07MwxQqN3t+y1njXwKGg7DwRCihbtrsk+3
f2qukVzbHik.O7FavH3TOo.Hy3R0Z.kX3HpXJETERH+zXvYQJIX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pMVLa
kZGnLOKI6fSerpL.Nwb2pEdu9YeG.NEGRQp2v4voDDgg80eR9AOulkRioMnp
FQ8ngPr5Qo9XF0S+o.Lwin9Dbulg20WPTnoGfgAPp4SxKgj8UylEktp7zzh0
3HgRcnHkkWerhMkDV+7aEYqxiVDWt4jgspnf6KEkxk2c+5PXxZIfFW0llhd0
CFe014Q1F.hlqRMcKPkfk.jl6ndRNU+Il4ZM3yI7D958aJKv2moAz.nLFJym
j+JXb61NaUqlEBoHltKCB8nLloY3PyOkmec6Z0JJyCQzOANjHan9SdHn+dDZ
gjRmq.91jJV9fZlC4yvlg9.HDQa23lmXaRMwuYCOE7sQoEfukuNdVVxhcIjV
ktacW7Pr5r1ofWK4PBwHeC4UI5gYATBZeToekgZAkNzGbTFssFQPsdP.C5ED
1pmg0khNLxOuEnctY2TRzenHIV5i9epbfaSld+QuV+oJthWIsrN5Ye0RDdZd
bL.csURV4Pcm5N6Q9vcE29oHYOXLbiCPldQdoaKYjF3vldUUdCndnglrZUQG
GmvNc6.muJcCkyJijG9IKJmr.ULZ2ezOcXytIiZqs1gaihMOecbP5ROl0HB2
ltFFDIKyR7+mS1xq1ZYtGXIhI8YocVTSfgpKgFABLO6ozSlB2QWd05ljQhB+
KuDc5DHDKCP1XjjQHXitCFgPjgm.+xbN+LnPM5oxZJwDbsxo5vSbeszxVpH5
jIu.Jz22DsuOTRbZnzODE5M7z3+hmjj8jcR7v.M8Bgv.aQaFHmjCyX8CEnCE
T1FO5vx.5y52uTN+lSFgY0wk5Icn6ooTTSKtCBAlaB5QQg1yuvoQaGKjaepT
hIrTSiUN6TIdGNn5b63mgGwO5DIfLDT+ngDpOLrbN2LzfJGIh1zmzeiYo7UQ
hLvWoNjvmbN8urM+227+.Gt6lD.
-----------end_max5_patcher-----------
``````

The `irstats~` is just determining the time centroid, so it basically plays the sinewave for roughly the duration as the sample is fading out. Not necessary, but a simple touch to make it easier to compare.

With some of the examples I attached I get wildly inaccurate results, particularly the “hard bounce” and “soft bounce” files (more so the hard bounce ones).

That’s why my patches are all messy

Bumping this thread, as I’m running into this problem again/now.

To resummarize, I have a few different descriptors that I want to query/compare against an envelope follower so that the busier the playing is in my live audio, the shorter the samples that are queried from the database, and similarly, if my playing is more sparse, to have it learn towards longer samples.

So I can do a single->many mapping where the envelope follower is just scaled to each descriptor, but that won’t really give me any weighting, which is useful if one value is spiking but others are not.

How is this generally handled, in statistics? Should I come up with a(n arbitrary) function that combines the three descriptors together into a single value, and then match against that? How would that work in terms of turning that information back into an actionable query for `entrymatcher~`, particularly if the `<->` matcher is euclidian (??).

1 Like

A quick question here: why don’t you just make a label in your samples (around a rounded duration) and query with that as first condition? The label could be devised in snap/short/med/long/drone for 50-150-600-1200 ms (this is guestimate, but I’m sure @weefuzzy has, in his machine listening literature, some approximated lenghts for these from psychoacoustics)

I would use a certain metric on the corpus analysis that checks the overall amplitude variation (to avoid long tails), a sort of dynamic range allowed between the median and the max, or 90 50 10 centile… I’m just riffing here, there is a way to do that cleverly but I don’t know yet… looking at the stats and their first derivative will probably give you some intuition of what is useful. @a.harker’s famous example of @tutschku’s loudness description of a grain was useful to understand how time is an important factor in all this…

1 Like

Yeah totally. The time centroid is actually quite good for telling the overall “length”, and weighed against things like amplitude derivatives would give me a strong idea but I’m still not sure on how to best query for that.

Like, I can query for time centroid first, then derivate, etc…, but having a linear(?) query could probably leave out some better samples if the first criteria isn’t really representative of what’s going on overall (i.e. a high time centroid that is skewed too long because a really long tail, even though the transient is quiet loud/fast).

So I guess it’s more of a many-to-many type question where I want a thing (“perceptual length”) which is measured by oodles of other things, which I want to weigh(?) together in some manner when querying.

TLDR but I skimmed - it seems like you are saying that the key goal is a descriptor of the perceptual length of a sample?

A few points:

• in general in statistics you don’t combine items of different units, because it doesn’t make sense in a general context.
• You can either match on a set of descriptors (yes of course you might not always pick optimally, but this is somewhat approximate work)
• Or you can design a new composite descriptor - this is more complex but has the potential to be more meaningful - the problem is that you have to decide what perceptual length means. For instance, if I have a sample with a sharp attack (lots of energy at the top) but a long resonance is it long or short? Also knowing how your samples are constructed might help - the problem is quite different for sounds with many attacks within them than sounds you know are percussive decays with a small number of associated attacks.
• I’d suggest that in terms of energy distribution (or loudness or whatever) that the spread of the energy over the sample (which would be in units of time) might be a useful indicator of its length, but you might also want to clip your data in the case that you consider some base level of amplitude to be “active/on” and you don’t want the calculation to be too biased by loud percussive peaks. The time centroid is simply an easy thing for one sound samples that are likely to have early centroid if front loaded/percussive and later if more sustained - spread is probably more accurate to telling you how much of the sample most of the energy is distributed over.
1 Like