# DefaultGainProvider.FadeProvider

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/audio/DefaultGainProvider.java+class:androidx.media3.common.audio.DefaultGainProvider.FadeProvider)

*** ** * ** ***


```
interface DefaultGainProvider.FadeProvider
```

<br />

*** ** * ** ***

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

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/DefaultGainProvider.FadeProvider#getGainFactorAt(long,long)( index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, duration: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` 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:

```kotlin
&#64;Override
public float getGainFactorAt(long index, long duration) {
  return (float) index / duration;
}
```

| Parameters |
|---|---|
| `index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Position (numerator) between \[0; `duration`\]. |
| `duration: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 1) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Duration (denominator). |