DefaultGainProvider.FadeProvider


interface DefaultGainProvider.FadeProvider


Represents a time unit-agnostic fade shape to be applied over an automation.

Summary

Public functions

Float
getGainFactorAt(
    index: @IntRange(from = 0) Long,
    duration: @IntRange(from = 1) Long
)

Returns the gain factor within [0f; 1f] to apply to an audio sample for a specific fade shape.

Public functions

getGainFactorAt

fun getGainFactorAt(
    index: @IntRange(from = 0) Long,
    duration: @IntRange(from = 1) Long
): Float

Returns the gain factor within [0f; 1f] to apply to an audio sample for a specific fade shape.

Position and duration are unit agnostic and work as a numerator/denominator pair.

You can implement a basic linear fade as follows:

public float getGainFactorAt(long index, long duration) {
  return (float) index / duration;
}
Parameters
index: @IntRange(from = 0) Long

Position (numerator) between [0; duration].

duration: @IntRange(from = 1) Long

Duration (denominator).