Way of modifying state of "fluid.robustscale" in puredata

Hello,

a bit of an odd question here,
I’m adapting some max code from Rodrigo Constanzo in Pure Data which implies at some point the modification of “fluid.robustscale” state:

fetch the “Range” in the json file
multiply by 2
replace the “Range” in the json by the result.

Yesterday I gave it a go, I fetched the “Range”, I multiplied, once I had to modify the json I ended up with an incorrect json file, not readable by “fluid.robustscale”. This task is made quite complex by pd itself, I know there’s an external for JSON parsing ( haven’t tried yet ) but the goal here is to rely on Flucoma only, no other externals.

So I’m wondering if I could get some help to get the same result without having to manually construct a json file in pd.

for reference, this is what’s to be achieved:

here’s what the data looks like before the processing:
{

“cols”: 8,

“data_high”: [ -26.247343063354492, 0.241597786545753, 63.95220947265625, 0.081183396279812, -40.074893951416016, 0.244581758975983, 90.867919921875, 0.000858980114572 ],

“data_low”: [ -42.08658981323242, -0.129064902663231, 47.55539321899414, -0.309432119131088, -96.38632202148438, -0.207946330308914, 27.48699951171875, 0.0 ],

“high”: 75.0,

“low”: 25.0,

“median”: [ -33.885108947753906, 0.090700931847095, 52.845741271972656, -0.018240973353386, -77.57266998291016, -0.012044765986502, 83.26824188232422, 0.0 ],

“range”: [ 15.83924674987793, 0.370662689208984, 16.39681625366211, 0.3906155154109, 56.31142807006836, 0.452528089284897, 63.38092041015625, 0.000858980114572 ]

}

And here’s what’s loaded into that dict in the patch:

{

“cols”: 8,

“data_high”: [ -26.247343063354492, 0.241597786545753, 63.95220947265625, 0.081183396279812, -40.074893951416016, 0.244581758975983, 90.867919921875, 0.000858980114572 ],

“data_low”: [ -42.08658981323242, -0.129064902663231, 47.55539321899414, -0.309432119131088, -96.38632202148438, -0.207946330308914, 27.48699951171875, 0.0 ],

“high”: 75.0,

“low”: 25.0,

“median”: [ -33.885108947753906, 0.090700931847095, 52.845741271972656, -0.018240973353386, -77.57266998291016, -0.012044765986502, 83.26824188232422, 0.0 ],

“range”: [ 31.67849349975586, 0.741325378417968, 32.79363250732422, 0.7812310308218, 112.62285614013672, 0.905056178569794, 126.7618408203125, 0.001717960229144 ]

}

So it’s literally just “range” multiplied by two.

1 Like

Curious if there’s some pd-specific thing that makes this approach trickier.

I’m curious if @tremblap has used this kind of robustscale “hack” in pd. In Max it works well and I use it all over as per his suggestion.

Well I managed to implement this, in an ugly way…
I hope it’s done right, I spent 3 hours on this.

Ooh, what’d you have to do as a workaround?

And what/where was the issue?

this looks great but I’m not able to look at it properly until next week…

1 Like

I read the json with “text” object, it comes up sliced in many elements, it just took time to figure out how to extract values then recompose the json formatted text. ( I never noticed one couldn’t type a “{” in pd it gets ignored )

There’s interesting re: special characters.

I guess the fluid. objects internally parse that just fine, but in pd-land the characters get absorbed.

I wonder if it would be possible to have an alternative parser for fits in pd-land for the flucoma objects as this “hack” of using fluid.robustscale and fluid.normalize with custom fits is massively useful.

In your patchers you manually edit a fluid.standardize state :

dict.pack std: mean:0 0 cols:8

then load in fluid.standardize

In pd I have to create a template json file, then modify it in pd ( with all json formatting issues to solve ) then save it and “read” it with fluid.standardize.

a way of doing this easily would be great ( & I think your way of adding weigths is interesting enough ! )

1 Like