Builder
class Builder
| kotlin.Any | |
| ↳ | android.media.VolumeShaper.Configuration.Builder |
Builder class for a VolumeShaper.Configuration object.
Here is an example where Builder is used to define the VolumeShaper.Configuration.
VolumeShaper.Configuration LINEAR_RAMP = new VolumeShaper.Configuration.Builder() .setInterpolatorType(VolumeShaper.Configuration.INTERPOLATOR_TYPE_LINEAR) .setCurve(new float[] { 0.f, 1.f }, // times new float[] { 0.f, 1.f }) // volumes .setDuration(1000) .build();
Summary
| Public constructors | |
|---|---|
Builder()Constructs a new |
|
Builder(configuration: VolumeShaper.Configuration)Constructs a new |
|
| Public methods | |
|---|---|
| VolumeShaper.Configuration |
build()Builds a new |
| VolumeShaper.Configuration.Builder |
Inverts the volume curve so that the max volume becomes the min volume and vice versa. |
| VolumeShaper.Configuration.Builder |
Reflects the volume curve so that the shaper changes volume from the end to the start. |
| VolumeShaper.Configuration.Builder |
scaleToEndVolume(volume: Float)Scale the curve end volume to a target value. |
| VolumeShaper.Configuration.Builder |
scaleToStartVolume(volume: Float)Scale the curve start volume to a target value. |
| VolumeShaper.Configuration.Builder |
setCurve(times: FloatArray, volumes: FloatArray)Sets the volume curve. |
| VolumeShaper.Configuration.Builder |
setDuration(durationMillis: Long)Sets the |
| VolumeShaper.Configuration.Builder |
setInterpolatorType(interpolatorType: Int)Sets the interpolator type. |
Public constructors
Builder
Builder(configuration: VolumeShaper.Configuration)
Constructs a new Builder with settings copied from a given VolumeShaper.Configuration.
| Parameters | |
|---|---|
configuration |
VolumeShaper.Configuration: prototypical configuration which will be reused in the new Builder. This value cannot be null. |
Public methods
build
fun build(): VolumeShaper.Configuration
Builds a new VolumeShaper object.
| Return | |
|---|---|
VolumeShaper.Configuration |
a new VolumeShaper object. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
if curve is not properly set. |
invertVolumes
fun invertVolumes(): VolumeShaper.Configuration.Builder
Inverts the volume curve so that the max volume becomes the min volume and vice versa.
| Return | |
|---|---|
VolumeShaper.Configuration.Builder |
the same Builder instance. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
if curve has not been set. |
reflectTimes
fun reflectTimes(): VolumeShaper.Configuration.Builder
Reflects the volume curve so that the shaper changes volume from the end to the start.
| Return | |
|---|---|
VolumeShaper.Configuration.Builder |
the same Builder instance. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
if curve has not been set. |
scaleToEndVolume
fun scaleToEndVolume(volume: Float): VolumeShaper.Configuration.Builder
Scale the curve end volume to a target value. Keeps the start volume the same. This works best if the volume curve is monotonic.
| Parameters | |
|---|---|
volume |
Float: the target end volume to use. |
| Return | |
|---|---|
VolumeShaper.Configuration.Builder |
the same Builder instance. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if volume is not valid. |
java.lang.IllegalStateException |
if curve has not been set. |
scaleToStartVolume
fun scaleToStartVolume(volume: Float): VolumeShaper.Configuration.Builder
Scale the curve start volume to a target value. Keeps the end volume the same. This works best if the volume curve is monotonic.
| Parameters | |
|---|---|
volume |
Float: the target start volume to use. |
| Return | |
|---|---|
VolumeShaper.Configuration.Builder |
the same Builder instance. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if volume is not valid. |
java.lang.IllegalStateException |
if curve has not been set. |
setCurve
fun setCurve(
times: FloatArray,
volumes: FloatArray
): VolumeShaper.Configuration.Builder
Sets the volume curve. The volume curve is represented by a set of control points given by two float arrays of equal length, one representing the time (x) coordinates and one corresponding to the volume (y) coordinates. The length must be at least 2 and no greater than VolumeShaper.Configuration.getMaximumCurvePoints().
The volume curve is normalized as follows: time (x) coordinates should be monotonically increasing, from 0.f to 1.f; volume (y) coordinates must be within 0.f to 1.f.
The time scale is set by setDuration.
| Parameters | |
|---|---|
times |
FloatArray: an array of float values representing the time line of the volume curve. This value cannot be null. |
volumes |
FloatArray: an array of float values representing the amplitude of the volume curve. This value cannot be null. |
| Return | |
|---|---|
VolumeShaper.Configuration.Builder |
the same Builder instance. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if times or volumes is invalid. |
setDuration
fun setDuration(durationMillis: Long): VolumeShaper.Configuration.Builder
Sets the VolumeShaper duration in milliseconds. If omitted, the default duration is 1 second.
| Parameters | |
|---|---|
durationMillis |
Long: |
| Return | |
|---|---|
VolumeShaper.Configuration.Builder |
the same Builder instance. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if durationMillis is not strictly positive. |
setInterpolatorType
fun setInterpolatorType(interpolatorType: Int): VolumeShaper.Configuration.Builder
Sets the interpolator type. If omitted the default interpolator type is INTERPOLATOR_TYPE_CUBIC.
| Parameters | |
|---|---|
interpolatorType |
Int: method of interpolation used for the volume curve. One of INTERPOLATOR_TYPE_STEP, INTERPOLATOR_TYPE_LINEAR, INTERPOLATOR_TYPE_CUBIC, INTERPOLATOR_TYPE_CUBIC_MONOTONIC. Value is one of the following: |
| Return | |
|---|---|
VolumeShaper.Configuration.Builder |
the same Builder instance. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
if interpolatorType is not valid. |