Table of Contents

Class AudioParam

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The Web Audio API's AudioParam interface represents an audio-related parameter, usually a parameter of an AudioNode (such as Gain).

[Value("AudioParam")]
public class AudioParam
Inheritance
AudioParam
Inherited Members

Remarks

An AudioParam can be set to a specific value or a change in value, and can be scheduled to happen at a specific time and following a specific pattern.

Each AudioParam has a list of events, initially empty, that define when and how values change. When this list is not empty, changes using the AudioParam.value attributes are ignored. This list of events allows us to schedule changes that have to happen at very precise times, using arbitrary timeline-based automation curves. The time used is the one defined in BaseAudioContextcurrentTime.

-Using the Web Audio API

See also on MDN

Constructors

AudioParam()

public AudioParam()

Properties

AutomationRate

[Value("automationRate")]
public AutomationRate AutomationRate { get; set; }

Property Value

AutomationRate

DefaultValue

The defaultValue
read-only property of the AudioParam interface represents the initial
value of the attributes as defined by the specific AudioNode creating
the AudioParam.

[Value("defaultValue")]
public Number DefaultValue { get; }

Property Value

Number

A floating-point Number.

Remarks

MaxValue

The maxValue
read-only property of the AudioParam interface represents the maximum
possible value for the parameter's nominal (effective) range.

[Value("maxValue")]
public Number MaxValue { get; }

Property Value

Number

A floating-point Number indicating the maximum value permitted for the
parameter's nominal range.The default value of maxValue is the maximum positive single-precision
floating-point value (+340,282,346,638,528,859,811,704,183,484,516,925,440).

Remarks

MinValue

The minValue
read-only property of the AudioParam interface represents the minimum
possible value for the parameter's nominal (effective) range.

[Value("minValue")]
public Number MinValue { get; }

Property Value

Number

A floating-point Number indicating the minimum value permitted for the
parameter's nominal range.The default value of minValue is the minimum negative single-precision
floating-point value (-340,282,346,638,528,859,811,704,183,484,516,925,440).

Remarks

Value

The value property of the AudioParam interface gets or sets the value of this AudioParam at the current time.
Initially, the value is set to DefaultValue.

[Value("value")]
public Number Value { get; set; }

Property Value

Number

A floating-point Number indicating the parameter's value as of the current time.
This value will be between the values specified by the MinValue and MaxValue properties.The data type used internally to store value is a single-precision (32-bit) floating point number, while JavaScript uses 64-bit double-precision floating point numbers.
As a result, the value you read from the value property may not always exactly equal what you set it to.Consider this example:The log output will be false, because the playback rate parameter, rate, was converted to the 32-bit floating-point number closest to 5.3, which yields 5.300000190734863.
One solution is to use the MathFround method, which returns the single-precision value equivalent to the 64-bit JavaScript value specified—when setting value, like this:In this case, the log output will be true.The value of an AudioParam can either be fixed or can vary over time.
This is reflected by the value getter, which returns the value of the parameter as of the audio rendering engine's most recent render quantum, or moment at which audio buffers are processed and updated.
In addition to processing audio buffers, each render quantum updates the value of each AudioParam as needed given the current time and any established time-based parameter value changes.Upon first creating the parameter, its value is set to its default value, given by DefaultValue.
This is the parameter's value at a time of 0.0 seconds, and will remain the parameter's value until the first render quantum in which the value is altered.During each render quantum, the browser does the following things related to managing the value of a parameter:Thus, the value of a parameter is maintained to accurately reflect the state of the parameter over time.

Remarks

Setting value has the same effect as calling SetValueAtTime(Number, Number) with the time returned by the AudioContext's BaseAudioContextcurrentTime property.

-Using the Web Audio API

See also on MDN

Methods

CancelAndHoldAtTime(Number)

The cancelAndHoldAtTime() method of the
AudioParam interface cancels all scheduled future changes to the
AudioParam but holds its value at a given time until further changes are
made using other methods.

[Value("cancelAndHoldAtTime")]
public AudioParam CancelAndHoldAtTime(Number cancelTime)

Parameters

cancelTime Number

Returns

AudioParam

A reference to the AudioParam it was called on.

Remarks

CancelScheduledValues(Number)

The cancelScheduledValues() method of the AudioParam
Interface cancels all scheduled future changes to the AudioParam.

[Value("cancelScheduledValues")]
public AudioParam CancelScheduledValues(Number cancelTime)

Parameters

cancelTime Number

Returns

AudioParam

A reference to this AudioParam object. In some older implementations this
method returns 'undefined'.

Remarks

ExponentialRampToValueAtTime(Number, Number)

The exponentialRampToValueAtTime() method of the AudioParam Interface schedules a gradual exponential change in the value of the AudioParam.
The change starts at the time specified for the previous event, follows an exponential ramp to the new value given in the value parameter, and reaches the new value at the time given in the
endTime parameter.

[Value("exponentialRampToValueAtTime")]
public AudioParam ExponentialRampToValueAtTime(Number value, Number endTime)

Parameters

value Number
endTime Number

Returns

AudioParam

A reference to this AudioParam object. In some browsers older
implementations of this interface return 'undefined'.

Remarks

NOTE

Exponential ramps are considered more useful when changing
frequencies or playback rates than linear ramps because of the way the human ear
works.

-Using the Web Audio API

See also on MDN

LinearRampToValueAtTime(Number, Number)

The linearRampToValueAtTime() method of the AudioParam
Interface schedules a gradual linear change in the value of the
AudioParam. The change starts at the time specified for the
previous event, follows a linear ramp to the new value given in the
value parameter, and reaches the new value at the time given in the
endTime parameter.

[Value("linearRampToValueAtTime")]
public AudioParam LinearRampToValueAtTime(Number value, Number endTime)

Parameters

value Number
endTime Number

Returns

AudioParam

A reference to this AudioParam object. In some browsers older
implementations of this interface return 'undefined'.

Remarks

SetTargetAtTime(Number, Number, Number)

The setTargetAtTime() method of the
AudioParam interface schedules the start of a gradual change to the
AudioParam value. This is useful for decay or release portions of ADSR
envelopes.

[Value("setTargetAtTime")]
public AudioParam SetTargetAtTime(Number target, Number startTime, Number timeConstant)

Parameters

target Number
startTime Number
timeConstant Number

Returns

AudioParam

A reference to this AudioParam object. Some older browser implementations
of this interface return 'undefined'.

Remarks

SetValueAtTime(Number, Number)

The setValueAtTime() method of the
AudioParam interface schedules an instant change to the
AudioParam value at a precise time, as measured against
BaseAudioContextcurrentTime. The new value is given in the value parameter.

[Value("setValueAtTime")]
public AudioParam SetValueAtTime(Number value, Number startTime)

Parameters

value Number
startTime Number

Returns

AudioParam

A reference to this AudioParam object. In some browsers older
implementations of this interface return 'undefined'.

Remarks

SetValueCurveAtTime(List<Number>, Number, Number)

The
setValueCurveAtTime() method of the
AudioParam interface schedules the parameter's value to change
following a curve defined by a list of values.

[Value("setValueCurveAtTime")]
public AudioParam SetValueCurveAtTime(List<Number> values, Number startTime, Number duration)

Parameters

values List<Number>
startTime Number
duration Number

Returns

AudioParam

A reference to this AudioParam object. Some older browser implementations
of this interface return undefined.

Remarks

The curve is a linear
interpolation between the sequence of values defined in an array of floating-point
values, which are scaled to fit into the given interval starting at
startTime and a specific duration.

-Using the Web Audio API

See also on MDN