AudioParams() { SAMPLE_RATE = AudioTrack.getNativeOutputSampleRate(STREAM_TYPE); BUF_BYTES = Math.max( AudioTrack.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT), (SAMPLE_RATE * LATENCY_MS / 1000) * BYTES_PER_SAMPLE); BUF_SAMPLES = BUF_BYTES / BYTES_PER_SAMPLE; }
public static TestSettings computeDefaultSettings() { int samplingRate = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC); int minPlayerBufferSizeInBytes = AudioTrack.getMinBufferSize(samplingRate, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT); int minRecorderBufferSizeInBytes = AudioRecord.getMinBufferSize(samplingRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); return new TestSettings(samplingRate, minPlayerBufferSizeInBytes, minRecorderBufferSizeInBytes); }
public static TestSettings computeDefaultSettings(Context context, int threadType, int performanceMode) { TestSettings nativeResult = nativeComputeDefaultSettings( Constant.BYTES_PER_FRAME, threadType, performanceMode); if (nativeResult != null) { return nativeResult; } int samplingRate = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC); int minBufferSizeInFrames = 1024; if (isSafeToUseGetProperty()) { AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); String value = am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); minBufferSizeInFrames = Integer.parseInt(value); } int minBufferSizeInBytes = Constant.BYTES_PER_FRAME * minBufferSizeInFrames; return new TestSettings(samplingRate, minBufferSizeInBytes, minBufferSizeInBytes); }
private boolean areParametersValid(int sampleRate, int channels) { final int streamType = audioTrack.getStreamType(); return (audioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT && audioTrack.getChannelConfiguration() == AudioFormat.CHANNEL_OUT_MONO && streamType == AudioManager.STREAM_VOICE_CALL && audioTrack.getSampleRate() == sampleRate && sampleRate == audioTrack.getNativeOutputSampleRate(streamType) && audioTrack.getChannelCount() == channels); }
AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC); int minSize = AudioTrack.getMinBufferSize(rate, AudioFormat.CHANNEL_OUT_MONO,
AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
nosr = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);