FileDocCategorySizeDatePackage
NoiseSuppressor.javaAPI DocAndroid 5.1 API4311Thu Mar 12 22:22:30 GMT 2015android.media.audiofx

NoiseSuppressor

public class NoiseSuppressor extends AudioEffect
Noise Suppressor (NS).

Noise suppression (NS) is an audio pre-processing which removes background noise from the captured signal. The component of the signal considered as noise can be either stationary (car/airplane engine, AC system) or non-stationary (other peoples conversations, car horn) for more advanced implementations.

NS is mostly used by voice communication applications (voice chat, video conferencing, SIP calls).

An application creates a NoiseSuppressor object to instantiate and control an NS engine in the audio framework.

To attach the NoiseSuppressor to a particular {@link android.media.AudioRecord}, specify the audio session ID of this AudioRecord when creating the NoiseSuppressor. The audio session is retrieved by calling {@link android.media.AudioRecord#getAudioSessionId()} on the AudioRecord instance.

On some devices, NS can be inserted by default in the capture path by the platform according to the {@link android.media.MediaRecorder.AudioSource} used. The application should call NoiseSuppressor.getEnable() after creating the NS to check the default NS activation state on a particular AudioRecord session.

See {@link android.media.audiofx.AudioEffect} class for more details on controlling audio effects.

Fields Summary
private static final String
TAG
Constructors Summary
private NoiseSuppressor(int audioSession)
Class constructor.

The constructor is not guarantied to succeed and throws the following exceptions:

  • IllegalArgumentException is thrown if the device does not implement an NS
  • UnsupportedOperationException is thrown is the resources allocated to audio pre-procesing are currently exceeded.
  • RuntimeException is thrown if a memory allocation error occurs.

param
audioSession system wide unique audio session identifier. The NoiseSuppressor will be applied to the AudioRecord with the same audio session.
throws
java.lang.IllegalArgumentException
throws
java.lang.UnsupportedOperationException
throws
java.lang.RuntimeException

        super(EFFECT_TYPE_NS, EFFECT_TYPE_NULL, 0, audioSession);
    
Methods Summary
public static android.media.audiofx.NoiseSuppressorcreate(int audioSession)
Creates a NoiseSuppressor and attaches it to the AudioRecord on the audio session specified.

param
audioSession system wide unique audio session identifier. The NoiseSuppressor will be applied to the AudioRecord with the same audio session.
return
NoiseSuppressor created or null if the device does not implement noise suppression.

        NoiseSuppressor ns = null;
        try {
            ns = new NoiseSuppressor(audioSession);
        } catch (IllegalArgumentException e) {
            Log.w(TAG, "not implemented on this device "+ns);
        } catch (UnsupportedOperationException e) {
            Log.w(TAG, "not enough resources");
        } catch (RuntimeException e) {
            Log.w(TAG, "not enough memory");
        } finally {
            return ns;
        }
    
public static booleanisAvailable()
Checks if the device implements noise suppression.

return
true if the device implements noise suppression, false otherwise.


                          
        
        return AudioEffect.isEffectTypeAvailable(AudioEffect.EFFECT_TYPE_NS);