AudioParam
The AudioParam interface represents audio-related parameter (such as gain property of GainNode`).
It can be set to specific value or schedule value change to happen at specific time, and following specific pattern.
a-rate vs k-rate
a-rate- takes the current audio parameter value for each sample frame of the audio signal.k-rate- uses the same initial audio parameter value for the whole block processed.
Properties
| Name | Type | Description | |
|---|---|---|---|
defaultValue | number | Initial value of the parameter. | Read only |
minValue | number | Minimum possible value of the parameter. | Read only |
maxValue | number | Maximum possible value of the parameter. | Read only |
value | number | Current value of the parameter. Initially set to defaultValue. |
Methods
setValueAtTime
Schedules an instant change to the value at given startTime.
If you need to call this function many times (especially more than 31 times), it is recommended to use the methods described below
(such as linearRampToValueAtTime or exponentialRampToValueAtTime),
as they are more efficient for continuous changes. For more specific use cases, you can schedule multiple value changes using setValueCurveAtTime.

| Parameters | Type | Description |
|---|---|---|
value | number | A float representing the value the AudioParam will be set at given time |
startTime | number | The time, in seconds, at which the change in value is going to happen. |
Errors:
| Error type | Description |
|---|---|
RangeError | startTime is negative number. |
Returns AudioParam.
linearRampToValueAtTime
Schedules a gradual linear change to the new value.
The change begins at the time designated for the previous event. It follows a linear ramp to the value, achieving it by the specified endTime.

| Parameters | Type | Description |
|---|---|---|
value | number | A float representing the value, the AudioParam will ramp to by given time. |
endTime | number | The time, in seconds, at which the value ramp will end. |
Errors
| Error type | Description |
|---|---|
RangeError | endTime is negative number. |
Returns AudioParam.
exponentialRampToValueAtTime
Schedules a gradual exponential change to the new value.
The change begins at the time designated for the previous event. It follows an exponential ramp to the value, achieving it by the specified endTime.

| Parameters | Type | Description |
|---|---|---|
value | number | A float representing the value the AudioParam will ramp to by given time. |
endTime | number | The time, in seconds, at which the value ramp will end. |
Errors
| Error type | Description |
|---|---|
RangeError | endTime is negative number. |
Returns AudioParam.
setTargetAtTime
Schedules a gradual change to the new value at the start time. This method is useful for decay or release portions of ADSR envelopes.

| Parameters | Type | Description |
|---|---|---|
target | number | A float representing the value to which the AudioParam will start transitioning. |
startTime | number | The time, in seconds, at which exponential transition will begin. |
timeConstant | number | A double representing the time-constant value of an exponential approach to the target. |
Errors
| Error type | Description |
|---|---|
RangeError | startTime is negative number. |
RangeError | timeConstant is negative number. |
Returns AudioParam.
setValueCurveAtTime
Schedules the parameters's value change following a curve defined by given array.

| Parameters | Type | Description |
|---|---|---|
values | Float32Array | The array of values defining a curve, which change will follow. |
startTime | number | The time, in seconds, at which change will begin. |
duration | number | A double representing total time over which the change will happen. |
Errors
| Error type | Description |
|---|---|
RangeError | startTime is negative number. |
Returns AudioParam.
cancelScheduledValues
Cancels all scheduled changes after given cancel time.
| Parameters | Type | Description |
|---|---|---|
cancelTime | number | The time, in seconds, after which all scheduled changes will be cancelled. |
Errors
| Error type | Description |
|---|---|
RangeError | cancelTime is negative number. |
Returns AudioParam.
cancelAndHoldAtTime
Cancels all scheduled changes after given cancel time, but holds its value at given cancel time until further changes appear.
| Parameters | Type | Description |
|---|---|---|
cancelTime | number | The time, in seconds, after which all scheduled changes will be cancelled. |
Errors
| Error type | Description |
|---|---|
RangeError | cancelTime is negative number. |
Returns AudioParam.
Remarks
All time parameters should be in the same time coordinate system as BaseAudioContext.currentTime.