Forums > MaxMSP

Multislider to Always Add to 1

April 18, 2008 | 5:10 pm

I’d like to have an array[n] of flonums/sliders that will always add
up to a given number.
For instance, I could have 4 flonums and when one value is modified,
the other 3 values would adjust to keep the total equal to 1.
Ultimately I’d like a multi-slider whose outputs always add up to 1
(so that each slider is a percentage).


Morgan Sutherland


April 18, 2008 | 6:23 pm

On 18 Apr 2008, at 19:10, Morgan Sutherland wrote:
> I’d like to have an array[n] of flonums/sliders that will always add
> up to a given number.
> For instance, I could have 4 flonums and when one value is modified,
> the other 3 values would adjust to keep the total equal to 1.
> Ultimately I’d like a multi-slider whose outputs always add up to 1
> (so that each slider is a percentage).

divide each element by the sum.

#P outlet 138 387 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 84 233 48 196617 loadbang;
#P message 84 258 67 196617 scalarmode 1;
#P newex 152 71 61 196617 listfunnel 1;
#P newex 152 92 62 196617 prepend set;
#P newex 84 333 78 196617 vexpr $f1/$f2;
#P newex 152 309 67 196617 mxj list.sum;
#P user multiSlider 152 123 227 164 0. 1. 4 2681 47 0 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P connect 2 0 7 0;
#P fasten 2 0 4 0 89 360 74 360 74 66 157 66;
#P fasten 0 0 2 0 157 296 89 296;
#P connect 0 0 1 0;
#P connect 1 0 2 1;
#P connect 5 0 2 0;
#P connect 6 0 5 0;
#P connect 4 0 3 0;
#P connect 3 0 0 0;
#P window clipboard copycount 8;


April 18, 2008 | 7:06 pm


Viewing 3 posts - 1 through 3 (of 3 total)