API Docs for: 2.7.1
Show:

SPAudioParam Class

Module: Effects

Mock AudioParam used to create Parameters for Sonoport Sound Models. The SPAudioParam supports either a AudioParam backed parameter, or a completely Javascript mocked up Parameter, which supports a rough version of parameter automation.

Constructor

SPAudioParam

(
  • baseSound
  • [name]
  • [minValue]
  • [maxValue]
  • [defaultValue]
  • [aParams]
  • [mappingFunction]
  • [setter]
)

Parameters:

  • baseSound BaseSound

    A reference to the BaseSound which exposes this parameter.

  • [name] String optional

    The name of the parameter.

  • [minValue] Number optional

    The minimum value of the parameter.

  • [maxValue] Number optional

    The maximum value of the parameter.

  • [defaultValue] Number optional

    The default and starting value of the parameter.

  • [aParams] AudioParam/Array optional

    A WebAudio parameter which will be set/get when this parameter is changed.

  • [mappingFunction] Function optional

    A mapping function to map values between the mapped SPAudioParam and the underlying WebAudio AudioParam.

  • [setter] Function optional

    A setter function which can be used to set the underlying audioParam. If this function is undefined, then the parameter is set directly.

Methods

cancelScheduledValues

(
  • startTime
)

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

Parameters:

  • startTime Number

    The startTime parameter is the starting time at and after which any previously scheduled parameter changes will be cancelled.

createPsuedoParam

(
  • baseSound
  • name
  • minValue
  • maxValue
  • defaultValue
)
static

Static helper method to create Psuedo parameters which are not connected to any WebAudio AudioParams.

Parameters:

  • baseSound BaseSound

    A reference to the BaseSound which exposes this parameter.

  • name String

    The name of the parameter..

  • minValue Number

    The minimum value of the parameter.

  • maxValue Number

    The maximum value of the parameter.

  • defaultValue Number

    The default and starting value of the parameter.

Returns:

SPAudioParam

exponentialRampToValueAtTime

(
  • value
  • endTime
)

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

v(t) = V0 * (V1 / V0) ^ ((t - T0) / (T1 - T0))

Parameters:

  • value Number

    The value parameter is the value the parameter will exponentially ramp to at the given time.

  • endTime Number

    The endTime parameter is the time in the same time coordinate system as AudioContext.currentTime.

linearRampToValueAtTime

(
  • value
  • endTime
)

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

Parameters:

  • value Float32Array

    The value parameter is the value the parameter will exponentially ramp to at the given time.

  • endTime Number

    The endTime parameter is the time in the same time coordinate system as AudioContext.currentTime.

setTargetAtTime

(
  • target
  • startTime
  • timeConstant
)

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

During the time interval: T0 <= t < T1, where T0 is the startTime parameter and T1 represents the time of the event following this event (or infinity if there are no following events): v(t) = V1 + (V0 - V1) * exp(-(t - T0) / timeConstant)

Parameters:

  • target Number

    The target parameter is the value the parameter will start changing to at the given time.

  • startTime Number

    The startTime parameter is the time in the same time coordinate system as AudioContext.currentTime.

  • timeConstant Number

    The timeConstant parameter is the time-constant value of first-order filter (exponential) approach to the target value. The larger this value is, the slower the transition will be.

setValueAtTime

(
  • value
  • startTime
)

Schedules a parameter value change at the given time.

Parameters:

  • value Number

    The value parameter is the value the parameter will change to at the given time.

  • startTime Number

    The startTime parameter is the time in the same time coordinate system as AudioContext.currentTime.

setValueCurveAtTime

(
  • values
  • startTime
  • duration
)

Sets an array of arbitrary parameter values starting at the given time for the given duration. The number of values will be scaled to fit into the desired duration.

During the time interval: startTime <= t < startTime + duration, values will be calculated:

v(t) = values[N * (t - startTime) / duration], where N is the length of the values array.

Parameters:

  • values Float32Array

    The values parameter is a Float32Array representing a parameter value curve. These values will apply starting at the given time and lasting for the given duration.

  • startTime Number

    The startTime parameter is the time in the same time coordinate system as AudioContext.currentTime.

  • duration Number

    The duration parameter is the amount of time in seconds (after the startTime parameter) where values will be calculated according to the values parameter.

Properties

defaultValue

Number/Boolean

Initial value for the value attribute.

Default: 0

maxValue

Number/Boolean

Maximum value which the value attribute can be set to.

Default: 0

minValue

Number/Boolean

Minimum value which the value attribute can be set to.

Default: 0

name

String

Name of the Parameter.

Default: ""

value

Number/Boolean

The parameter's value. This attribute is initialized to the defaultValue. If value is set during a time when there are any automation events scheduled then it will be ignored and no exception will be thrown.

Default: 0