Example usage for android.media AudioFormat CHANNEL_IN_DEFAULT

List of usage examples for android.media AudioFormat CHANNEL_IN_DEFAULT

Introduction

In this page you can find the example usage for android.media AudioFormat CHANNEL_IN_DEFAULT.

Prototype

int CHANNEL_IN_DEFAULT

To view the source code for android.media AudioFormat CHANNEL_IN_DEFAULT.

Click Source Link

Usage

From source file:Main.java

public static final int getSampleRate(boolean lowest) {
    int sampleRate = -1;
    for (int rate : POSSIBLE_SAMPLE_RATES) {
        int bufferSize = AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_IN_DEFAULT,
                AudioFormat.ENCODING_PCM_16BIT);
        if (bufferSize > 0) {
            // buffer size is valid, Sample rate supported
            sampleRate = rate;/*from   w ww  . j  a  va2  s. c o  m*/
            if (lowest) {
                return sampleRate;
            }
        }
    }
    return sampleRate;
}