# 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)

*** ** * ** ***


```
public interface DefaultGainProvider.FadeProvider
```

<br />

*** ** * ** ***

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

## Summary

| ### Public methods |
|---|---|
| `abstract float` | `https://developer.android.com/reference/androidx/media3/common/audio/DefaultGainProvider.FadeProvider#getGainFactorAt(long,long)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long index, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) long duration )` Returns the gain factor within \[0f; 1f\] to apply to an audio sample for a specific fade shape. |

## Public methods

### getGainFactorAt

```
abstract float getGainFactorAt(
    @IntRange(from = 0) long index,
    @IntRange(from = 1) long duration
)
```

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:

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

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