Edge cases in analysis frames

Revisiting a pretty old subject here, but in searching on the forum, it doesn’t look like any of it took place on here.

Back at the second plenary there was a bunch of discussion between @tremblap, @a.harker, @weefuzzy, and myself about what to do when you’re analyzing a small number of samples and want the best representation of what’s in there.

As a point of reference, I’m talking about analyses like these:
@windowsize 256 @hopsize 64 @numframes 256

So in a situation like this, you are returned with only 7 analysis frames. So taking the vanilla mean from fluid.bufstats~ probably isn’t enough to remove the impact of the edge cases here, particularly since the only option here is zero-padding.

The intended use case here is that I’m trying to shorten the ‘onset descriptors’ analysis window down to 256 samples instead of 512, since I’m now doing some extra analysis stuff, and further post-processing. At the best of times my latency here is ca. 11ms, but now it’s getting closer to 15ms+, which starts feeling laggy.

From my vague recollection, what is “best” (generally speaking) varies on the type of descriptor in question.

For centroid, I believe mirroring (vs zero-padding) can be better because it keeps the spectral emphasis more-or-less in the same place (though that’s not possible here). For something like pitch, throwing out the outer frames is desirable(?) since you don’t know what is in there. For loudness doing something similar to avoid overly weighing the “zeroes” that surround the analysis window.

Is this about right?

I’m not sure why this is the case, but in my patches from around the second plenary (which I’ve just tweaked as we’ve carried on) I’ve been keeping the first 7 frames loudness (although from 512 samples, so 7 out of 11 frames), and frames 3-8 for spectral moments (again, out of 11).

So that doesn’t really line up with my memory of stuff (hence this thread, and generally inquiry). The spectral moments “middle frames” makes sense, but not sure why I would only take the first frames of loudness. I guess to try to capture the initial “oomph” of the sound only? With only 256 samples it’d be all “oomph” I suppose.

Do MFCCs and mel-bands fall into the spectral descriptors thing, where it would (perhaps) be better to grab the central frames?

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

Another thing that occurred to me is that I may want different amount of frames for different statistics. Maybe for the mean it would be good to be more selective about the frames to not overly weigh it towards the zero-padding, but perhaps I do want the zero-padding-ness for the derivative, since that may capture more of what the actual morphology of the analyzed segment was?

I guess I can always ‘double dip’ the fluid.bufstats~-ing by taking some stats from the whole window, and other stats from just the middle etc…

I’ve found that on small windows it is so signal dependant that I have to test. Sorry for the ‘it depends’ answer but that is the most truthful. The best way to test I found is to test values with expectations. If I do something pitchy, and something noisy, what do i get value-wise. Some of these examples are in the Max helpfiles as demo (for instance bufpitch granulator on confidence).

So far, in comparing the results from the 512 version and the 256 version (doing frames 3-6 instead of 3-8 for spectral descriptors) appears to be about the same.

Am I correct in assuming that for all the spectral descriptors, with such short windows, that throwing out the outer frames will be better, since you otherwise risk pulling the stats down towards zero(padding)?

The statistics (derivative/deviation) tend to be pretty wildly different, but that doesn’t seem far fetched to me since it’s a different and shorter time-frame at play.

It doesn’t hurt that with loudness I was only doing the first 7 frames before (@512) and now I’m analyzing all 7 frames (@256).

So I guess the overall thinking is focusing on the frames you think will be important and testing from there?

indeed. For instance: I’m editing right now in Premiere and even there, super high level, you have the option for blurring on what to do with the edge cases (mirror or zero-pad - although the latter is not explained…)

I was about to make a new post, but discourse suggested this one and it was right!

So I built a patch to test some of this today.

For context, I’m working on the onset descriptors idea where I have a 256 sample analysis window which I’m running with @fftsettings 256 64 512. This gives me 7 frames of analysis, which I was then feeding frames 3-6 (@startframe 3 @numframes 3) into fluid.bufstats~, to avoid having the zero-padding on the edges muck about the spectral descriptors.

Since there’s no option to select what happens with edge cases in the fluid.verse~, I’ve “manually” mirrored the edges using fluid.bufcompose~. It’s a bit ugly and a bit slow, but it (appears to) work.

The patch below compares the original version of looking at only the middle 3 frames, with the version which mirrors the outer frames and then analyzes “all” 7 frames.

Don’t really know how to properly assess how effective this is, so I built a thing where you can manually listen to each fragment and compare the results using an sfv~ filter.


----------begin_max5_patcher----------
7231.3oc6ck9iaibk+y1+UPnr.KvtsEp6ic+xjIGd.x3IyF6fAASBZPIwtMs
USpPQ018DD+29VEKJJRwqhREoTOy3.zCCOT8pe06pd0qp2+5kuX1h3OGrcl2
+i2O58hW7ud4KdQ1sz23E4++ewrG7+7x09aydsYKie3gfnzY2XdVZvmSytOc
t2hv68VEd2cAIAQKC7tKNwac7m7tKI3etScmPUCk+UqCiBVFuKJ6Sw42bSRv
V0ureZXb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snWGnaqx1XiIxQzSn2Up5gX+fRKkXYP
aiGSpon+5C8rvRSH79C9OFnOjgb3DFNYuGKpttmcmakexGeUj9b+3UYS2ef7
81Fu3ZUncKiTZKwffbnhFWrBMEqUiHq8cP30FRYH2IQkv4gVykKw3Gx2zW.P
91i2E+Tng3mIs0UzXw5.kNayZK90wwebVqKTQmQ8DzKi2gUbo1EtKPX1Qg+h
fkKL5iCTiDSW0pDEliw5JZDoGkQV7MMNu39+rA+90XWOrFDYuNt7U8aDwhlr
MF8ap7WGDnW6ooIT+63tHE8ZkyIhIezLmrePmZOWZmkVqckneWnOiZWW8hYp
jjmhHRIVvyuhKb5DDpTf2sVYjn5jc347hm6hh29.o6bLT2gKcTYXyDVyKryk
sVoY+gtdbnxQYayD1TlpAkRZf8YgQ8q5PWEWnyJsaZ7pIzv84jmZUkNraTr7
gUmsAcqTN847P.XN7h9506B1e.1YepzA44qE8AcXxxZtbIAlD+onASg8pa0g
T3u6I+gSf.jjZRcCNGiQ77pirx6G2SfuNIH3DnvdJdwNh3diRyVTp+fIOAAv
LUgU.C.MURSNSBkT2Si+kfUCl93EdtAKlUCH2hgqou+Vv50wepaRrdl1Qk.f
nqr2vhJeua6.nmicfrkunbo11dVDaJt4mMAtYWxl0mlyC7hro6PYmWnUCP6w
CUBv3XDhBXxLg.jfxPBW1uRBVFD9X2qbWS7DESL4PeBTNIRcCwcnBrasEeFQ
oPSlaHfmmovT8Y4cmn8zvEsMHZ01qMKH0Ky8tS1qwrE1lxZ+Y2qJJe8sqGrq
RVuCZ+FJM8Vv+ZYIU+jJE8NqSkdRKZjsSU2E3gUkW9yGOJJi7WI6WfxkGdaH
oxkD99KG7mWof+bKC7mSIfeX.qYqy0RoJ3k+6W9+Ce2TxvB
-----------end_max5_patcher-----------

If someone knows of a better way to assess this, I’m all ears!

For the most part the results are very close. The biggest difference I’ve found (so far) is when the analysis frame has a low of low frequency energy. For some reason the version without the mirroring seems to capture that more. Don’t know if this a result of the windowing being more present in the mirrored version, which (somewhat) pulls the centroid up.

Also wish there was a way to reverse things with fluid.bufcompose~, since I have to manually copy each individual sample over. The mirroring part of the patch takes around 0.15-0.3ms, which isn’t slow, but I’m hesitant to add another bit of latency to the patch unless the results are kickass. I can also manually peek~ / poke~ the individual samples in, but not sure that would be any/much faster.

1 Like

This is essentially a question about what data is represented and how it is weighted.

With zero-padding the edge values are biased by the zero-padding in a manner that is dependent on the descriptor.

  • For spectral shape, as long as you have enough data in the window the biasing will come from the sharp onset that has been induced in the sample.
  • For pitch it can really mess up the measurement and it’s hard to predict how that will happen
  • For loudness etc. it may be less problematic, but you are biasing towards zero

To counter this - if you have a segment of audio that is very loud in the first few samples, then windowing that may significantly affect the result, so if you only start your window at the edge of the audio you are discarding useful data. These situations might be considered as different for streaming situations (analysing in chunks) rather than a file where the start is meaningful. You have to be careful that you are not throwing data away, or biasing it to induce error.

Mirroring or folding (I’m drawing a distinction between repeating the edge sample or not) or wrapping (reading modulo) can reduce some of these issues in that all frames are now full, and full of the original dat - however, you’ve now repeated samples to do so and therefore weighted those samples more highly in your estimates.

1 Like

Indeed, it’s quite pickle-y of a situation.

Based on my (fairly superficial) understanding, I like the idea of zero-padding for loudness, even though it creates “fake” data by isolating a window, but for my purposes that’s probably the better choice. The spectral ones are where I was hoping to improve things, and it looks like for my example I mirrored (duplicating the start/end frame (or is that folding?)).

As you point out, however, that overly represents those in the analysis, but perhaps that’s less problematic with loudness-weighted descriptors.

I hadn’t really considered what it would mean for pitch though, as that seems like a weirder one in terms of behavior.

I use mirror for when you repeat the edge sample (like holding a mirror at the end) and fold for when it doesn’t repeat (like folding a cloth back and forward - there’s a single edge point) - but that may simply be my terminology.

Ok, I’ve realized I did this all wrong…

I’ve been mirroring the frames of anlaysis I have gotten back, and not the audio which is being fed into the analysis, which is what I think actually matters here.

I went back and tried to mirror the analysis frames I get from fluid.bufloudness~ to try applying the loudness weighting for spectral descriptors ideas in a slightly different way. At present I’m taking all the frames I get from fluid.bufloudness~ and then the “middle” frames from fluid.bufspectralshape~, to avoid pulling things down with the zero-padding, which the mirroring I tried to do earlier in this thread was getting at.

In doing that I discovered my stupid oversight here.

In terms of edge-case handling, I think for loudness I would be better off including the material before (and after) the desired analysis window as statistical “context”, and to not pull down the averaging with the zero-padding at the ends.

So I’ve made myself a handy chart:

Each cell represents 64 samples and the darker green area in the middle is the window I’m interested in analyzing. The rectangles underneath correspond to the frames that are being analyzed with a hopsize of 64. Using settings of @windowsize 256 @hopsize 64 @numframes 256 gives me 7 frames of analysis, but with zero-padding where the light green is. Given that I’m mainly analyzing percussive sounds with sharp attacks, at present this really flattens my first frame since it’s mainly filled with zeros.

So what I’m now doing (patch below) is accounting for this by anazyling a larger window than I’m interested in, and then discarding the frames that fall outside of these 7. So I have the same total number of frames, but with “audio” in those outer frames, rather than zeros.

In my case here, this involves analyzing 640 total frames, and starting 192 frames before I’m actually interested in analyzing, and then discarding the first and last 3 frames before taking the stats.

This gets philosophical here, but I think that “what really happened, but outside of the window I’m trying to analyze” is better than “exactly what I’m asking to analyze, but in an artificial vacuum that never happened”.

So this works, and gives me what looks to be better results (not as “droopy” for the first frame), and overall higher mean, which is to be expected. The 1st derivative is a bit more dramatic in the difference though.

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

Thankfully, for what I want to do with loudness, I can just use the existing @attributes and a bit of math.

Where this gets trickier is trying to do the equivalent for spectral descriptors, where mirroring would be (IMO) ideal.

Now, I can manually reverse/mirror 192 samples on each side of my desired analysis window, and then follow the same process above, but that would be time consuming. As it was, mirroring 6 frames using fluid.bufcompose~ for the examples earlier in this post took a whopping 0.15ms, so doing the same for 384 samples will likely make things too slow, particularly since it would be 384 separate operations in order to do that.

I’m certain this has been mentioned in the past (though a quick forum search didn’t turn anything up), but being have to reverse material with fluid.bufcompose~ would be a super welcome feature. Both in general, but also in specific cases where you want to mirror audio for analysis purposes. Even better would be an @attribute for the kind of edge frames you want for any given descriptor.

I know @tremblap very much likes the zero-padded analysis windows, but given the flexibility of the tools, it would be great to not have such a “curated black box” when it comes to edge frames and how to analyze them. :stuck_out_tongue_winking_eye:

On a more serious note, is the a better way to mirror audio for spectral analysis that doesn’t involve manually reading/writing those samples one at a time?

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

edit: I was taking stats of the peak and not loudness channel.


----------begin_max5_patcher----------
9453.3oc68r1aiabsedyuBBiBbauWuNyCNyPteZaRZSAZ11Ec2hfhzBCJIZa
FSQpRRYuNEc+semGjT7wPxgRjRZCjQhWZN7wbd+XN7L+mu5UWsH9S9oWY8Fq
ex5Uu5+7Uu5UxSINwqx+6Wc0ZuOsLzKUdYWsLd8Z+nrqtVMVl+mxjm+0LPw4
13ks7gfn6uMweYl5YiQ2.t1xgXeCCRYNHW4ONjqsPXwHPma.V+q76OZ653sY
g9Yx2HH+rAqjum3E+7qQvhW0cwQYoA+huXHH3FvtmPPTwC.JN2+8q9Jwut9.
gxdgQp.RX1RPE5tGfEZtAq0aCyBRCCV4mT7pJdMrtALBSAXN0HdtTaN0CofV
NfhcYTJE6Z6Bro.6RvN0OiOq4SC0CiymHtCPmHFzt6KM6kPENH+bpKK6kM9p
G1UWcM++KePUwk16nTIdq8y7St0Oxag54M67IlHMP4bJShz.37UZffA6qz.j
M2fk+urxa4m6AFP.E4f5dCh55.P1LByAxfrqsrIhgD+dDfj6U5l6n8XtuPNc
2IF+Tf+yOEjFrHHLH6kZxL2cGWTJW3yVLoeMtxjNLd4i9qVk3ce5xj3vvpS8
kgAKeL6gj3s2+P0yqDjdn8MnF3o1Cr390wqpI5sHNQnEpxYzo4QxDgn2HDMT
LQNtchw6TKQZv8Qdg6zSDwUHHwhq7WGmFuMZ0MbjK+8ekFZlSwI8RtO2R4Uu
8t.thDttmEIaSevO8Fuf6D+4aCii2vO.JN9o3P9g0lr6n4f8fluIz6kvfzrR
V13jf6C3PVl+5MwRL.Zm3wBuzfkYai3XTwP118fmQNtUPzDIqMC0Ihlje1BZ
p5cUJHEve9KiSDO9f3npj363rEwOeeX7hJS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y7SOu9dAdVjMmWFAi+2Ejj8h0e393gRKNz0En7OjyTYmu
n2T..CqWc0cZFzrugkNR8FPv.IiwEmy2v0iju.FcWuHX59gXUe5bcr699U+2
u5+2aVhky
-----------end_max5_patcher-----------

You are right it gets philosophical, and that it is only what you think is better. If someone like me think the other is better, the current implementation allows you do to both. the other way round wouldn’t. Ergo, a superior interface design! This is as if we thought about these 2 options… :smiley:

But your drawing in excel might help people understand what is happening. Which is a good contribution, so thanks for that!

Well, options to choose would let you do whatever you want! At present it’s not possible (without some tedious workarounds) to do any kind of mirroring, would be the other most common thing to do with the edge frames.

A question.

So I’m trying to do the same thing as above, but with spectral descriptors (centroid in this case), but I’m getting unexpected (somewhat) behavior.

It looks like if you analyze digital silence, you get Nyquist/2 as the default value. I guess it has to return something, and this is, I suppose, no more incorrect than any other value that is returned.

But I noticed that if I did what I’m doing above with loudness (analyzing 640samples, when I only want 256), the outer frames, if there is silence in the buffer, which there is in my test context, are filled with 11k:
Screenshot 2020-10-17 at 3.47.09 pm

That’s not always the case, as it seems to depend on what else is going on, and what else may be in that bit of buffer etc…, but contrary to my expectations, this approach of taking a larger analysis window is biasing my queries upwards towards Nyquist/2.

For example, here is fairly bright sample hit, with a mean around 9k (which sounds about right):
Screenshot 2020-10-17 at 4.00.14 pm

I have no idea what’s going on in the frames before the attack, though the ones at the end seem in line with a decrease in centroid over time.

My question is, what happens with the zero padded equivalent of this? I have no way of seeing the “zeros” that are put into that part of the analysis since it happens behind the scene, but if I do this:
0eff07a41c175ca8b9f49aa443438eb8c7df7399_2_690x187

I don’t seem to get results that are in line with those light green frames being filled with 11k. So is the “zero-padding”, with regards to spectral desriptors, doing something other than filling them with Nyquist/2? Are those light green frames filled with a centroid value of “zero”? That would be more in line with what (I think) I’m seeing, with the mean getting pulled down by zero padding.

What is in those first few hops when zero-padding an analysis with spectral frames? Nyquist/2 or zeroes?

Also, with this it occurred to me that I can also have a double-buffered “reverse” audio stream going at all times (driven by the same count~) , so when I detect an onset, I can fluid.bufcompose~ the frames I want (dark green), and then do two copies from the reversed buffer into the the mirrored frames (light green). A bit of a faff that, but I guess it’s possible with native objects.

Zeros, because any padding happens in the time domain, before the signal gets anywhere near the algorithm (which doesn’t know about padding). You can probably see what the results are internally using framelib (padding vs mirroring)

1 Like

I thought I understood this, but when thinking back about it today, does that mean those edge frames are super pulled up towards Nyquist/2, in the same way that I’m experience in trying to do a larger analysis window with potentially some extra silence at the edges?

Or does the moment there’s a tiny amount of audio in an analysis frame (frame #1 in my spreadsheet/diagram), does that break the “default value”-ness of Nyquist/2?

I’m just confused as what the difference between me “zero-padding” by having silence or near-silence, vs the algorithm zero-padding, if it’s all happening in the time domain.

It’s possible because, as Alex says above, the zeros can introduce a discontinuity that can, in turn, spread a bunch of energy over the DFT spectrum.

None, I would think. But I thought you were doing your own mirroring / folding instead? I’d suggest that FrameLib is the tool for this kind of forensically orientated work (i.e. you want strict timing, and you really care about the initial results from a small population of frames).

(aah, it’s nice to be able to properly quote formatted text again)

Gotcha, and that makes sense.

Out of tangential curiosity, is the Nyquist/2 thing the norm when working with spectral descriptors and silence? It makes sense in that, it’s probably mathematically (?) correct, since all the frequencies are at equal loudness (none).

I should poke at this and see. It’s just hard because I can’t really see/access the actual zero-padding that fluid.spectralshape~ is doing, vs what I can feed it with a larger analysis window. So it could very well be the same results, just hard to see. In running patch above on general demosound sounds, the larger window gives me visible/readable Nyquist/2 at the edges, since I can see them before throwing them away.

I’m still quite green at framelib, so it would take me longer to figure out how to start building something like that, than actually building something like that.

At the moment I’ve not yet done that. The tests I did a while back (above) were conceptually wrong, as I was mirroring the results I got from the analysis, rather than the audio I fed into the analysis. It still did something since there was a stats step that comes next anyways, but it would be (I imagine) very different for actual mirroring of audio.

I think what would take me the least amount of faffing will be to hand craft a couple audio examples and just analyze those static things, rather than working out the parallel/reverse JIT audio analysis which has to concatenate the perfect bits of audio for this all to work.

I’d put a strong vote in for switchable edge behaviours as part of the objects, because although I agree that the current interface allows you to get to lots of options, the process of how you get to them in a musical context is important. I am wary of comparisons between things I’ve made and parts of flucoma (because taking things is not a competition), so what I’m interested in here is the logic, there is a very clear reason (from my perspective as a creator) that I decided to build a bunch of edge conditions into FrameLib objects (even though one could prepare the frame using other objects and post-process) and that is because it is long and tedious work, which I frequently get wrong - and involves lots of diagram type work (as Rod has done here). I absolutely don’t want to deal with that in a musical context when I’m using it, so I hive it off into a technical area of work. There are also not so many options that make sense, so to me it doesn’t make sense to have users replicate that work with the possibility of mistakes, as compared to building It in.

1 Like

I obviously agree here, but I think this is something that can get easily overlooked by someone casually, or even somewhat-deeply using the objects.

I mean, I only really know about the implications of what frames are getting analyzed before/after the chosen frame because of in-person conversations, which most users won’t have had the luxury to have.

Same goes for the zero padding and other “overall edge cases” that happen as part of the system at large.

All of that to say, offering options with friction leads towards no options being offered at all (and default choices being made more often).

As an aside, it would be handy to have something like the bit of code I posted above in a helpfile somewhere to show how to create other edge cases by just choosing larger analysis windows and dropping outer frames.

Revisiting this analysis frame thing today. I’m trying to build a kind of slow-mo envelope generator by using the loudness (and eventually other spectral descriptors) on a frame-by-frame basis so that a single attack can yield a variety of envelope contours, and when unpacking the loudness frames I can never get an envelope shape that seems correct.

So at the moment I’m doing this:

And throwing out the first three and last three frames, so taking frames #4 through #10.

My thinking is that there will be real audio in frame #4, as opposed to being zero-padded.

That ends up giving me attacks that look like this:
Screenshot 2020-10-25 at 7.59.11 pm

And this:
Screenshot 2020-10-25 at 7.59.05 pm

(that’s normalization in dB and then converted to linear amplitude in p normalize)

So with this, the loudest frame I get is frame #7, or frame #4 if I count from the trimmed frames, which corresponds with the analysis frame that is full centered in the analysis window itself.

This, however, is not the loudest frame in the overall window as these are percussive attacks with super fast onsets.

It makes, computational, sense why this is the case as the loudest part of the analysis window is generally preceded by the silence (digital or otherwise) prior to the detected onset. But this isn’t really intuitive as, perceptually I would expect something more along the lines of this:
Screenshot 2020-10-25 at 8.15.12 pm

I’m thinking that mirroring here might give a more (perceptual/intuitive) set of values since it would, presumably, have the highest amount of energy centered around that hop of the analysis window. Or rather, folding, to use @a.harker’s lingo from above.

I think that would require dropping another analysis frame too, so only taking from frame #5, which would be the first frame that would be centered at the start of the analysis window.

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

Am I thinking about this correctly?
What’s normally done for short/loud analyses?

Up to this point, particularly with summary stats, I’ve been taking the mean of the whole thing here, which, if consistent, should correspond to a comparable descriptor across the board, but if I’m interested in the specific envelope and contour of that short window of time, I feel like there’s probably a better way to approach this than I am presently doing.

You are unlikely to see a shape like the one you are expecting. The system of analysis is symmetric in relation to a ideal impulse, as the important thing is that the analysis is in chunks and thus the impulse either falls under a given window (chunk) or not. It is likely to fall late in the first window under which it falls, and thus be significantly reduced by the windowing. The highest output is where it falls centrally in the window. Overlapping will adjust the “pre-ring” (more overlap gives more frames of “pre-ring” and vice versa).

Also, although the window reduces the level at the edges, at the 25/75 points the level reduction is likely smaller than the effect of the sudden loud transient - hence the relatively flat output overall the peak in dB.

The shape you draw is what you would get from a time domain envelope follower that has been biased to respond faster to attacks (and therefore is non-symmetric). I suppose you using a super short FFT might get you closer to that (but if that then why not use the time domain)?

1 Like