You're using the [scale] formula from @classic_mode in Max7, which exists for compatibility with IRCAM, but it's clearly wrong. (There's no way mapping 13.3 from 0-127 to -1 to 1 should result in something so close to -1. Just try a few different exponents and you'll see that there's a bug in the Max code. And there are lots of bug reports out there about it.)

That's why they introduced an alternate mode for [scale] in Max, which can be switch in the Inspector.

For non-classic (modern) mode, the documentation gives you this equation:

((x-in_low)/(in_high-in_low) == 0) ? out_low : (((x-in_low)/(in_high-in_low)) > 0) ? (out_low + (out_high-out_low) * ((x-in_low)/(in_high-in_low))^exp) : ( out_low + (out_high-out_low) * -((((-x+in_low)/(in_high-in_low)))^(exp)))

Translated to expr as:

[expr if ((($f1-in_low)/(in_high-in_low)==0), out_low, if ((($f1-in_low)/(in_high-in_low)>0), out_low+(out_high-out_low)*pow(($f1-in_low)/(in_high-in_low), power), out_low+(out_high-out_low)*-1*pow((-1*$f1+in_low)/(in_high-in_low), power)))]

Switch off classic mode in the inspector in Max7, and you get the same result as expr above, the very sensible -0.817072.

Joel

On 06/19/2015 05:39 PM, Alexandre Torres Porres wrote:

Howdy, so I'm cloning the scale object from Max, to make an object and include in the cyclone library. It converts range input (low_in / high_in) to a range output (low_out / high_out). It has a logarithmic curve for rescaling according to a fifth argument/inlet. I did copy into expr the formula described in the reference of Max6/7 (max's 5 was just wrong, copied from [linedrive]) - well, it didn't work! Would anyone know if I'm doing something wrong or if the reference is not telling the truth?

The formula, as described in the reference is: (out_low + (out_high-out_low) * ( (out_high - out_low) * exp(-1 * (in_high-in_low) * log(power)) * exp(x * log(power)) ))


Here's my patch with that formula into expr. The output with the parameters I have should be -0.997347 - as that's the output I get in Max. But instead, it's giving -0.994694...


thanks




=================


#N canvas 24 23 488 340 10;

#X obj 215 154 v out_low;

#X obj 233 132 v out_high;

#X obj 288 110 v power;

#X obj 152 130 v in_high;

#X obj 115 153 v in_low;

#X floatatom 58 248 0 0 0 0 - - -;

#X obj 58 197 expr (out_low + (out_high-out_low) * ( (out_high - out_low)

* exp(-1*(in_high-in_low)*log(power)) * exp($f1*log(power)) ));

#X msg 115 102 0;

#X msg 152 102 127;

#X msg 215 99 -1;

#X msg 249 97 1;

#X msg 288 86 1.06;

#X obj 90 31 loadbang;

#X obj 90 60 t b b;

#X msg 58 107 13.3;

#X connect 6 0 5 0;

#X connect 7 0 4 0;

#X connect 8 0 3 0;

#X connect 9 0 0 0;

#X connect 10 0 1 0;

#X connect 11 0 2 0;

#X connect 12 0 13 0;

#X connect 13 0 14 0;

#X connect 13 1 11 0;

#X connect 13 1 10 0;

#X connect 13 1 9 0;

#X connect 13 1 8 0;

#X connect 13 1 7 0;

#X connect 14 0 6 0;




_______________________________________________
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

_______________________________________________
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to