Java Code Examples for android.media.audiofx.NoiseSuppressor#isAvailable()

The following examples show how to use android.media.audiofx.NoiseSuppressor#isAvailable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AACEncoder.java    From AndroidInstantVideo with Apache License 2.0 6 votes vote down vote up
public AACEncoder(final StreamPublisher.StreamPublisherParam params) throws IOException {
    this.samplingRate = params.samplingRate;

    bufferSize = params.audioBufferSize;
    mMediaCodec = MediaCodec.createEncoderByType(params.audioMIME);
    mMediaCodec.configure(params.createAudioMediaFormat(), null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
    mediaCodecInputStream = new MediaCodecInputStream(mMediaCodec, new MediaCodecInputStream.MediaFormatCallback() {
        @Override
        public void onChangeMediaFormat(MediaFormat mediaFormat) {
            params.setAudioOutputMediaFormat(mediaFormat);
        }
    });
    mAudioRecord = new AudioRecord(params.audioSource, samplingRate, params.channelCfg, AudioFormat.ENCODING_PCM_16BIT, bufferSize);
    if (NoiseSuppressor.isAvailable()) {
        NoiseSuppressor noiseSuppressor = NoiseSuppressor.create(mAudioRecord.getAudioSessionId());
    }

}
 
Example 2
Source File: VoIPController.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void setConfig(double recvTimeout, double initTimeout, int dataSavingOption, long callID){
	ensureNativeInstance();
	boolean sysAecAvailable=false, sysNsAvailable=false;
	if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){
		try{
			sysAecAvailable=AcousticEchoCanceler.isAvailable();
			sysNsAvailable=NoiseSuppressor.isAvailable();
		}catch(Throwable x){

		}
	}
	SharedPreferences preferences=MessagesController.getGlobalMainSettings();
	boolean dump=preferences.getBoolean("dbg_dump_call_stats", false);
	nativeSetConfig(nativeInst, recvTimeout, initTimeout, dataSavingOption,
			!(sysAecAvailable && VoIPServerConfig.getBoolean("use_system_aec", true)),
			!(sysNsAvailable && VoIPServerConfig.getBoolean("use_system_ns", true)),
			true, BuildVars.DEBUG_VERSION ? getLogFilePath("voip"+callID) : getLogFilePath(callID), BuildVars.DEBUG_VERSION && dump ? getLogFilePath("voipStats") : null,
			BuildVars.DEBUG_VERSION);
}
 
Example 3
Source File: VoIPController.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setConfig(double recvTimeout, double initTimeout, int dataSavingOption, long callID){
	ensureNativeInstance();
	boolean sysAecAvailable=false, sysNsAvailable=false;
	if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){
		try{
			sysAecAvailable=AcousticEchoCanceler.isAvailable();
			sysNsAvailable=NoiseSuppressor.isAvailable();
		}catch(Throwable x){

		}
	}
	SharedPreferences preferences=MessagesController.getGlobalMainSettings();
	boolean dump=preferences.getBoolean("dbg_dump_call_stats", false);
	nativeSetConfig(nativeInst, recvTimeout, initTimeout, dataSavingOption,
			!(sysAecAvailable && VoIPServerConfig.getBoolean("use_system_aec", true)),
			!(sysNsAvailable && VoIPServerConfig.getBoolean("use_system_ns", true)),
			true, BuildVars.DEBUG_VERSION ? getLogFilePath("voip"+callID) : getLogFilePath(callID), BuildVars.DEBUG_VERSION && dump ? getLogFilePath("voipStats") : null,
			BuildVars.DEBUG_VERSION);
}
 
Example 4
Source File: RecordAudioinBytes.java    From Alexa-Voice-Service with MIT License 5 votes vote down vote up
private void checkthingsforrecoder() {
    int audioSessionId = getAudioSessionId();

    if(NoiseSuppressor.isAvailable())
    {
      //  NoiseSuppressor.create(audioSessionId);
    }
    if(AutomaticGainControl.isAvailable())
    {
       // AutomaticGainControl.create(audioSessionId);
    }
    if(AcousticEchoCanceler.isAvailable()){
       // AcousticEchoCanceler.create(audioSessionId);
    }
}
 
Example 5
Source File: AudioPostProcessEffect.java    From rtmp-rtsp-stream-client-java with Apache License 2.0 5 votes vote down vote up
public void enableNoiseSuppressor() {
  if (NoiseSuppressor.isAvailable() && noiseSuppressor == null) {
    noiseSuppressor = NoiseSuppressor.create(microphoneId);
    noiseSuppressor.setEnabled(true);
    Log.i(TAG, "NoiseSuppressor enabled");
  } else {
    Log.e(TAG, "This device don't support NoiseSuppressor");
  }
}
 
Example 6
Source File: SpeechRecord.java    From AlexaAndroid with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isNoiseSuppressorAvailable() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        return NoiseSuppressor.isAvailable();
    }
    return false;
}
 
Example 7
Source File: SpeechRecord.java    From AlexaAndroid with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isNoiseSuppressorAvailable() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        return NoiseSuppressor.isAvailable();
    }
    return false;
}
 
Example 8
Source File: SpeechRecord.java    From speechutils with Apache License 2.0 4 votes vote down vote up
public static boolean isNoiseSuppressorAvailable() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        return NoiseSuppressor.isAvailable();
    }
    return false;
}