Gain
class Core ↳ extends ToneAudioNode<GainOptions<TypeName>>
A thin wrapper around the Native Web Audio GainNode. The GainNode is a basic building block of the Web Audio API and is useful for routing audio and adjusting gains.
return Tone.Offline(() => {
const gainNode = new Tone.Gain(0).toDestination();
const osc = new Tone.Oscillator(30).connect(gainNode).start();
gainNode.gain.rampTo(1, 0.1);
gainNode.gain.rampTo(0, 0.4, 0.2);
}, 0.7, 1);Constructor
Section titled “Constructor”new Gain(gain?: UnitMap[TypeName], units?: TypeName)Parameters
-
gain
UnitMap[TypeName]optionalThe initial gain of the GainNode
-
units
TypeNameoptionalThe units of the gain parameter.
new Gain(options?: Partial<GainOptions<TypeName>>)Parameters
- options
Partial<GainOptions<TypeName>>optional
Properties
Section titled “Properties”read-only
gain: Param<TypeName>The gain parameter of the gain node.
const gainNode = new Tone.Gain(0).toDestination(); const osc = new Tone.Oscillator().connect(gainNode).start(); gainNode.gain.rampTo(1, 0.1); gainNode.gain.rampTo(0, 2, "+0.5");
read-only
input: GainNodeThe input node or nodes. If the object is a source, it does not have any input and this.input is undefined.
output
Section titled “output”read-only
output: GainNodeThe output nodes. If the object is a sink, it does not have any output and this.output is undefined.
Methods
Section titled “Methods”getDefaults()
Section titled “getDefaults()”static
getDefaults(): GainOptions<any>Returns all of the default options belonging to the class.
Returns GainOptions<any>
Inherited members
Section titled “Inherited members”- From
ToneWithContext: context, blockTime, sampleTime, get(), immediate(), now(), set(), toFrequency(), toSeconds(), toTicks() - From
Tone: debug, version, disposed, toString() - From
ToneAudioNode: channelCount, channelCountMode, channelInterpretation, numberOfInputs, numberOfOutputs, chain(), connect(), disconnect(), fan(), toDestination(), toMaster()