Using fluid.ampslice~ to extract amplitude information

Although I still haven’t made sense of fluid.ampslice~, it occurred to me that using the gate output nature of it might make it useful for detecting what a peak was within that time.

So using a vanilla 1->0 crossing would be no good as that could potentially happen 100+ ms after the onset, since the 1->0 crossing happens only when the threshold criteria becomes false, and has nothing to do with when a peak might have happened.

I then thought I could use the code from the previous onset detection algorithm to trigger the amplitude measurement aspect of the previous abstraction:


----------begin_max5_patcher----------
4382.3oc68z0bipbkO64WQW5gT1UoQa+c2rISpI6to17PRU4g7VlsbgEHaxU
BzBHOiu255e66o6FPfDfPRf8jMiqw1xcCz84zmu+f4W9vMydH4agYyP+6n+N
5la9kObyM1gLCbSweeyrM9ea4Z+L6kMKN7qIO7OlM2MUd32xsCuEkrZUVXd4
Dw61jrKecXt8tHEi5FJ+ksgtkb1Lz+SwTa8yW9TT7i2mFtL2MKQ4s.OGI0rE
JsTHwXgV3wTh4Ht1LCkt.W8.hBraDXy8QuZ6hn3xMAt9JElV.iE.4MyVEsN7
4vzrnj3Za4al4ucasguo1sXvL+iD6CROuZnnX2P3pgRCeNp79kUi5mBvaN.r
6RsXiYeSxms+wjDDlFuKxtUbC9qenbKYOMh82Dls0eo6lMGZkSuGCJrHPBla
9Eu.oww6wZvo8iqSV9SgA02xyR1FFGEuMMLKLN2OuXuWMcP3J+cqyueURbdV
zOa2AD3rns4WUrCacRCLX29+gzH+0U.vioQAIwlMQiSByvkKGPcHrvlnNvXu
hX+ssby.cAfV5XxL.H2k8fep4f5g01UfVNYdRx5lSUceqCWkWL81n33Cvh4I
a6dxznGepm68gDXxM88rsyjc+tX2r2CzD42m4+bSrct+50ErrMe7eyONZied
Xdj6HfhqlLL1G.zmxVllrdcC30MyysLS.PiuL7qQA4OYWn5DCvkGssjHZV0o
bPzigY4MGK2+wrlijk+hCoWancOTvCeed3lsqAnn4EzPnVcF15B2ZL9AB4Vl
rYCP4WwNVWR2eLNC3XyP4O4miLzSYOkj+JJ2+mrCFhLGDnLeXiEBBEsC8LP5
kjhx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OfRp
c7mw3Wrx7JEgP4XJy91Bi4I6XtQmPXP.hZJj0xoCfwuTf70sRCQur2XHYkOT
8xWqrCl5Jc78JrQpc5YOqw9ZSKebP8ETXnvwScs3.x.HfFAif7jt+GQgnLkI
X8xqovCmil4ZArgXJvAD0i4apnKdiSGhtyxX1b8qDYHJvHmP.rBTVINnVXY5
ELyWBsRxkbswb2gdcvTKTfehLpRxJyzroUnOVi3wW4XKicPnIJY.5oZC7c80
U2yHLtFPnZpG3BbQg0RbEk3wSM1Z1nxAaO80JL1tTjAsTzqcoFhpLqRyqFnF
jPnoINJW0Fm3MDZd72i6b5aka8tZc6s0s9JeWGBE0QYG4f1Y2rHGzF6GzB6G
295c255G1151VV209tGjQlprLsw+axp1rsrwvahALIvxd7beTrYuG1cVGJPI
MZxLRwryKOX2Khze4xv37FDsZyU.GVThz7IE1SaTyWinbdwokISiG1Yxy1.6
9nRgt0Oca.v0JAm1A4FaIyK.Yp0zRFvhvseBXZDjwdasILKyurqgFuyhUQqW
WAP0ekKTlNwYOl5GDU6UXtC9IUmIVM9ya8Sj589u81nk2FHlAvbya8SGeak2
E0CS7rm8rhydymfgHGbW9wOV7VBPUqU22llrMIs50kvBvmfxqeWdREfV04rk
c5X6GeM4NF1oX8RHe.TW1yLNPVgshi4.Ly7FSJqb+s8sYpmyYP10e1OOA8mM
uXDlcIquSHWG+20xG90O7+YSnTgJ
-----------end_max5_patcher-----------

Unfortunately that’s not possible with fluid.ampslice~ since the output of the envelope followers is not available, and that’s what’s being used here to determine when a peak happens.

Now, I can just run the first bit of this code in parallel with fluid.ampslice~, and use a 0->1 transition to trigger the minmax~ in the same way, but it’s a bit of duplicate code, and quite possibly not the best way to go about it.

This would also be quite fast as the code in question adds a latency of 110samples (2.5ms) to tell what the amplitude has been in that window

I also thought about using fluid.loudness~, or even better fluid.bufloudness~ but with the former I don’t think it’s possible to accurately say that the onset detected by fluid.ampslice~ lines up with the current analysis frame of fluid.loudness~. With fluid.bufloudness~ it would be possible to analyze the precise frame in question, but that can then come with an overhead of up to 500ms(!).

SO

Is there a way to tell the amplitude of an onset within the fluid.verse~ in a fast and sample accurate manner? (Or is there the possibility for this coming in the future).

1 Like

@rodrigo.constanzo this post is on my important things to do before unplugging for 3 weeks. That day was supposed to be today, but since the Pd help files are sooooo almost done (and I found many bugs doing them so they are urgent) I will most probably unplug progressively in a few days… but not before I’ve checked this - it should be helpful to see what a user get in my Machiavelli interface design…

1 Like

Now, this is an interesting question. I would use fluid.loudness for that, and get the RMS for the same price. You are in real time here, but the JIT approach is good here. Obviously that induces the latency of the window you want to analyse to ‘catch’ the peak.

as for this:

I really don’t know what you would do to do that, since it is a complicated gate, not a discrete output of amplitude

but

as it is very quick you could use its change of state 0->1 to trigger a sample and hold. if you tweak the latency right, you could catch the peak, especially if you are peak-riding with a fast attack and slow decay on the relative gate.

as for this:

in the long term, there is another idea in the pipeline for a way to output the curves. that has been talked about in various threads, but will happen only after the 2nd toolbox has a viable alpha, so not for a good 6 months… @groma has some dreams and great ideas there.

1 Like

Totally, but that brings me back to the “analyzing the correct frame” problem. There’s no way to get the output of fluid.loudness~ to be perfectly in sync with a triggered onset. I can take a whole window and then take a peak value from that, but again, a bit sloppy and susceptible to Max slop(?).

Again, possible, but if the decay is set too long, or if my criteria exceeds the threshold for a longer period of time, all of that adds to additional latency. Or worse, additional (pseudo)random latency, since it’s not something you have direct musical control over.

That would be cool, and it would be less…erm… of a black box object than it presently stands… :wink:

For me, however, that would just be a workaround to the larger (in my case) problem of wanting something in real-time and being able to be sample accurate about it. Where presently is in a no-man’s-land in the fluid.-verse.

I was thinking of the JIT approach,

now, you could also use the output to check the max of the last X samples. A JIT or a hybrid with framelib is most probably what would serve you best.

Ah right. The JIT has a +/- of 50ms jitter with spikes up to 500ms, so I wouldn’t trust it for fast/accurate loudness measurement.

Indeed, though that’s basically what the original patch in this thread is doing. So I’d be back to duplicating code with an envelope follower, or involving other frameworks (framelib).

I guess part of this post in general was just to see if “the loudness of an onset” (or change in magnitude for the spectral one) was on the radar for the fluid. stuff, as those seem like fairly common use cases that presently require work arounds to get at.