List of usage examples for android.media AudioFormat CHANNEL_IN_MONO
int CHANNEL_IN_MONO
To view the source code for android.media AudioFormat CHANNEL_IN_MONO.
Click Source Link
From source file:com.bangz.shotrecorder.RecordActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recorder); ActionBar bar = getSupportActionBar(); bar.setDisplayHomeAsUpEnabled(true); strModeNames = getResources().getStringArray(R.array.mode_names); strModeValNames = getResources().getStringArray(R.array.mode_value_names); mMode = MODE.COMSTOCK;//from w w w . ja va2 s.c om setDigitFont(); initButtonsListener(); TextView v = (TextView) findViewById(R.id.textTIME); v.setText("------"); FragmentManager fm = getSupportFragmentManager(); SplitListFragment splitfragment = (SplitListFragment) fm.findFragmentById(R.id.splitlist); mSplitAdapter = new SplitArrayAdapter(this, mSplitManager.getSplits()); splitfragment.setListAdapter(mSplitAdapter); if (savedInstanceState == null) { Intent intent = getIntent(); if (intent.getBooleanExtra(EXTRA_STARTFROMNOTIFY, false)) { mState = STATE_RECORDING; int mode = intent.getIntExtra(RecordService.EXTRA_MODE, 0); Log.d(TAG, "get mode in RecordActivity from service mode = " + mode); mMode = MODE.values()[mode]; mSampleRate = intent.getIntExtra(RecordService.EXTRA_SAMPLERATE, 44100); mChannels = intent.getIntExtra(RecordService.EXTRA_CHANNLES, AudioFormat.CHANNEL_IN_MONO); mEncoding = intent.getIntExtra(RecordService.EXTRA_ENCODDING, AudioFormat.ENCODING_PCM_16BIT); mMaxShots = intent.getIntExtra(RecordService.EXTRA_MAXSHOT, 0); mMaxParTime = intent.getIntExtra(RecordService.EXTRA_MAXPARTIME, 0) / 1000.0f; mCaptureSize = intent.getIntExtra(RecordService.EXTRA_CAPTURESIZE, 0); mMaxRecordTime = intent.getIntExtra(RecordService.EXTRA_MAXRECORDTIME, 5 * 60); } } updateMode(); updateStatus(); }
From source file:com.brejza.matt.habmodem.Dsp_service.java
public void startAudio() { if (!_enableDecoder) return;// w w w . ja va 2 s . c o m boolean mic = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MICROPHONE); System.out.println("isRecording: " + isRecording); logEvent("Starting Audio. Mic avaliable: " + mic, false); if (!isRecording) { isRecording = true; buffsize = AudioRecord.getMinBufferSize(8000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); buffsize = Math.max(buffsize, 3000); mRecorder = new AudioRecord(AudioSource.MIC, 8000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, buffsize); mPlayer = new AudioTrack(AudioManager.STREAM_MUSIC, 8000, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT, 2 * buffsize, AudioTrack.MODE_STREAM); if (enableEcho) { AudioManager manager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); manager.setMode(AudioManager.MODE_IN_CALL); manager.setSpeakerphoneOn(true); } if (mRecorder.getState() != AudioRecord.STATE_INITIALIZED) { mRecorder = new AudioRecord(AudioSource.DEFAULT, 8000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, buffsize); if (mRecorder.getState() != AudioRecord.STATE_INITIALIZED) { logEvent("Error - Could not initialise audio", true); return; } logEvent("Using default audio source", false); } mRecorder.startRecording(); System.out.println("STARTING THREAD"); Thread ct = new captureThread(); logEvent("Starting Audio Thread.", false); setDecoderRunningNotification(); ct.start(); } }
From source file:com.smc.tw.waltz.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (DEBUG)/* www . ja v a2s . co m*/ Log.d(TAG, "onCreate"); overridePendingTransition(R.anim.slide_right_in, R.anim.slide_left_out); super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); setContentView(R.layout.activity_main); mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG); mPreferences = PreferenceManager.getDefaultSharedPreferences(this); mFragmentManager = getSupportFragmentManager(); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); mAudioRecordBufferSize = 5600;//AudioRecord.getMinBufferSize(8000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT)*10; mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, 8000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, mAudioRecordBufferSize); mNotifyChannelList = new ArrayList<String>(); setupLayout(); if (savedInstanceState != null) { mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); } // mRegistrationBroadcastReceiver = new BroadcastReceiver() { // @Override // public void onReceive(Context context, Intent intent) { // // // checking for type intent filter // if (intent.getAction().equals(MainApplication.REGISTRATION_COMPLETE)) { // // gcm successfully registered // // now subscribe to `global` topic to receive app wide notifications // String token = intent.getStringExtra("token"); // // //Toast.makeText(getApplicationContext(), "GCM registration token: " + token, Toast.LENGTH_LONG).show(); // // } else if (intent.getAction().equals(MainApplication.SENT_TOKEN_TO_SERVER)) { // // gcm registration id is stored in our server's MySQL // // Toast.makeText(getApplicationContext(), "GCM registration token is stored in server!", Toast.LENGTH_LONG).show(); // // } else if (intent.getAction().equals(MainApplication.PUSH_NOTIFICATION)) { // // new push notification is received // // Toast.makeText(getApplicationContext(), "Push notification is received!", Toast.LENGTH_LONG).show(); // } // } // }; // if (checkPlayServices()) { registerGCM(); } }
From source file:cc.echonet.coolmicapp.MainActivity.java
public void startRecording(View view) { if (isThreadOn) { stopRecording(view);//from www .j a v a2s . c o m return; } if (!checkPermission()) { Toast.makeText(getApplicationContext(), "Missing Permissions. Please request them in the Settings.", Toast.LENGTH_LONG).show(); return; } if (Wrapper.getState() != Wrapper.WrapperInitializationStatus.WRAPPER_INTITIALIZED) { Toast.makeText(getApplicationContext(), "Native components not ready.", Toast.LENGTH_LONG).show(); return; } if (!isOnline()) { Toast.makeText(getApplicationContext(), "Check Internet Connection !", Toast.LENGTH_LONG).show(); return; } if (!coolmic.isConnectionSet()) { Toast.makeText(getApplicationContext(), "Set the connection details !", Toast.LENGTH_LONG).show(); return; } invalidateOptionsMenu(); isThreadOn = true; //screenreceiver.setThreadStatus(true); startService(new Intent(getBaseContext(), MyService.class)); RedFlashLight(); timeInMilliseconds = 0L; timeSwapBuff = 0L; start_button.startAnimation(animation); start_button.setBackground(trans); trans.startTransition(5000); start_button.setText(R.string.broadcasting); streamThread = new Thread(new Runnable() { @Override public void run() { if (isThreadOn) { try { String portnum; String server = coolmic.getServerName(); Integer port_num = 8000; if (server.indexOf(":") > 0) { String[] split = server.split(":"); server = split[0]; portnum = split[1]; port_num = Integer.parseInt(portnum); } Log.d("VS", server); Log.d("VS", port_num.toString()); String username = coolmic.getUsername(); String password = coolmic.getPassword(); String mountpoint = coolmic.getMountpoint(); String sampleRate_string = coolmic.getSampleRate(); String channel_string = coolmic.getChannels(); String quality_string = coolmic.getQuality(); String title = coolmic.getTitle(); String artist = coolmic.getArtist(); Log.d("VS", String.format( "Server: %s Port: %d Username: %s Password: %s Mountpoint: %s Samplerate: %s Channels: %s Quality: %s Title: %s Artist: %s", server, port_num, username, password, mountpoint, sampleRate_string, channel_string, quality_string, title, artist)); Integer buffersize = AudioRecord.getMinBufferSize(Integer.parseInt(sampleRate_string), Integer.parseInt(channel_string) == 1 ? AudioFormat.CHANNEL_IN_MONO : AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT); Log.d("VS", "Minimum Buffer Size: " + String.valueOf(buffersize)); Wrapper.init(MainActivity.this, server, port_num, username, password, mountpoint, "audio/ogg; codec=vorbis", Integer.parseInt(sampleRate_string), Integer.parseInt(channel_string), buffersize); int status = Wrapper.start(); Log.d("VS", "Status:" + status); if (status != 0) { throw new Exception("Failed to start Recording: " + String.valueOf(status)); } strStreamFetchStatsURL = String.format("http://%s:%s@%s:%s/admin/stats.xml?mount=/%s", username, password, server, port_num, mountpoint); } catch (Exception e) { e.printStackTrace(); Log.e("VS", "Recording Start: Exception: ", e); MainActivity.this.runOnUiThread(new Runnable() { public void run() { stopRecording(null); Toast.makeText(MainActivity.this, "Failed to start Recording. ", Toast.LENGTH_LONG) .show(); } }); } } } }); streamThread.start(); }
From source file:com.inmobi.ultrapush.AnalyzeActivity.java
/** * Return a array of verified audio sampling rates. * * @param requested: the sampling rates to be verified *///from www. j av a2 s .c o m private static String[] validateAudioRates(String[] requested) { ArrayList<String> validated = new ArrayList<String>(); for (String s : requested) { int rate; String[] sv = s.split("::"); if (sv.length == 1) { rate = Integer.parseInt(sv[0]); } else { rate = Integer.parseInt(sv[1]); } if (rate != 0) { if (AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT) != AudioRecord.ERROR_BAD_VALUE) { validated.add(s); } } else { validated.add(s); } } return validated.toArray(new String[0]); }