Java 类android.media.audiofx.NoiseSuppressor 实例源码

项目:Alexa-Voice-Service    文件:RecordAudioinBytes.java   
private void checkthingsforrecoder() {
    int audioSessionId = getAudioSessionId();

    if(NoiseSuppressor.isAvailable())
    {
      //  NoiseSuppressor.create(audioSessionId);
    }
    if(AutomaticGainControl.isAvailable())
    {
       // AutomaticGainControl.create(audioSessionId);
    }
    if(AcousticEchoCanceler.isAvailable()){
       // AcousticEchoCanceler.create(audioSessionId);
    }
}
项目:rtmp-rtsp-stream-client-java    文件:AudioPostProcessEffect.java   
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");
  }
}
项目:speechutils    文件:SpeechRecord.java   
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");
        }
    }
}
项目:AI-Powered-Intelligent-Banking-Platform    文件:SpeechRecord.java   
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");
        }
    }
}
项目:AI-Powered-Intelligent-Banking-Platform    文件:SpeechRecord.java   
public static boolean isNoiseSuppressorAvailable() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        return NoiseSuppressor.isAvailable();
    }
    return false;
}
项目:AI-Powered-Intelligent-Banking-Platform    文件:SpeechRecord.java   
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");
        }
    }
}
项目:AI-Powered-Intelligent-Banking-Platform    文件:SpeechRecord.java   
public static boolean isNoiseSuppressorAvailable() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        return NoiseSuppressor.isAvailable();
    }
    return false;
}
项目:Saiy-PS    文件:SaiyAudio.java   
/**
 * 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");
        }
    }
}
项目:AlexaAndroid    文件:SpeechRecord.java   
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");
        }
    }
}
项目:AlexaAndroid    文件:SpeechRecord.java   
public static boolean isNoiseSuppressorAvailable() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        return NoiseSuppressor.isAvailable();
    }
    return false;
}
项目:AlexaAndroid    文件:SpeechRecord.java   
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");
        }
    }
}
项目:AlexaAndroid    文件:SpeechRecord.java   
public static boolean isNoiseSuppressorAvailable() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        return NoiseSuppressor.isAvailable();
    }
    return false;
}
项目:speechutils    文件:SpeechRecord.java   
public static boolean isNoiseSuppressorAvailable() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        return NoiseSuppressor.isAvailable();
    }
    return false;
}
项目:opentok-android-sdk-samples    文件:CustomAudioDevice.java   
@Override
public boolean initCapturer() {
    // initalize audio mode
    audioManagerMode.acquireMode(audioManager);

    // get the minimum buffer size that can be used
    int minRecBufSize = AudioRecord.getMinBufferSize(
            captureSettings.getSampleRate(),
            NUM_CHANNELS_CAPTURING == 1 ? AudioFormat.CHANNEL_IN_MONO : AudioFormat.CHANNEL_IN_STEREO,
            AudioFormat.ENCODING_PCM_16BIT
    );

    // double size to be more safe
    int recBufSize = minRecBufSize * 2;

    // release the object
    if (noiseSuppressor != null) {
        noiseSuppressor.release();
        noiseSuppressor = null;
    }
    if (echoCanceler != null) {
        echoCanceler.release();
        echoCanceler = null;
    }
    if (audioRecord != null) {
        audioRecord.release();
        audioRecord = null;
    }

    try {
        audioRecord = new AudioRecord(AudioSource.VOICE_COMMUNICATION,
                captureSettings.getSampleRate(),
                NUM_CHANNELS_CAPTURING == 1 ? AudioFormat.CHANNEL_IN_MONO
                        : AudioFormat.CHANNEL_IN_STEREO,
                AudioFormat.ENCODING_PCM_16BIT, recBufSize);
        if (NoiseSuppressor.isAvailable()) {
            noiseSuppressor = NoiseSuppressor.create(audioRecord.getAudioSessionId());
        }
        if (AcousticEchoCanceler.isAvailable()) {
            echoCanceler = AcousticEchoCanceler.create(audioRecord.getAudioSessionId());
        }

    } catch (Exception e) {
        throw new RuntimeException(e.getMessage());
    }

    // check that the audioRecord is ready to be used
    if (audioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
        throw new RuntimeException("Audio capture is not initialized " + captureSettings.getSampleRate());
    }

    shutdownCaptureThread = false;
    new Thread(captureThread).start();
    return true;
}