# GainProcessor.GainProvider

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/GainProcessor.java+class:androidx.media3.common.audio.GainProcessor.GainProvider)

*** ** * ** ***


```
public interface GainProcessor.GainProvider
```

<br />

Known direct subclasses [DefaultGainProvider](https://developer.android.com/reference/androidx/media3/common/audio/DefaultGainProvider)

|---|---|
| `https://developer.android.com/reference/androidx/media3/common/audio/DefaultGainProvider` | Provides gain automation information to be applied on an audio stream. |

*** ** * ** ***

Interface that provides sample-level gain automation to be applied on an audio stream.

## Summary

| ### Public methods |
|---|---|
| `abstract float` | `https://developer.android.com/reference/androidx/media3/common/audio/GainProcessor.GainProvider#getGainFactorAtSamplePosition(long,int)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long samplePosition, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int sampleRate )` Returns a gain factor between \[0f; 1f\] to apply at the given sample position relative to `sampleRate`. |
| `abstract long` | `https://developer.android.com/reference/androidx/media3/common/audio/GainProcessor.GainProvider#isUnityUntil(long,int)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long samplePosition, @https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int sampleRate )` Returns the exclusive upper limit of the range starting at `samplePosition` where the gain value is 1f (unity), or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if `samplePosition` does not correspond to a gain of 1f. |

## Public methods

### getGainFactorAtSamplePosition

```
abstract float getGainFactorAtSamplePosition(
    @IntRange(from = 0) long samplePosition,
    @IntRange(from = 1) int sampleRate
)
```

Returns a gain factor between \[0f; 1f\] to apply at the given sample position relative to `sampleRate`.

Returned values must not change for the same pair of parameter values within the lifetime of the instance.

### isUnityUntil

```
abstract long isUnityUntil(
    @IntRange(from = 0) long samplePosition,
    @IntRange(from = 1) int sampleRate
)
```

Returns the exclusive upper limit of the range starting at `samplePosition` where the gain value is 1f (unity), or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if `samplePosition` does not correspond to a gain of 1f.

If the range continues until the end of the stream, this method returns `https://developer.android.com/reference/androidx/media3/common/C#TIME_END_OF_SOURCE()`.

Returned values must not change for the same pair of parameter values within the lifetime of the instance.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) long samplePosition` | Inclusive starting position of the unity range. |
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 1) int sampleRate` | Sample rate in Hertz related to `samplePosition`. |