Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class AudioParam
- Object
- AudioParam
A value of an AudioNode that can be scheduled ahead of time and modulated
by other nodes, the Web Audio AudioParam.
The value at any moment is the automation timeline (or the default value
when nothing is scheduled), plus the sum of every node output connected to
the parameter with AudioNode.connect(AudioParam), clamped to
getMinValue() and getMaxValue(). Scheduling methods return the
parameter so calls can be chained:
OfflineAudioContext audio = new OfflineAudioContext(2, 44100, 44100);
GainNode gain = audio.createGain();
double now = audio.getCurrentTime();
gain.getGain().setValueAtTime(0, now)
.linearRampToValueAtTime(1, now + 0.05)
.setTargetAtTime(0.2f, now + 0.05, 0.1);Times are in the context’s time base, BaseAudioContext.getCurrentTime().
Every method may be called from any thread; changes reach the renderer at
its next render quantum.
Methods
Inherited methods
Method details
getDefaultValue
public float getDefaultValue()The value used when nothing is scheduled.
Returns
the default value
getMinValue
public float getMinValue()The lowest value the parameter can take.
Returns
the nominal minimum
getMaxValue
public float getMaxValue()The highest value the parameter can take.
Returns
the nominal maximum
getAutomationRate
public AutomationRate getAutomationRate()The automation rate.
Returns
whether the value is computed per sample or per render quantum
setAutomationRate
public void setAutomationRate(AutomationRate rate)Sets the automation rate.
Parameters
rateAutomationRate- the new rate
Throws
IllegalStateException- for a parameter whose rate the specification
fixes, such as
AudioBufferSourceNode.playbackRate
getValue
public float getValue()The intrinsic value at the context’s current time: the automation
timeline, without the contribution of connected nodes.
Returns
the value
setValue
public void setValue(float value)Sets the value now, the same as
setValueAtTime(value, context.getCurrentTime()).Parameters
valuefloat- the new value
setValueAtTime
public AudioParam setValueAtTime(float value, double startTime)Changes the value at
startTime.Parameters
valuefloat- the new value
startTimedouble- when, in context seconds
Returns
this parameter
linearRampToValueAtTime
public AudioParam linearRampToValueAtTime(float value, double endTime)Ramps linearly from the previous scheduled value to
value, reaching it
at endTime.Parameters
valuefloat- the value to reach
endTimedouble- when it is reached
Returns
this parameter
exponentialRampToValueAtTime
public AudioParam exponentialRampToValueAtTime(float value, double endTime)Ramps exponentially from the previous scheduled value to
value,
reaching it at endTime. If the previous value is 0 or of the other
sign the value holds until endTime, as the specification requires.Parameters
valuefloat- the value to reach; must not be 0
endTimedouble- when it is reached
Returns
this parameter
setTargetAtTime
public AudioParam setTargetAtTime(float target, double startTime, double timeConstant)Starts an exponential approach to
target at startTime. After
timeConstant seconds about 63% of the distance has been covered.Parameters
targetfloat- the value approached
startTimedouble- when the approach starts
timeConstantdouble- the time constant in seconds, 0 or more; 0 jumps
Returns
this parameter
setValueCurveAtTime
public AudioParam setValueCurveAtTime(float[] values, double startTime, double duration)Follows
values from startTime for duration seconds, linearly
interpolating between them, then holds the last one.Parameters
valuesfloat[]- at least two values; copied
startTimedouble- when the curve starts
durationdouble- how long it lasts, more than 0
Returns
this parameter
cancelScheduledValues
public AudioParam cancelScheduledValues(double cancelTime)Removes every event scheduled at or after
cancelTime.Parameters
cancelTimedouble- the first time to clear
Returns
this parameter
cancelAndHoldAtTime
public AudioParam cancelAndHoldAtTime(double cancelTime)Like
cancelScheduledValues(double), but the value the timeline would
have had at cancelTime is held from then on, so a ramp in progress
stops where it was rather than jumping back.Parameters
cancelTimedouble- when to hold
Returns
this parameter