Added in API level 28

DynamicsProcessing


class DynamicsProcessing : AudioEffect
kotlin.Any
   ↳ android.media.audiofx.AudioEffect
   ↳ android.media.audiofx.DynamicsProcessing

DynamicsProcessing is an audio effect for equalizing and changing dynamic range properties of the sound. It is composed of multiple stages including equalization, multi-band compression and limiter.

The number of bands and active stages is configurable, and most parameters can be controlled in realtime, such as gains, attack/release times, thresholds, etc.

The effect is instantiated and controlled by channels. Each channel has the same basic architecture, but all of their parameters are independent from other channels.

The basic channel configuration is:

Channel 0          Channel 1       ....       Channel N-1
       Input              Input                       Input
         |                  |                           |
    +----v----+        +----v----+                 +----v----+
    |inputGain|        |inputGain|                 |inputGain|
    +---------+        +---------+                 +---------+
         |                  |                           |
   +-----v-----+      +-----v-----+               +-----v-----+
   |   PreEQ   |      |   PreEQ   |               |   PreEQ   |
   +-----------+      +-----------+               +-----------+
         |                  |                           |
   +-----v-----+      +-----v-----+               +-----v-----+
   |    MBC    |      |    MBC    |               |    MBC    |
   +-----------+      +-----------+               +-----------+
         |                  |                           |
   +-----v-----+      +-----v-----+               +-----v-----+
   |  PostEQ   |      |  PostEQ   |               |  PostEQ   |
   +-----------+      +-----------+               +-----------+
         |                  |                           |
   +-----v-----+      +-----v-----+               +-----v-----+
   |  Limiter  |      |  Limiter  |               |  Limiter  |
   +-----------+      +-----------+               +-----------+
         |                  |                           |
      Output             Output                      Output
  

Where the stages are: inputGain: input gain factor in decibels (dB). 0 dB means no change in level. PreEQ: Multi-band Equalizer. MBC: Multi-band Compressor PostEQ: Multi-band Equalizer Limiter: Single band compressor/limiter.

An application creates a DynamicsProcessing object to instantiate and control this audio effect in the audio framework. A DynamicsProcessor.Config and DynamicsProcessor.Config.Builder are available to help configure the multiple stages and each band parameters if desired.

See each stage documentation for further details.

If no Config is specified during creation, a default configuration is chosen.

To attach the DynamicsProcessing to a particular AudioTrack or MediaPlayer, specify the audio session ID of this AudioTrack or MediaPlayer when constructing the effect (see AudioTrack.getAudioSessionId() and MediaPlayer.getAudioSessionId()).

To attach the DynamicsProcessing to a particular AudioTrack or MediaPlayer, specify the audio session ID of this AudioTrack or MediaPlayer when constructing the DynamicsProcessing.

See android.media.MediaPlayer#getAudioSessionId() for details on audio sessions.

See android.media.audiofx.AudioEffect class for more details on controlling audio effects.

Summary

Nested classes

Base class for bands

Base class for stages that hold bands

Class for Channel configuration parameters.

Class for Config object, used by DynamicsProcessing to configure and update the audio effect.

Class for Equalizer stage

Class for Equalizer Bands Equalizer bands have three controllable parameters: enabled/disabled, cutoffFrequency and gain

Class for Limiter Stage Limiter is a single band compressor at the end of the processing chain, commonly used to protect the signal from overloading and distortion.

Class for Multi-Band Compressor (MBC) stage

Class for Multi-Band compressor bands MBC bands have multiple controllable parameters: enabled/disabled, cutoffFrequency, attackTime, releaseTime, ratio, threshold, kneeWidth, noiseGateThreshold, expanderRatio, preGain and postGain.

base class for the different stages.

Constants
static Int

Index of variant that favors frequency resolution.

static Int

Index of variant that favors time resolution resolution.

Inherited constants
Public constructors
DynamicsProcessing(audioSession: Int)

Class constructor.

DynamicsProcessing(priority: Int, audioSession: Int, cfg: DynamicsProcessing.Config?)

Class constructor for the DynamicsProcessing audio effect

Public methods
DynamicsProcessing.Channel!

Int

Gets the number of channels in the effect engine

DynamicsProcessing.Config!

Returns the Config object used to setup this effect.

Float

DynamicsProcessing.Limiter!

DynamicsProcessing.MbcBand!
getMbcBandByChannelIndex(channelIndex: Int, band: Int)

DynamicsProcessing.Mbc!
getMbcByChannelIndex(channelIndex: Int)

DynamicsProcessing.EqBand!
getPostEqBandByChannelIndex(channelIndex: Int, band: Int)

DynamicsProcessing.Eq!

DynamicsProcessing.EqBand!
getPreEqBandByChannelIndex(channelIndex: Int, band: Int)

DynamicsProcessing.Eq!
getPreEqByChannelIndex(channelIndex: Int)

Unit

Unit
setChannelTo(channelIndex: Int, channel: DynamicsProcessing.Channel!)

Unit

Unit
setInputGainbyChannel(channelIndex: Int, inputGain: Float)

Unit

Unit

Unit

Unit

Unit
setMbcBandByChannelIndex(channelIndex: Int, band: Int, mbcBand: DynamicsProcessing.MbcBand!)

Unit

Unit

Unit

Unit
setPostEqBandByChannelIndex(channelIndex: Int, band: Int, postEqBand: DynamicsProcessing.EqBand!)

Unit

Unit

Unit

Unit
setPreEqBandByChannelIndex(channelIndex: Int, band: Int, preEqBand: DynamicsProcessing.EqBand!)

Unit

Inherited functions
Inherited properties

Constants

VARIANT_FAVOR_FREQUENCY_RESOLUTION

Added in API level 28
static val VARIANT_FAVOR_FREQUENCY_RESOLUTION: Int

Index of variant that favors frequency resolution. Frequency domain based implementation.

Value: 0

VARIANT_FAVOR_TIME_RESOLUTION

Added in API level 28
static val VARIANT_FAVOR_TIME_RESOLUTION: Int

Index of variant that favors time resolution resolution. Time domain based implementation.

Value: 1

Public constructors

DynamicsProcessing

Added in API level 28
DynamicsProcessing(audioSession: Int)

Class constructor.

Parameters
audioSession Int: system-wide unique audio session identifier. The DynamicsProcessing will be attached to the MediaPlayer or AudioTrack in the same audio session.

DynamicsProcessing

Added in API level 28
DynamicsProcessing(
    priority: Int,
    audioSession: Int,
    cfg: DynamicsProcessing.Config?)

Class constructor for the DynamicsProcessing audio effect

Parameters
priority Int: the priority level requested by the application for controlling the DynamicsProcessing engine. As the same engine can be shared by several applications, this parameter indicates how much the requesting application needs control of effect parameters. The normal priority is 0, above normal is a positive number, below normal a negative number.
audioSession Int: system-wide unique audio session identifier. The DynamicsProcessing will be attached to the MediaPlayer or AudioTrack in the same audio session.
cfg DynamicsProcessing.Config?: Config object used to setup the audio effect, including bands per stage, and specific parameters for each stage/band. Use android.media.audiofx.DynamicsProcessing.Config.Builder to create a Config object that suits your needs. A null cfg parameter will create and use a default configuration for the effect

Public methods

getChannelByChannelIndex

Added in API level 28
fun getChannelByChannelIndex(channelIndex: Int): DynamicsProcessing.Channel!

getChannelCount

Added in API level 28
fun getChannelCount(): Int

Gets the number of channels in the effect engine

Return
Int number of channels currently in use by the effect engine

getConfig

Added in API level 28
fun getConfig(): DynamicsProcessing.Config!

Returns the Config object used to setup this effect.

Return
DynamicsProcessing.Config! Config Current Config object used to setup this DynamicsProcessing effect.

getInputGainByChannelIndex

Added in API level 28
fun getInputGainByChannelIndex(channelIndex: Int): Float

getLimiterByChannelIndex

Added in API level 28
fun getLimiterByChannelIndex(channelIndex: Int): DynamicsProcessing.Limiter!

getMbcBandByChannelIndex

Added in API level 28
fun getMbcBandByChannelIndex(
    channelIndex: Int,
    band: Int
): DynamicsProcessing.MbcBand!

getMbcByChannelIndex

Added in API level 28
fun getMbcByChannelIndex(channelIndex: Int): DynamicsProcessing.Mbc!

getPostEqBandByChannelIndex

Added in API level 28
fun getPostEqBandByChannelIndex(
    channelIndex: Int,
    band: Int
): DynamicsProcessing.EqBand!

getPostEqByChannelIndex

Added in API level 28
fun getPostEqByChannelIndex(channelIndex: Int): DynamicsProcessing.Eq!

getPreEqBandByChannelIndex

Added in API level 28
fun getPreEqBandByChannelIndex(
    channelIndex: Int,
    band: Int
): DynamicsProcessing.EqBand!

getPreEqByChannelIndex

Added in API level 28
fun getPreEqByChannelIndex(channelIndex: Int): DynamicsProcessing.Eq!

setAllChannelsTo

Added in API level 28
fun setAllChannelsTo(channel: DynamicsProcessing.Channel!): Unit

setChannelTo

Added in API level 28
fun setChannelTo(
    channelIndex: Int,
    channel: DynamicsProcessing.Channel!
): Unit

setInputGainAllChannelsTo

Added in API level 28
fun setInputGainAllChannelsTo(inputGain: Float): Unit

setInputGainbyChannel

Added in API level 28
fun setInputGainbyChannel(
    channelIndex: Int,
    inputGain: Float
): Unit

setLimiterAllChannelsTo

Added in API level 28
fun setLimiterAllChannelsTo(limiter: DynamicsProcessing.Limiter!): Unit

setLimiterByChannelIndex

Added in API level 28
fun setLimiterByChannelIndex(
    channelIndex: Int,
    limiter: DynamicsProcessing.Limiter!
): Unit

setMbcAllChannelsTo

Added in API level 28
fun setMbcAllChannelsTo(mbc: DynamicsProcessing.Mbc!): Unit

setMbcBandAllChannelsTo

Added in API level 28
fun setMbcBandAllChannelsTo(
    band: Int,
    mbcBand: DynamicsProcessing.MbcBand!
): Unit

setMbcBandByChannelIndex

Added in API level 28
fun setMbcBandByChannelIndex(
    channelIndex: Int,
    band: Int,
    mbcBand: DynamicsProcessing.MbcBand!
): Unit

setMbcByChannelIndex

Added in API level 28
fun setMbcByChannelIndex(
    channelIndex: Int,
    mbc: DynamicsProcessing.Mbc!
): Unit

setPostEqAllChannelsTo

Added in API level 28
fun setPostEqAllChannelsTo(postEq: DynamicsProcessing.Eq!): Unit

setPostEqBandAllChannelsTo

Added in API level 28
fun setPostEqBandAllChannelsTo(
    band: Int,
    postEqBand: DynamicsProcessing.EqBand!
): Unit

setPostEqBandByChannelIndex

Added in API level 28
fun setPostEqBandByChannelIndex(
    channelIndex: Int,
    band: Int,
    postEqBand: DynamicsProcessing.EqBand!
): Unit

setPostEqByChannelIndex

Added in API level 28
fun setPostEqByChannelIndex(
    channelIndex: Int,
    postEq: DynamicsProcessing.Eq!
): Unit

setPreEqAllChannelsTo

Added in API level 28
fun setPreEqAllChannelsTo(preEq: DynamicsProcessing.Eq!): Unit

setPreEqBandAllChannelsTo

Added in API level 28
fun setPreEqBandAllChannelsTo(
    band: Int,
    preEqBand: DynamicsProcessing.EqBand!
): Unit

setPreEqBandByChannelIndex

Added in API level 28
fun setPreEqBandByChannelIndex(
    channelIndex: Int,
    band: Int,
    preEqBand: DynamicsProcessing.EqBand!
): Unit

setPreEqByChannelIndex

Added in API level 28
fun setPreEqByChannelIndex(
    channelIndex: Int,
    preEq: DynamicsProcessing.Eq!
): Unit