List of usage examples for android.media AudioFormat CHANNEL_OUT_STEREO
int CHANNEL_OUT_STEREO
To view the source code for android.media AudioFormat CHANNEL_OUT_STEREO.
Click Source Link
From source file:Main.java
public static int getOutFormat(int outChannels) { switch (outChannels) { case 1://from ww w . j a va2 s .co m return AudioFormat.CHANNEL_OUT_MONO; case 2: return AudioFormat.CHANNEL_OUT_STEREO; case 4: return AudioFormat.CHANNEL_OUT_QUAD; case 6: return AudioFormat.CHANNEL_OUT_5POINT1; case 8: return AudioFormat.CHANNEL_OUT_7POINT1; default: throw new IllegalArgumentException("illegal number of output channels: " + outChannels); } }
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
public static int outChannelMaskFromInChannelMask(int channelMask) { switch (channelMask) { case AudioFormat.CHANNEL_IN_MONO: return AudioFormat.CHANNEL_OUT_MONO; case AudioFormat.CHANNEL_IN_STEREO: return AudioFormat.CHANNEL_OUT_STEREO; default:/*w w w.ja v a 2s .c o m*/ return AudioFormat.CHANNEL_INVALID; } }
From source file:de.badaix.snapcast.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); for (int rate : new int[] { 8000, 11025, 16000, 22050, 44100, 48000 }) { // add the rates you wish to check against Log.d(TAG, "Samplerate: " + rate); int bufferSize = AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT); if (bufferSize > 0) { Log.d(TAG, "Samplerate: " + rate + ", buffer: " + bufferSize); }/*from www. ja v a 2s .co m*/ } AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { String rate = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE); nativeSampleRate = Integer.valueOf(rate); // String size = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); // tvInfo.setText("Sample rate: " + rate + ", buffer size: " + size); } coordinatorLayout = (CoordinatorLayout) findViewById(R.id.myCoordinatorLayout); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.container); mViewPager.setAdapter(sectionsPagerAdapter); tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); mViewPager.setVisibility(View.GONE); setActionbarSubtitle("Host: no Snapserver found"); new Thread(new Runnable() { @Override public void run() { Log.d(TAG, "copying snapclient"); Setup.copyBinAsset(MainActivity.this, "snapclient", "snapclient"); Log.d(TAG, "done copying snapclient"); } }).start(); sectionsPagerAdapter.setHideOffline(Settings.getInstance(this).getBoolean("hide_offline", false)); }
From source file:com.xperia64.timidityae.Globals.java
public static int[] validRates(boolean stereo, boolean sixteen) { ArrayList<Integer> valid = new ArrayList<Integer>(); for (int rate : new int[] { 8000, 11025, 16000, 22050, 44100, 48000, 88200, 96000 }) { int bufferSize = AudioTrack.getMinBufferSize(rate, (stereo) ? AudioFormat.CHANNEL_OUT_STEREO : AudioFormat.CHANNEL_OUT_MONO, (sixteen) ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT); if (bufferSize > 0) { //System.out.println(rate+" "+bufferSize); // buffer size is valid, Sample rate supported valid.add(rate);/* w ww . j a v a 2 s. com*/ } } int[] rates = new int[valid.size()]; for (int i = 0; i < rates.length; i++) rates[i] = valid.get(i); return rates; }
From source file:com.xperia64.timidityae.Globals.java
public static SparseIntArray validBuffers(int[] rates, boolean stereo, boolean sixteen) { SparseIntArray buffers = new SparseIntArray(); for (int rate : rates) { buffers.put(rate,/* www. j ava 2 s .c o m*/ AudioTrack.getMinBufferSize(rate, (stereo) ? AudioFormat.CHANNEL_OUT_STEREO : AudioFormat.CHANNEL_OUT_MONO, (sixteen) ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT)); } return buffers; /*HashMap<Integer, Integer> buffers = new HashMap<Integer, Integer>(); for(int rate : rates) { buffers.put(rate, AudioTrack.getMinBufferSize(rate, (stereo)?AudioFormat.CHANNEL_OUT_STEREO:AudioFormat.CHANNEL_OUT_MONO, (sixteen)?AudioFormat.ENCODING_PCM_16BIT:AudioFormat.ENCODING_PCM_8BIT)); } return buffers;*/ }
From source file:uk.co.armedpineapple.cth.SDLActivity.java
public static Object audioInit(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) { int channelConfig = isStereo ? AudioFormat.CHANNEL_OUT_STEREO : AudioFormat.CHANNEL_OUT_MONO; int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT; int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1); Log.v("SDL", "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer"); // Let the user pick a larger buffer if they really want -- but ye // gods they probably shouldn't, the minimums are horrifyingly high // latency already desiredFrames = Math.max(desiredFrames, (AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize); mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM); audioStartThread();//w w w.j a va2 s .c o m Log.v("SDL", "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioTrack.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer"); if (is16Bit) { audioBuffer = new short[desiredFrames * (isStereo ? 2 : 1)]; } else { audioBuffer = new byte[desiredFrames * (isStereo ? 2 : 1)]; } return audioBuffer; }