Example usage for android.media AudioFormat ENCODING_DEFAULT

List of usage examples for android.media AudioFormat ENCODING_DEFAULT

Introduction

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

Prototype

int ENCODING_DEFAULT

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

Click Source Link

Document

Default audio data format

Usage

From source file:Main.java

public static AudioTrack createTrack(int samplingRate) {
    AudioTrack track = new AudioTrack(AudioManager.STREAM_MUSIC, samplingRate, AudioFormat.CHANNEL_OUT_STEREO,
            AudioFormat.ENCODING_DEFAULT, samplingRate, AudioTrack.MODE_STREAM);
    return track;
}

From source file:Main.java

/**
 * Convert integers to AudioFormat.ENCODING_PCM constants
 * /*from w w w . ja v a2 s.  c o  m*/
 * @param bitsPerSample
 *            bits in a sample of audio, typically 8 or 16
 */
public static int getAndroidPcmEncoding(int bitsPerSample) {
    switch (bitsPerSample) {
    case 8:
        return AudioFormat.ENCODING_PCM_8BIT;
    case 16:
        return AudioFormat.ENCODING_PCM_16BIT;
    default:
        return AudioFormat.ENCODING_DEFAULT;
    }
}