Weighted averages for spectral descriptors

Ok, here’s a better example.

Analyzes entire files with percussion strikes, so most of the energy/loudness is at the start of the file.

I also added a bit at the end to listen to the results (sending noise through an svf~).

The results for the weighted version definitely sound more like the sample you feed it, though counterintuitively, this meant that the weighted centroid was generally considerably lower than the vanilla mean. (I would have guessed that the silence would have pulled the centroid down)


----------begin_max5_patcher----------
3775.3oc2cs1iaabE8yq+UPHzOErq579Q+TRZZc.pcZPsKLJBJLnjlcMsoHE
HoV60Aw+167fh5EE4PoQq1sNHan4xQybOy4dt24NCU98Wb0nI4eQUNJ5uD8a
QWc0u+hqtxdKyMtp9ue0n4weYZZbo8wFMMe9bUV0nqc+tJ0Wpr2mNNJMorRk
EUkGMU+DE4IyJW8XoIYpo4KyrOKp9lKJTk5GLtJIO68s+DwUS+PR1cuuPMsx
MJEbvX50QTJcrPvfHNjh3R.AytNBB4iAWGQXiAQ+25OhayyptMdpxzZX88Rl
YGx4S93ML7nMdvxjuZePDP+43tc1x4IYoppxM+.LOaV7b6yN5mUo2qpRlFOZ
cSxWVspM.yM+iW7ByOt9oDHSNLHi3DCPFLPF8bBjIaBx2ljpBOIVhLPHVfGS
3bJPhf.AgJPjqiDxAitvmSnKZbTbVb5CesAVaAevBK+CyGi2i9AvleEZH.D3
4D.AGGUnVjpMmsHeGEOS6+ZvJJZedFDSGJNRkOEwwIKqpxy5fLAgPm219jIj
klY9YCF3FMUOrP4Z8nIwY2Mp4WuIbHV2oEZCrRU7dUV7jTaK6DS11pgAj8.z
hW4wyrC5Sg4.EVUdtN..C27OHiCncBeXDG1SQhybUYY7cp8fvxp3hptDmfLS
FHL.aLDuCgBaE1QntHTsSl.iZCKPAivjo9rte1yX0BMO7snr7jRkGlLQLFwf
aaxbP+lbYxcZM+QW2k2Dbj+dLnvA.k2e62hD.seiNuROf.IXeYDtXHPPGW0J
vfZEXvsBLjvALe22zHBoKDQGcQiHbMmmB2gTP7mTzpMSNydCpuNKd527v3zI
By10ImXibZ9Yqic5.F6Ol5VRn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f2rYNMaqiv1+AnFbvdn6AunEAu9agbKF+ncpPU..0uNP
g3ipy0Rt6tSzYYMAcjuHsG5z5sXYuKBW0u7ar+zlHcfMiXRpRGxzsAf+Xd9m
FEHwoOtHI6SCc6xzVIPzDNFy.ZUkNp6pGOeqq10itYO5658xv933Mup+.Bdz
k6Iy5QaNjKw0a8y.TGX+GSOh5uAdmL1svu8EkKHtIexslr2YNZOW5jkRMoRz
eJzs5R0DAm1nKtZluqZi.jj5Shhz7cyS8UbQPW0y73uvLuMvCSLRr85V30bw
Sa+b1x92YhLbIFZLX665q+qxCgoH41w0LzeXnmG15qmo1GXGCpdxoIJZNfF6
eUGZUbg4ToccqW8HFh+TNmZa6c32rn6cFeXEcaiyzWvqqg6s4+GSWptANziR
GjWuWzq0vjapbExAXQ9myF7HrWs0.NB+qODO7AH.IotCnAmiwHmuCBpyXJ7C
vWVnTGwHzhdMkhCxLA2C+f60Zksrp3AO7DD.i4JRHCnGbVnjIgRZ3Gi+K0rA
O93MYtAaV+CnNhQnGe+GUZZ9mGNDhntCkDW.E1zMATMqj12gYiJA.w4v.POG
M.61W7x7zifhzTBIpNiIp6v8D7is1hkEKROtjG3MmlNBjp8+shTFY.ZOYnR.
tDiPT.SZcBPBJCIBocUnlpRtu6ctqMNSyBSVaSfMOeogYv4VhhgV3cDeFQKn
IqCDvqOovZ1rD2IZ+3vhJUYyJepEAYMHGdeuVOlw.NDvcaQEgAj0mkaNLnbm
p3E8cRt2nXTuJtJO5UlUgNJX8eYk51kooUCaCVLuzJbKjxZxU2T5icO8o6dv
FETJzURaFlicuyBLf6+2KGPP0YTmIaJfquGI3BWhM3FWGLRhkAU8rRU9z58E
3ylp47vPOF.592LAYWCItddQ6bWuKMdU2AOeeC11vwrdqnHTJAtzR0bYR8ds
y..Lb6yL8N9y+TRQ0CQ+s6xOJ2Y2qNmcG7LelkKpmBseyt8h+3E+O9vuFhA
-----------end_max5_patcher-----------

And here are a few example audio files to test with it, but feeding it any ‘single attack’ sample should work just the same.

attacks.zip (650.2 KB)

attacks2.zip (527.3 KB)