round values to next in list…

Dec 18, 2013 at 1:46pm

round values to next in list…

really simple problem i think, but i cant think of any simple solution – maybe you guys have an idea how to do this:

I have a list of variable length with floats. eg: [10. 34.5 50. 72.] and an input value from 0. to 100.. now what i want is a simple function wich outputs 10. for the input range of 0. to 10.; 34.5 for the input range of 10.000001 to 34.5; 50 …. ect. you get the idea.

whats the easiest and most efficient way to create such a function with a variable number of points?

best,
plinio

#276157
Dec 18, 2013 at 1:48pm

i thought about writing the values into a buffer and reading from that – but thats to much msp for me…

#276158
Dec 18, 2013 at 2:29pm

okay – for now i used the function object – looking for better ideas though.

#276160
Dec 18, 2013 at 8:11pm

With a handful of values like you have, [split] could work. The challenge might be assigning the min/max and output values as the input list changes

<code>

– Pasted Max Patch, click to expand. –

</code>

#276182
Dec 21, 2013 at 2:37pm

if the lists are short, say of 5 elements, something like split would be perfect.

if the lists contain 100 elements, you better try to iterate it and build the process around single elements.

#276380
Dec 21, 2013 at 6:20pm

I call this “quantize to list”. Enjoy :)
<code>

– Pasted Max Patch, click to expand. –

</code>

#276395

You must be logged in to reply to this topic.