gain~ Reference

Gain control

gain~

Description

gain~ is a slider that scales signals. It can also make a smooth transition as you move from one value of the slider to the next.

Examples

Specialized fader to scale a signal exponentially or logarithmically

Discussion

Parameters of line's formula that translates between slider values and the signal scalar can be changed via messages or by selecting the object and choosing Get Info... from the Max menu. The formula values are the same as for the linedrive object.
The default values of range (158), base value (7.94231), and increment (1.071519) provide for a slider where 128 is full scale (multiplying by 1.0), 0 produces a zero signal, and 1 is 75.6 dB below the value at 127. A change of 10 in the slider produces a 6 dB change in the output. In addition, since the range is 158, slider values from 129 to 157 provide 17.4 dB of headroom. When the slider is at 157, the output signal is 17.4 dB louder than the input signal.

Arguments

None.

Attributes

bgcolor [4 floats]

Sets the first interior color (background) of the gain~ object in RGBA format.

inc [float] (default: 1.071519)

Sets the increment value used to calculate the output scale factor based on the input value. The default value is 1.071519.

interp [float] (default: 10.)

Sets the interpolation ramp time in milliseconds for the gain~ object. The default is 10.

interpinlet [int] (default: 0)7.0.0

Toggles the display of the interpolation inlet.

knobcolor [4 floats]

Sets the color of the knob and the stripes of the value color in RGBA format. The knobcolor attribute is mapped to the color style color.

multislider [int] (default: 0)

This attribute only applies to mc.gain~. If multislider is enabled, the mc.gain~ object will create a slider for each channel in its input multichannel signal, permitting independent level control of each channel. If the object is not wide or tall enough to show all the sliders, it remains in single slider mode until its size is adjusted.

orientation [int] (default: 0)

Sets the gain~ object to a horizontal or vertical data display.
Automatic: (the default for gain~ and mc.gain~) sets the display dependent on the size of the slider - longest side of the rectangle that describes the slider sets the orientation.
Horizontal
Vertical

Possible values:

0 = 'Automatic'
1 = 'Horizontal'
2 = 'Vertical'

parameter_enable [int]

Enables use of this object with Max for Live Parameters and allows for setting initial parameter values in the Max environment.

parameter_mappable [int] (default: 1)

When parameter_mappable is enabled, the object will be available for mapping to keyboard or MIDI input using the Mappings feature.

relative [int] (default: 0)

Sets way that the gain~ object responds to mouse clicks.

Possible values:

0 = 'Absolute' ( Absolute mode )
In absolute mode, the gain~ will automatically jump directly to the clicked location.

1 = 'Relative' ( Relative mode )
In relative mode (the default) the gain~ keeps its relative position when you click - Moving the mouse outputs higher or lower values in relation to that relative position.

scale [float] (default: 7.94321)

Sets the base output value used to calculate the output scale factor based on the input value. The default value is 7.94231. See the "Inspector" section for an explanation of the calculation. The word size, followed by a number, sets the range of gain~ to the number. The values of the slider will then be 0 to the range value minus 1. The default value is 158.

size [int] (default: 158)

Sets the number of steps (range) of the gain~ object. The default value is 158.

stripecolor [4 floats]

Sets the "off" color for the slider in RGBA format. The stripecolor attribute is mapped to the elementcolor style color.

style [symbol] (default: )7.0.0

Sets the style to be applied to the object. Styles can be set using the Format palette.

Common Box Attributes

Parameter Attributes

Messages

bang

Sends current slider value out right outlet.

int

Arguments

slider-value [int]
In left inlet: Sets the value of the slider, ramps the output signal to the level corresponding to the new value over the specified ramp time, and outputs the slider's value out the right outlet.

float

Arguments

slider-value [float]
In left inlet: Converted to int. Sets the value of the slider, ramps the output signal to the level corresponding to the new value over the specified ramp time, and outputs the slider's value out the right outlet.

  (inlet1)

Arguments

ramp-time [float]
In right inlet: Sets the ramp time in milliseconds. The default is 10 milliseconds.

list

Arguments

slider-value [list]
The object takes list messages in conjunction with pattr objects.

color7.0.0

Arguments

value [int]
Sets the bgcolor to a legacy color (from the 1990s) by index 0 - 15.

(mouse)

Clicking and dragging with the mouse sets the value of the slider, ramps the output signal to the level corresponding to the new value over the specified ramp time, and outputs the slider’s value out the right outlet.

set

Arguments

set-slider-value [int]
In left inlet: The word set, followed by a number, sets the value of the slider, ramps the output signal to the level corresponding to the new value over the specified ramp time, but does not output the slider's value out the right outlet.

signal

In left inlet: The input signal to be scaled by the slider.

Output

int

Out right outlet: The current slider value, when dragging on the slider with the mouse or when gain~ receives an int or float in its left inlet.

signal

Out left outlet: The input signal, scaled by the current slider value as x in the equation shown above.

See Also

Name Description
Max For Live Max For Live
linedrive
MSP Delay Tutorial 6: Comb Filter MSP Delay Tutorial 6: Comb Filter