# Internal/random buffer~ creation ala ears.stuff~

**URL:** <https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607>\
**Category:** New Ideas\
**Created:** [July 24, 2020, 6:28pm UTC](https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607 "2020-07-24T18:28:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodrigo.constanzo](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/rodrigo.constanzo/32/12_2.png) [@rodrigo.constanzo](https://discourse.flucoma.org/u/rodrigo.constanzo)\
**Post date:** [July 24, 2020, 6:28pm UTC](https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607/1 "2020-07-24T18:28:49Z")

</div>

So based on @danieleghisi’s presentation at the Friday geek out session, it struck me that the way that `ears.stuff~` handles `buffer~`-based operations is suuper elegant. Even seeing him prototype an idea on the screen share took no time… and more importantly, no manual creation of `buffer~`s.

This also relates a bit to what @a.harker brought up as a general interface-y thing.

But I guess the general idea is that, unless otherwise specified, every object creates and manages its own internal buffer (with random names ala jitter `u2535233523`) and then passes that out of its output. So that if you want to do a series of processes you just create a serial connection of objects, and send a starting message/buffer at the top, and at the bottom you are returned a randomly generated `buffer~` reference.

You can obviously still specify a `buffer~` if you want or need it, as well as specifying if you want to do things ‘[in place](https://discourse.flucoma.org/t/transform-in-place-for-scaling/597/2)’ which @jamesbradbury brought up in [this thread](https://discourse.flucoma.org/t/transform-in-place-for-scaling/597/2).

For my own silly shenanigans I’d still have to create and manage `buffer~`s in order to `@blocking 2` everything, but for prototyping and/or offline processes, the workflow is so much nicer.

Really, seeing @danieleghisi whip up a patch that slices a `buffer~`, applies a fade, and reorder the segments was 3-4 objects, maybe 10seconds of coding, with not a `buffer~` in sight looked so effortless! The equivalent coding in the `fluid.verse~` (presuming you could do fades) would require figuring out how many `buffer~`s you needed, you’d have to name them all and remember the names (as well as making sure that you haven’t already used that name elsewhere), etc…

So this is more an interface discussion/prompt than a feature-request, but there’s some feature-requests undertones to it!

---

<div class="post-metadata">

**Author:** ![jamesbradbury](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/jamesbradbury/32/1252_2.png) [@jamesbradbury](https://discourse.flucoma.org/u/jamesbradbury)\
**Post date:** [July 24, 2020, 6:40pm UTC](https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607/2 "2020-07-24T18:40:14Z")

</div>

it might even look as simple as source $1, bang for every time you chain.

---

<div class="post-metadata">

**Author:** ![a.harker](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/a.harker/32/18_2.png) [@a.harker](https://discourse.flucoma.org/u/a.harker)\
**Post date:** [July 24, 2020, 6:43pm UTC](https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607/3 "2020-07-24T18:43:55Z")

</div>

Maybe @rodrigo.constanzo needs to read the forum more thoroughly…

[https://discourse.flucoma.org/t/max-controversial-automatic-temporary-buffer-mode/589](https://discourse.flucoma.org/t/max-controversial-automatic-temporary-buffer-mode/589)

---

<div class="post-metadata">

**Author:** ![rodrigo.constanzo](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/rodrigo.constanzo/32/12_2.png) [@rodrigo.constanzo](https://discourse.flucoma.org/u/rodrigo.constanzo)\
**Post date:** [July 24, 2020, 6:48pm UTC](https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607/4 "2020-07-24T18:48:37Z")

</div>

> [@jamesbradbury](#):
>
> it might even look as simple as source $1, bang for every time you chain.

Even simpler would be that if it receives a randomly generated name (that is presently in the memory space, or some other kind of check), it executes on it sans bang. So you could literally just have object/cable/object/cable.

I mean, that would be gravy all the way.

> [@a.harker](#):
>
> Maybe @rodrigo.constanzo needs to read the forum more thoroughly…

I don’t know about you, but the _last_ thing I do when making a new post is check to see if someone has made that same post before…

---

<div class="post-metadata">

**Author:** ![rodrigo.constanzo](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/rodrigo.constanzo/32/12_2.png) [@rodrigo.constanzo](https://discourse.flucoma.org/u/rodrigo.constanzo)\
**Post date:** [September 17, 2020, 8:53pm UTC](https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607/5 "2020-09-17T20:53:37Z")

</div>

I mentioned this during the latest FluCoMa geek chat, but I wanted to bump this thread with the `buffer~` stuff in light of some of what may be the suggestions from the use case prompts in the thread about “[`fluid.datasetfilter~`](https://discourse.flucoma.org/t/a-fluid-datasetfilter-object-for-conditional-querying/598/13)”.

As I mentioned to @tremblap, I spent a few weeks away from FluCoMa stuff working on some other things ([largely](https://llllllll.co/t/3d-printing-digital-fabrication/15454/169) [3d-printing](https://llllllll.co/t/3d-printing-digital-fabrication/15454/171)!) but I came back to it last week in order to tidy up some of the [code I was working on before](https://discourse.flucoma.org/t/regression-classification-regressification/547/58).

One of the things that struck me was the amount of friction involved in “data house keeping stuff”. As in, I knew what descriptors I wanted, what stats I wanted, and where I wanted them all, but it still took me the better part of an hour to get it up and running. And if one thing changed (another stat or descriptor), that often broke everything, particularly in `@blocking 2` mode.

Granted, the `@blocking 2` means that things will always be fiddly (actually, is there any overhead with just making `buffer~ foo @samps 500 500` for everything? I imagine the `@samps 500` probably doesn’t matter, but I have no idea if having loads of “channels” does weird stuff), but the kind of coding required to manage this stuff is pretty far removed from any creative process. `fluid.buf.select` mitigates some of the unpleasantness of this (though the js-based nature of it won’t jive with `@blocking 2`) but even with that, you need to think in “channels” and “indices”, which is not the same as “descriptors” and “statistics”. So figuring out I want the 3rd sample from the 2nd channel is still required.

I’ve rung this bell long enough, but I only bring it back up because the prospect of doing all of this “at a zoomed out level” with `fluid.dataset~`s is pretty daunting.

So if building something that lets you do a (simple) binary hierarchical search inside a `fluid.dataset~` requires you to _remember_ (or make note of elsewhere, since there is no symbolic notation anywhere) what indices in your `fluid.dataset~` correspond with what, in order to be able to cleave off the bits you need, it starts to be the same kind of fiddly “data management” problem which kills the creative coding flow (for me, at least).

So this bump is part-bump for having better ‘low-level’ data management, but it’s also a pre-bump for future ‘high-level’ data management.

---

<div class="post-metadata">

**Author:** ![weefuzzy](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/weefuzzy/32/362_2.png) [@weefuzzy](https://discourse.flucoma.org/u/weefuzzy)\
**Post date:** [September 18, 2020, 8:56am UTC](https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607/6 "2020-09-18T08:56:57Z")

</div>

> [@rodrigo.constanzo](#):
>
> is there any overhead with just making `buffer~ foo @samps 500 500` for everything? I imagine the `@samps 500` probably doesn’t matter, but I have no idea if having loads of “channels” does weird stuff

There will be a notional performance hit due to cache misses because buffer data is stored consecutively by channel rather consecutively in time. However, whether it is noticeable is another matter: almost all (maybe all) of the NRT algos copy their data into a time sequential layout before processing anyway, so the cache misses will just be on the read / write from the [buffer~].

> [@rodrigo.constanzo](#):
>
> equires you to _remember_ (or make note of elsewhere, since there is no symbolic notation anywhere) what indices in your `fluid.dataset~` correspond with what, in order to be able to cleave off the bits you need,

Is it not possible to use a dict or a coll in exactly the same way as you would add labels to `entrymatcher`? If you found a workflow that made sense to you for this, you could make some abstractions that wrap (e.g.) bufselect, datasetquery etc which would, in turn, give us food for thought about the shape of a possible future. At the moment though we’re still at the ‘getting it working at a low level in multiple hosts’ stage.

---

<div class="post-metadata">

**Author:** ![rodrigo.constanzo](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/rodrigo.constanzo/32/12_2.png) [@rodrigo.constanzo](https://discourse.flucoma.org/u/rodrigo.constanzo)\
**Post date:** [September 18, 2020, 9:31am UTC](https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607/7 "2020-09-18T09:31:39Z")

</div>

> [@weefuzzy](#):
>
> There will be a notional performance hit due to cache misses because buffer data is stored consecutively by channel rather consecutively in time. However, whether it is noticeable is another matter: almost all (maybe all) of the NRT algos copy their data into a time sequential layout before processing anyway, so the cache misses will just be on the read / write from the [buffer~].

Ok, that’s really good to know. (makes mental note to be fussy about channels, but cavalier about samples) It’s often the samples part that is harder to figure out, with channels usually being multiples of 7 (for stats or spectral moments etc…).

> [@weefuzzy](#):
>
> Is it not possible to use a dict or a coll in exactly the same way as you would add labels to `entrymatcher` ? If you found a workflow that made sense to you for this, you could make some abstractions that wrap (e.g.) bufselect, datasetquery etc which would, in turn, give us food for thought about the shape of a possible future. At the moment though we’re still at the ‘getting it working at a low level in multiple hosts’ stage.

This is an obvious way to go, but I’ve put off this for now hoping there will be an internal solution later on. So far my patches have been exclusively “oldschool” (`entrymatcher` / `coll` / with a bit of `dict` in the mix) or “newschool” (_only_ `fluid.dataset~`).

I guess for some of the things I’m thinking, `fluid.datasetquery~` wouldn’t be able to do the manipulations yet, so it would just be an exercise (worth doing) in tidying.

---

<div class="post-metadata">

**Author:** ![weefuzzy](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/weefuzzy/32/362_2.png) [@weefuzzy](https://discourse.flucoma.org/u/weefuzzy)\
**Post date:** [September 18, 2020, 9:39am UTC](https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607/8 "2020-09-18T09:39:49Z")

</div>

> [@rodrigo.constanzo](#):
>
> makes mental note to be fussy about channels, but cavalier about samples

I wouldn’t internalize that too deeply, lest you fall into the trap of working around a performance problem that isn’t really an issue. The only way to really be sure is to measure, or at least try it and see how things behave. Like I said, the performance impact could well be completely negligible.

> [@rodrigo.constanzo](#):
>
> It’s often the samples part that is harder to figure out, with channels usually being multiples of 7 (for stats or spectral moments etc…).

> [@rodrigo.constanzo](#):
>
> channels usually being multiples of 7 (for stats or spectral moments etc…).

Yes for spectralshape (because these are time series), but the stats are frame-wise, no?

> [@rodrigo.constanzo](#):
>
> so it would just be an exercise (worth doing) in tidying.

Worth doing both from the normal wholesome point of view, but also it will be really helpful to us to start to see the repeated patterns that lead to boilerplate which we may be able to abstract away in future versions.

---

<div class="post-metadata">

**Author:** ![rodrigo.constanzo](https://discourse.flucoma.org/user_avatar/discourse.flucoma.org/rodrigo.constanzo/32/12_2.png) [@rodrigo.constanzo](https://discourse.flucoma.org/u/rodrigo.constanzo)\
**Post date:** [September 18, 2020, 12:53pm UTC](https://discourse.flucoma.org/t/internal-random-buffer-creation-ala-ears-stuff/607/9 "2020-09-18T12:53:58Z")

</div>

> [@weefuzzy](#):
>
> Yes for spectralshape (because these are time series), but the stats are frame-wise, no?

Whoops, my bad. Yeah you’re right. I guess, either way, I tend to get hung up on the sample count rather than the channel count.

> [@weefuzzy](#):
>
> Worth doing both from the normal wholesome point of view, but also it will be really helpful to us to start to see the repeated patterns that lead to boilerplate which we may be able to abstract away in future versions.

Indeed. I’ll start having a think about this, but this is very much starting to overlap with the stuff being discussed [in this thread](https://discourse.flucoma.org/t/a-fluid-datasetfilter-object-for-conditional-querying/598/16). Off the top of my head, an abstraction where you define each descriptor along with what stats you want for it (similar to `descriptors~`) would be quite convenient: `centroid 500 10000 mean min max 0.95 std` etc…

That could get messy quickly if you want the same stats for loads of descriptors, or if, by default, you want “everything”, as that would get really verbose.

Another alternative would be to have content-aware labels for `fluid.buf.select~` where you can give it an attributes or tickboxes for whether it’s dealing with spectral descriptors, or stats, or x amount of derivatives, and then you can be verbose with it: `@source source @destination destination @descriptors centroid flatness rolloff @statistics mean min max`. Or something like that.
