Param < Type >

Param wraps the native Web Audio's AudioParam to provide additional unit conversion functionality. It also serves as a base-class for classes which have a single, automatable parameter.

Type Parameter

Hierarchy

Constructor

new Param (
param:AudioParam ,

The AudioParam to wrap

units?:Unit ,

The unit name

convert?:undefined | false | true

Whether or not to convert the value to the target units

) => Param
new Param (
options:Partial<ParamOptions<Type > >
) => Param

Properties

blockTime #

readonly Seconds

The number of seconds of 1 processing block (128 samples)

context #

Context

The context belonging to the node.

convert #

boolean

If the value should be converted or not

debug #

boolean

Set this debug flag to log all events that happen in this class.

defaultValue #

readonly Type

disposed #

readonly boolean

Indicates if the instance was disposed. 'Disposing' an instance means that all of the Web Audio nodes that were created for the instance are disconnected and freed for garbage collection.

input #

AudioParam

The input connection

maxValue #

readonly number

The maximum value of the output given the units

minValue #

readonly number

The minimum value of the output given the units

name #

string

overridden #

boolean

True if the signal value is being overridden by a connected signal. Internal use only.

sampleTime #

readonly Seconds

The duration in seconds of one sample.

units #

UnitName

The unit type

value #

Type

The current value of the parameter. Setting this value is equivalent to setValueAtTime(value, context.currentTime)

static version #

string

The version number semver

Methods

apply #

Apply all of the previously scheduled events to the passed in Param or AudioParam. The applied values will start at the context's current time and schedule all of the events which are scheduled on this Param onto the passed in param.

apply (
param:Param | AudioParam
) => this

cancelAndHoldAtTime #

This is similar to cancelScheduledValues except it holds the automated value at time until the next automated event.

cancelAndHoldAtTime (
time:Time
) => this

cancelScheduledValues #

Cancels all scheduled parameter changes with times greater than or equal to startTime.

cancelScheduledValues (
time:Time
) => this

dispose #

disconnect and dispose.

dispose ( ) => this

exponentialApproachValueAtTime #

Start exponentially approaching the target value at the given time. Since it is an exponential approach it will continue approaching after the ramp duration. The rampTime is the time that it takes to reach over 99% of the way towards the value. This methods is similar to setTargetAtTime except the third argument is a time instead of a 'timeConstant'


//exponentially ramp to the value 2 over 4 seconds.
signal.exponentialRampTo(2, 4);
exponentialApproachValueAtTime (
value:Type ,
time:Time ,
rampTime:Time
) => this

exponentialRampTo #

Schedules an exponential continuous change in parameter value from the current time and current value to the given value over the duration of the rampTime.


//exponentially ramp to the value 2 over 4 seconds.
signal.exponentialRampTo(2, 4);
exponentialRampTo (
value:Type ,
rampTime:Time ,
startTime?:Time
) => this

exponentialRampToValueAtTime #

Schedules an exponential continuous change in parameter value from the previous scheduled parameter value to the given value.

exponentialRampToValueAtTime (
value:Type ,
endTime:Time
) => this

get #

Get the object's attributes.


osc.get();
//returns {"type" : "sine", "frequency" : 440, ...etc}
get ( ) => ParamOptions<Type >

static getDefaults #

Returns all of the default options belonging to the class.

getDefaults ( ) => ParamOptions<any >

getValueAtTime #

Get the signals value at the given time. Subsequent scheduling may invalidate the returned value.

getValueAtTime (
time:Time
) => Type

immediate #

Return the current time of the Context clock without any lookAhead.

immediate ( ) => Seconds

linearRampTo #

Schedules an linear continuous change in parameter value from the current time and current value to the given value over the duration of the rampTime.


//linearly ramp to the value 4 over 3 seconds.
signal.linearRampTo(4, 3);
linearRampTo (
value:Type ,
rampTime:Time ,
startTime?:Time
) => this
this

linearRampToValueAtTime #

Schedules a linear continuous change in parameter value from the previous scheduled parameter value to the given value.

linearRampToValueAtTime (
value:Type ,
endTime:Time
) => this

now #

Return the current time of the Context clock plus the lookAhead.

now ( ) => Seconds

rampTo #

Ramps to the given value over the duration of the rampTime. Automatically selects the best ramp type (exponential or linear) depending on the units of the signal


//ramp to the value either linearly or exponentially
//depending on the "units" value of the signal
signal.rampTo(0, 10);

//schedule it to ramp starting at a specific time
signal.rampTo(0, 10, 5)
rampTo (
value:Type ,
rampTime= 0.1:Time ,
startTime?:Time
) => this

set #

Set the parameters at once. Either pass in an object mapping parameters to values, or to set a single parameter, by passing in a string and value. The last argument is an optional ramp time which will ramp any signal values to their destination value over the duration of the rampTime.


//set values using an object
filter.set({
"frequency" : 300,
"type" : "highpass"
});
set ( ) => this

setRampPoint #

Creates a schedule point with the current value at the current time. This is useful for creating an automation anchor point in order to schedule changes from the current value.


param.getValueAtTime(Tone.now())
setRampPoint (
time:Time
) => this

setTargetAtTime #

Start exponentially approaching the target value at the given time with a rate having the given time constant.

setTargetAtTime (
value:Type ,
startTime:Time ,
timeConstant:Positive
) => this

setValueAtTime #

Schedules a parameter value change at the given time. Does this work? is this working. are you working?


//set the frequency to "G4" in exactly 1 second from now.
freq.setValueAtTime("G4", "+1");
setValueAtTime (
value:Type ,
time:Time
) => this

setValueCurveAtTime #

Sets an array of arbitrary parameter values starting at the given time for the given duration.

setValueCurveAtTime (
values:Type [] ,
startTime:Time ,
duration:Time ,
scaling= 1:number
) => this

targetRampTo #

Start exponentially approaching the target value at the given time. Since it is an exponential approach it will continue approaching after the ramp duration. The rampTime is the time that it takes to reach over 99% of the way towards the value.


//exponentially ramp to the value 2 over 4 seconds.
signal.exponentialRampTo(2, 4);
targetRampTo (
value:Type ,
rampTime:Time ,
startTime?:Time
) => this

toFrequency #

Convert the input to a frequency number

toFrequency (
freq:Frequency
) => Hertz

toSeconds #

Convert the incoming time to seconds

toSeconds (
time?:Time
) => Seconds

toString #

Convert the class to a string


const osc = new Oscillator()
osc.toString() // "Oscillator"
toString ( ) => string

toTicks #

Convert the input time into ticks

toTicks (
time?:Time | TimeClass
) => Ticks