# GainProcessor.GainProvider

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/common/audio/GainProcessor.GainProvider "View this page in Java")

<br />

```
interface GainProcessor.GainProvider
```

<br />

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

|------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| [DefaultGainProvider](https://developer.android.com/reference/kotlin/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 functions                               |
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [getGainFactorAtSamplePosition](https://developer.android.com/reference/kotlin/androidx/media3/common/audio/GainProcessor.GainProvider#getGainFactorAtSamplePosition(long,int))`(` ` samplePosition: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` sampleRate: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Returns a gain factor between \[0f; 1f\] to apply at the given sample position relative to`sampleRate`.                                                                                                                                |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)   | [isUnityUntil](https://developer.android.com/reference/kotlin/androidx/media3/common/audio/GainProcessor.GainProvider#isUnityUntil(long,int))`(` ` samplePosition: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` sampleRate: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Returns the exclusive upper limit of the range starting at`samplePosition`where the gain value is 1f (unity), or[TIME_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET())if`samplePosition`does not correspond to a gain of 1f. |

## Public functions

### getGainFactorAtSamplePosition

```
fun getGainFactorAtSamplePosition(
    samplePosition: @IntRange(from = 0) Long,
    sampleRate: @IntRange(from = 1) Int
): Float
```

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

```
fun isUnityUntil(
    samplePosition: @IntRange(from = 0) Long,
    sampleRate: @IntRange(from = 1) Int
): Long
```

Returns the exclusive upper limit of the range starting at`samplePosition`where the gain value is 1f (unity), or[TIME_UNSET](https://developer.android.com/reference/kotlin/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[TIME_END_OF_SOURCE](https://developer.android.com/reference/kotlin/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                                                                                              |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------|
| `samplePosition: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 0) `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | Inclusive starting position of the unity range.  |
| `sampleRate: @`[IntRange](https://developer.android.com/reference/kotlin/androidx/annotation/IntRange)`(from = 1) `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)       | Sample rate in Hertz related to`samplePosition`. |