Forums > MaxMSP

[4.63] – scale is not limited to it's input range

December 3, 2008 | 12:08 am

Hello again,

using [scale] a lot these days i wonder:

1. it seems to not only work in the range defined in the object.
simple example: scale 10 20 20 10
still puts out 9, when inputting 21.
is there a way to overcome/limit this within the object itself?
2. using it’s fifth inlet for exponential calculation would oftenly be nice to have a reversed exponential curve instead.
how would you approach this? values lower than 1 for the exponential calculation don’t seem to do anything (though there could be a root calculation instead…), when using values higher than 1, then 1.04 (about) already seems to overdrive any useful range.
2b. also when i do scale 0 127 32. 17.000 with exponent 1.03 for a filter, then idealistically i’d need the power affecting reversed, means lower frequencies, when i trigger a filter, should have a finer resolution, that higher frequencies.
how do you deal with filters needing a finer step grade in lower ranges, than higher ones?

i hope that made any sense, any answers are very appreciated!

jrp


December 3, 2008 | 12:22 am

Use [zmap] when you want the input range to cap the output range. It will keep sending the high or low input value when the input exceeds them.

As for your question regarding the 5th argument to [scale] I tend to use [expr] for this as you can control exaclty how much scaling you want and it can go both ways. This patch scales 0-127 to the audible frequency range.

lh

– Pasted Max Patch, click to expand. –

December 3, 2008 | 12:28 am

LH, stupid kind of, but again: i am on 4.63 still, with no way to upgrade currently.

could you post a screen shot of your patch?

the zl tip was very nice, thank you. was not aware of this.

thank you very much!

jrp


December 3, 2008 | 12:29 am


December 3, 2008 | 12:35 am

Stupid on my part, I know you use 4.63 anyway and still I manage to forget. I’m sure it won’t be the last time it happens either!

lh

#P window setfont "Sans Serif" 9.;
#P number 145 300 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user hslider 145 318 18 128 128 1 0 0;
#P window linecount 1;
#P newex 145 280 358 196617 expr ((log10($f1/440.)/log10(2.))*12.+69.-15.48682)/119.589417*127.;
#P flonum 145 262 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 104 111 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 104 91 338 196617 expr (pow(2.\,((($f1/127.*119.589417+15.48682)-69.)/12.)))*440.;
#P window setfont Helvetica 9.;
#P user filtergraph~ 104 131 256 128 21 9 20. 20000. 0.0625 16. 0 1 1 0 0 1 1;
#X frgb 170 170 170;
#X brgb 209 209 209;
#X rgb2 0 0 0;
#X rgb3 130 130 130;
#X rgb4 0 0 0;
#X rgb5 76 108 172;
#X rgb6 210 74 54;
#X rgb7 255 22 22;
#X linmarkers 5512.5 11025. 16537.5;
#X logmarkers 10. 100. 1000. 10000.;
#X nfilters 1;
#X setfilter 0 5 1 0 0 19. 1. 2.5 0. 0. 0. 0. 0. 0.;
#X done;
#P window setfont "Sans Serif" 9.;
#P number 104 73 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user hslider 104 52 18 128 128 1 0 0;
#P connect 8 0 7 0;
#P connect 6 0 8 0;
#P connect 5 0 6 0;
#P connect 2 1 5 0;
#P fasten 4 0 2 5 109 128 284 128;
#P connect 3 0 4 0;
#P connect 1 0 3 0;
#P connect 0 0 1 0;
#P window clipboard copycount 9;


December 3, 2008 | 12:37 am

ej, can i invoke pow into a scale object itself then?

like
scale 0 127 0 pow2

???

jrp


December 3, 2008 | 12:39 am

LH,

Lovely, thanks a zillion!

jrp


December 3, 2008 | 12:45 am


December 3, 2008 | 12:50 am

No worries. In case you wondered what the seemingly random numbers in the [expr]s are they are the floating point midi values of 20Hz and 20000Hz-20Hz (i.e. the range). Explore the maths at your peril.

And as you might of noticed [scale] doesn’t let you put anything as helpful as pow2 in place of the final argument.

lh


December 3, 2008 | 1:49 am

>[scale] doesn’t let you put anything as helpful as pow2 in
> place of the final argument.

feature request! as soon as i am financially able to buy max 5…

deeply sorry to expose this.
The need to permanently upgrade is a real terror of today.

Thank you very much, LH!

jrp


December 3, 2008 | 3:15 am

Hey guys,

For what it’s worth, here are some abstractions I put together to add my own (intuitive, to me) 5th argument to both the scale and the zmap objects. They’re in Max5 though.

best,
Zachary


December 3, 2008 | 11:55 am


December 3, 2008 | 2:17 pm

Take a look at lp.scampi and lp.scampf from Litter Power.

They optionally allow you to clip/wrap/reflect out-of-range input back into range. And the 5th input is invertible.

Here’s a simple patch below demonstrating this. Requires lp.scampf (obviously?) from the Litter Starter Pack. URI at the very bottom of the message.

Hope this helps — Peter

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 203 145 43 196617 * – 1.;
#P flonum 203 79 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 63 205 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 63 140 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 63 80 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 63 173 152 196617 lp.scampf map 0 100 0 1 pow 1;
#P user umenu 6 79 47 196647 1 64 95 1;
#X add lin;
#X add exp;
#X add pow;
#P newex 63 105 152 196617 lp.scampf map 0 1 0 100 pow 1;
#P comment 8 51 230 196617 Lp.scampf is self-invertible in lin and pow modes;
#P connect 7 0 1 5;
#P fasten 7 0 8 0 208 98 218 98 218 137 208 137;
#P fasten 2 1 1 0 48 101 68 101;
#P fasten 2 1 3 0 48 163 68 163;
#P connect 8 0 3 5;
#P connect 3 0 6 0;
#P connect 5 0 3 0;
#P connect 1 0 5 0;
#P connect 4 0 1 0;
#P window clipboard copycount 9;


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