Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
    
    
  
  
    
    
    
    LoudnessEnhancer
    open class LoudnessEnhancer : AudioEffect
    
    LoudnessEnhancer is an audio effect for increasing audio loudness. The processing is parametrized by a target gain value, which determines the maximum amount by which an audio signal will be amplified; signals amplified outside of the sample range supported by the platform are compressed. An application creates a LoudnessEnhancer object to instantiate and control a this audio effect in the audio framework. To attach the LoudnessEnhancer 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()).
    Summary
    
      
        
          | Constants | 
        
          | static Int | The maximum gain applied to the signal to process. | 
      
    
    
      
        
          | Inherited constants | 
        
          | From class AudioEffect
                
                  
                    | String | ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION
                         Intent to signal to the effect control application or service that an audio session is closed and that effects should not be applied anymore.  The effect control application receiving this intent will delete all effects on this session and store current settings in package specific storage.  The calling package name is indicated by the EXTRA_PACKAGE_NAMEextra and the audio session ID by theEXTRA_AUDIO_SESSIONextra. Both extras are mandatory. It is good practice for applications to broadcast this intent when music playback stops and/or when exiting to free system resources consumed by audio effect engines. |  
                    | String | ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL
                         Intent to launch an audio effect control panel UI.  The goal of this intent is to enable separate implementations of music/media player applications and audio effect control application or services. This will allow platform vendors to offer more advanced control options for standard effects or control for platform specific effects.  The intent carries a number of extras used by the player application to communicate necessary pieces of information to the control panel application.  The calling application must use the android.app.Activity#startActivityForResult(Intent, int) method to launch the control panel so that its package name is indicated and used by the control panel application to keep track of changes for this particular application.  The EXTRA_AUDIO_SESSIONextra will indicate an audio session to which the audio effects should be applied. If no audio session is specified, either one of the follownig will happen: - If an audio session was previously opened by the calling application with ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSIONintent, the effect changes will be applied to that session. - If no audio session is opened, the changes will be stored in the package specific storage area and applied whenever a new audio session is opened by this application.  The EXTRA_CONTENT_TYPEextra will help the control panel application customize both the UI layout and the default audio effect settings if none are already stored for the calling application. |  
                    | String | ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION
                         Intent to signal to the effect control application or service that a new audio session is opened and requires audio effects to be applied.  This is different from ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANELin that no UI should be displayed in this case. Music player applications can broadcast this intent before starting playback to make sure that any audio effect settings previously selected by the user are applied. The effect control application receiving this intent will look for previously stored settings for the calling application, create all required audio effects and apply the effect settings to the specified audio session.  The calling package name is indicated by the EXTRA_PACKAGE_NAMEextra and the audio session ID by theEXTRA_AUDIO_SESSIONextra. Both extras are mandatory. If no stored settings are found for the calling application, default settings for the content type indicated by EXTRA_CONTENT_TYPEwill be applied. The default settings for a given content type are platform specific. |  
                    | Int | ALREADY_EXISTS
                         Internal operation status. Not returned by any method. |  
                    | Int | CONTENT_TYPE_GAME
                         Value for EXTRA_CONTENT_TYPEwhen the type of content played is game audio |  
                    | Int | CONTENT_TYPE_MOVIE
                         Value for EXTRA_CONTENT_TYPEwhen the type of content played is video or movie |  
                    | Int | CONTENT_TYPE_MUSIC
                         Value for EXTRA_CONTENT_TYPEwhen the type of content played is music |  
                    | Int | CONTENT_TYPE_VOICE
                         Value for EXTRA_CONTENT_TYPEwhen the type of content played is voice audio |  
                    | String | EFFECT_AUXILIARY
                         Effect connection mode is auxiliary.  Auxiliary effects must be created on session 0 (global output mix). In order for a MediaPlayer or AudioTrack to be fed into this effect, they must be explicitely attached to this effect and a send level must be specified.  Use the effect ID returned by getId()to designate this particular effect when attaching it to the MediaPlayer or AudioTrack. |  
                    | String | EFFECT_INSERT
                         Effect connection mode is insert. Specifying an audio session ID when creating the effect will insert this effect after all players in the same audio session. |  
                    | String | EFFECT_POST_PROCESSING
                         Effect connection mode is post processing. The audio post processing effects are attached to an audio output stream or device |  
                    | String | EFFECT_PRE_PROCESSING
                         Effect connection mode is pre processing. The audio pre processing effects are attached to an audio input stream or device |  
                    | Int | ERROR
                         Unspecified error. |  
                    | Int | ERROR_BAD_VALUE
                         Operation failed due to bad parameter value. |  
                    | Int | ERROR_DEAD_OBJECT
                         Operation failed due to dead remote object. |  
                    | Int | ERROR_INVALID_OPERATION
                         Operation failed because it was requested in wrong state. |  
                    | Int | ERROR_NO_INIT
                         Operation failed due to bad object initialization. |  
                    | Int | ERROR_NO_MEMORY
                         Operation failed due to lack of memory. |  
                    | String | EXTRA_AUDIO_SESSION
                         Contains the ID of the audio session the effects should be applied to.  This extra is for use with ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL,ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSIONandACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSIONintents. The extra value is of type int and is the audio session ID. |  
                    | String | EXTRA_CONTENT_TYPE
                         Indicates which type of content is played by the application.  This extra is for use with ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANELandACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSIONintents. This information is used by the effect control application to customize UI and select appropriate default effect settings. The content type is one of the following: If omitted, the content type defaults to CONTENT_TYPE_MUSIC. |  
                    | String | EXTRA_PACKAGE_NAME
                         Contains the package name of the calling application.  This extra is for use with ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSIONandACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSIONintents. The extra value is a string containing the full package name. |  
                    | Int | SUCCESS
                         Successful operation. |  | 
      
    
    
      
        
          | Public constructors | 
        
          | Class constructor. | 
      
    
    
      
        
          | Public methods | 
        
          | open Float | Return the target gain. | 
        
          | open Unit | Set the target gain for the audio effect. | 
      
    
    
    
    Constants
    
      PARAM_TARGET_GAIN_MB
      
      static val PARAM_TARGET_GAIN_MB: Int
      The maximum gain applied to the signal to process. It is expressed in millibels (100mB = 1dB) where 0mB corresponds to no amplification.
      Value: 0
     
    Public constructors
    
      LoudnessEnhancer
      
      LoudnessEnhancer(audioSession: Int)
      Class constructor.
      
        
          
            | Parameters | 
          
            | audioSession | Int: system-wide unique audio session identifier. The LoudnessEnhancer will be attached to the MediaPlayer or AudioTrack in the same audio session. | 
        
      
      
        
          
            | Exceptions | 
          
            | java.lang.IllegalStateException |  | 
          
            | java.lang.IllegalArgumentException |  | 
          
            | java.lang.UnsupportedOperationException |  | 
          
            | java.lang.RuntimeException |  | 
        
      
     
    Public methods
    
      getTargetGain
      
      open fun getTargetGain(): Float
      Return the target gain.
      
        
          
            | Return | 
          
            | Float | the effect target gain expressed in mB. | 
        
      
      
        
          
            | Exceptions | 
          
            | java.lang.IllegalStateException |  | 
          
            | java.lang.IllegalArgumentException |  | 
          
            | java.lang.UnsupportedOperationException |  | 
        
      
     
    
      setTargetGain
      
      open fun setTargetGain(gainmB: Int): Unit
      Set the target gain for the audio effect. The target gain is the maximum value by which a sample value will be amplified when the effect is enabled.
      
        
          
            | Parameters | 
          
            | gainmB | Int: the effect target gain expressed in mB. 0mB corresponds to no amplification. | 
        
      
      
        
          
            | Exceptions | 
          
            | java.lang.IllegalStateException |  | 
          
            | java.lang.IllegalArgumentException |  | 
          
            | java.lang.UnsupportedOperationException |  | 
        
      
     
  
  
  
    
  
 
  
    
      
      
    
    
      
    
    
  
       
    
    
      
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2025-08-20 UTC.
  
  
  
    
      [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[],[]]