android.media.audiofx.NoiseSuppressor Java Examples
The following examples show how to use
android.media.audiofx.NoiseSuppressor.
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: PlayService.java From music_player with Open Software License 3.0 | 7 votes |
private void initialAudioEffect(final int audioSessionId) { new Thread(new Runnable() { @Override public void run() { try { loudnessEnhancer = new LoudnessEnhancer(audioSessionId); mBass = new BassBoost(0, audioSessionId); mVirtualizer = new Virtualizer(0, audioSessionId); mEqualizer = new Equalizer(0, audioSessionId); canceler = AcousticEchoCanceler.create(audioSessionId); control = AutomaticGainControl.create(audioSessionId); suppressor = NoiseSuppressor.create(audioSessionId); getPreference(); } catch (Exception e) { e.printStackTrace(); } } }).start(); }
Example #2
Source File: AACEncoder.java From AndroidInstantVideo with Apache License 2.0 | 6 votes |
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 #3
Source File: VoIPController.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
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: AudioRecordJNI.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private static boolean isGoodAudioEffect(AudioEffect effect){ Pattern globalImpl=makeNonEmptyRegex("adsp_good_impls"), globalName=makeNonEmptyRegex("adsp_good_names"); AudioEffect.Descriptor desc=effect.getDescriptor(); VLog.d(effect.getClass().getSimpleName()+": implementor="+desc.implementor+", name="+desc.name); if(globalImpl!=null && globalImpl.matcher(desc.implementor).find()){ return true; } if(globalName!=null && globalName.matcher(desc.name).find()){ return true; } if(effect instanceof AcousticEchoCanceler){ Pattern impl=makeNonEmptyRegex("aaec_good_impls"), name=makeNonEmptyRegex("aaec_good_names"); if(impl!=null && impl.matcher(desc.implementor).find()) return true; if(name!=null && name.matcher(desc.name).find()) return true; } if(effect instanceof NoiseSuppressor){ Pattern impl=makeNonEmptyRegex("ans_good_impls"), name=makeNonEmptyRegex("ans_good_names"); if(impl!=null && impl.matcher(desc.implementor).find()) return true; if(name!=null && name.matcher(desc.name).find()) return true; } return false; }
Example #5
Source File: VoIPController.java From Telegram with GNU General Public License v2.0 | 6 votes |
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 #6
Source File: AudioRecordJNI.java From Telegram with GNU General Public License v2.0 | 6 votes |
private static boolean isGoodAudioEffect(AudioEffect effect){ Pattern globalImpl=makeNonEmptyRegex("adsp_good_impls"), globalName=makeNonEmptyRegex("adsp_good_names"); AudioEffect.Descriptor desc=effect.getDescriptor(); VLog.d(effect.getClass().getSimpleName()+": implementor="+desc.implementor+", name="+desc.name); if(globalImpl!=null && globalImpl.matcher(desc.implementor).find()){ return true; } if(globalName!=null && globalName.matcher(desc.name).find()){ return true; } if(effect instanceof AcousticEchoCanceler){ Pattern impl=makeNonEmptyRegex("aaec_good_impls"), name=makeNonEmptyRegex("aaec_good_names"); if(impl!=null && impl.matcher(desc.implementor).find()) return true; if(name!=null && name.matcher(desc.name).find()) return true; } if(effect instanceof NoiseSuppressor){ Pattern impl=makeNonEmptyRegex("ans_good_impls"), name=makeNonEmptyRegex("ans_good_names"); if(impl!=null && impl.matcher(desc.implementor).find()) return true; if(name!=null && name.matcher(desc.name).find()) return true; } return false; }
Example #7
Source File: RecordAudioinBytes.java From Alexa-Voice-Service with MIT License | 5 votes |
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 #8
Source File: AudioPostProcessEffect.java From rtmp-rtsp-stream-client-java with Apache License 2.0 | 5 votes |
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 #9
Source File: SaiyAudio.java From Saiy-PS with GNU Affero General Public License v3.0 | 5 votes |
/** * Attempt to set enhancers available on modern devices. * <p/> * These are hardware dependent, not build version. Although the APIs weren't available to * devices until API Level 16 */ @SuppressWarnings("NewApi") private void setEnhancers(final int sessionId) { if (!DEBUG) { NoiseSuppressor.create(sessionId); AcousticEchoCanceler.create(sessionId); AutomaticGainControl.create(sessionId); } else { if (NoiseSuppressor.create(sessionId) == null) { MyLog.i(CLS_NAME, "NoiseSuppressor null"); } else { MyLog.i(CLS_NAME, "NoiseSuppressor success"); } if (AcousticEchoCanceler.create(sessionId) == null) { MyLog.i(CLS_NAME, "AcousticEchoCanceler null"); } else { MyLog.i(CLS_NAME, "AcousticEchoCanceler success"); } if (AutomaticGainControl.create(sessionId) == null) { MyLog.i(CLS_NAME, "AutomaticGainControl null"); } else { MyLog.i(CLS_NAME, "AutomaticGainControl success"); } } }
Example #10
Source File: SpeechRecord.java From AlexaAndroid with GNU General Public License v2.0 | 4 votes |
public SpeechRecord(int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes, boolean noise, boolean gain, boolean echo) throws IllegalArgumentException { super(audioSource, sampleRateInHz, channelConfig, audioFormat, bufferSizeInBytes); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Log.i("Trying to enhance audio because running on SDK " + Build.VERSION.SDK_INT); int audioSessionId = getAudioSessionId(); if (noise) { if (NoiseSuppressor.create(audioSessionId) == null) { Log.i("NoiseSuppressor: failed"); } else { Log.i("NoiseSuppressor: ON"); } } else { Log.i("NoiseSuppressor: OFF"); } if (gain) { if (AutomaticGainControl.create(audioSessionId) == null) { Log.i("AutomaticGainControl: failed"); } else { Log.i("AutomaticGainControl: ON"); } } else { Log.i("AutomaticGainControl: OFF"); } if (echo) { if (AcousticEchoCanceler.create(audioSessionId) == null) { Log.i("AcousticEchoCanceler: failed"); } else { Log.i("AcousticEchoCanceler: ON"); } } else { Log.i("AcousticEchoCanceler: OFF"); } } }
Example #11
Source File: SpeechRecord.java From AlexaAndroid with GNU General Public License v2.0 | 4 votes |
public static boolean isNoiseSuppressorAvailable() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { return NoiseSuppressor.isAvailable(); } return false; }
Example #12
Source File: SpeechRecord.java From AlexaAndroid with GNU General Public License v2.0 | 4 votes |
public SpeechRecord(int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes, boolean noise, boolean gain, boolean echo) throws IllegalArgumentException { super(audioSource, sampleRateInHz, channelConfig, audioFormat, bufferSizeInBytes); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Log.i("Trying to enhance audio because running on SDK " + Build.VERSION.SDK_INT); int audioSessionId = getAudioSessionId(); if (noise) { if (NoiseSuppressor.create(audioSessionId) == null) { Log.i("NoiseSuppressor: failed"); } else { Log.i("NoiseSuppressor: ON"); } } else { Log.i("NoiseSuppressor: OFF"); } if (gain) { if (AutomaticGainControl.create(audioSessionId) == null) { Log.i("AutomaticGainControl: failed"); } else { Log.i("AutomaticGainControl: ON"); } } else { Log.i("AutomaticGainControl: OFF"); } if (echo) { if (AcousticEchoCanceler.create(audioSessionId) == null) { Log.i("AcousticEchoCanceler: failed"); } else { Log.i("AcousticEchoCanceler: ON"); } } else { Log.i("AcousticEchoCanceler: OFF"); } } }
Example #13
Source File: SpeechRecord.java From AlexaAndroid with GNU General Public License v2.0 | 4 votes |
public static boolean isNoiseSuppressorAvailable() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { return NoiseSuppressor.isAvailable(); } return false; }
Example #14
Source File: SpeechRecord.java From speechutils with Apache License 2.0 | 4 votes |
public SpeechRecord(int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes, boolean noise, boolean gain, boolean echo) throws IllegalArgumentException { super(audioSource, sampleRateInHz, channelConfig, audioFormat, bufferSizeInBytes); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { Log.i("Trying to enhance audio because running on SDK " + Build.VERSION.SDK_INT); int audioSessionId = getAudioSessionId(); if (noise) { if (NoiseSuppressor.create(audioSessionId) == null) { Log.i("NoiseSuppressor: failed"); } else { Log.i("NoiseSuppressor: ON"); } } else { Log.i("NoiseSuppressor: OFF"); } if (gain) { if (AutomaticGainControl.create(audioSessionId) == null) { Log.i("AutomaticGainControl: failed"); } else { Log.i("AutomaticGainControl: ON"); } } else { Log.i("AutomaticGainControl: OFF"); } if (echo) { if (AcousticEchoCanceler.create(audioSessionId) == null) { Log.i("AcousticEchoCanceler: failed"); } else { Log.i("AcousticEchoCanceler: ON"); } } else { Log.i("AcousticEchoCanceler: OFF"); } } }
Example #15
Source File: SpeechRecord.java From speechutils with Apache License 2.0 | 4 votes |
public static boolean isNoiseSuppressorAvailable() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { return NoiseSuppressor.isAvailable(); } return false; }