gain~ internal formulas

Oct 5, 2008 at 7:54pm

gain~ internal formulas

I’m trying to understand the internal workings of the gain~ object. Specifically, what is the formula it uses to derive its scale factor for scaling the amplitude of the incoming signal?

I don’t understand the meaning of the “log increment” attribute (defaults to 1.071519) and the “log scale value” attribute (defaults to 7.94321). What is the formula that these constants are getting plugged into? There is no indication in the gain~ help file of what these values actually represent, and what will result from changing these values.

Thanks

#40158
Oct 5, 2008 at 9:36pm

On 05 Oct 2008, at 21:54, Scott wrote:
>
> I’m trying to understand the internal workings of the gain~
> object. Specifically, what is the formula it uses to derive its
> scale factor for scaling the amplitude of the incoming signal?
>
> I don’t understand the meaning of the “log increment” attribute
> (defaults to 1.071519) and the “log scale value” attribute
> (defaults to 7.94321). What is the formula that these constants
> are getting plugged into? There is no indication in the gain~ help
> file of what these values actually represent, and what will result
> from changing these values.
>
hi scott,
the help file (max 4.6) says it’s the same formula as for linedrive
(which is the same as for [scale] i believe).
it’s in the max reference.

maybe the patch below sheds some light on the inner workings.

volker.

#P window setfont “Sans Serif” 9.;
#P flonum 121 331 59 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 121 307 34 196617 atodb;
#P flonum 507 307 59 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 507 283 34 196617 dbtoa;
#P comment 569 259 28 196617 dB;
#P flonum 507 257 59 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 507 233 102 196617 expr ($i1-128)*0.6;
#P number 507 210 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 43 282 61 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user ezdac~ 214 71 258 104 0;
#P comment 206 283 100 196617 gain factor;
#P newex 43 51 67 196617 cycle~ 1000;
#P newex 43 254 69 196617 peakamp~ 80;
#P flonum 121 282 80 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 121 220 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user gain~ 43 78 24 100 158 0 1.071519 7.94321 10.;
#P newex 121 254 334 196617 expr 7.94321 * exp(-158.*log(1.071519)) *
exp($i1*log(1.071519));
#P comment 164 223 100 196617 slider value;
#P comment 506 178 100 196617 short version;
#P connect 7 0 3 0;
#P connect 3 0 6 0;
#P connect 6 0 10 0;
#P fasten 3 1 4 0 62 210 126 210;
#P connect 4 0 2 0;
#P connect 2 0 5 0;
#P connect 5 0 17 0;
#P connect 17 0 18 0;
#P fasten 3 1 11 0 62 203 512 203;
#P connect 11 0 12 0;
#P connect 12 0 13 0;
#P connect 13 0 15 0;
#P connect 15 0 16 0;
#P window clipboard copycount 19;

#141819
Oct 6, 2008 at 8:37am

#141820
Oct 6, 2008 at 11:49pm

volker,

So, from your example patch, it seems that gain~’s formula is:

G = SV * e^(-S * log(I)) * e^(V * log(I))

where:

G = Gain Factor
SV = Log Scale Value
e = 2.71828183
S = Number of Steps
I = Log Increment
V = Current Slider Value

Excellent, very helpful! This should be posted in the gain~ help file, in my opinion… or at least in the reference page.

For what it’s worth, the above formula can be simplified as:

G = SV * e^((V-S)*log(I))

#141821

You must be logged in to reply to this topic.