Code example for AudioRecord

Methods: getStatesetPositionNotificationPeriodsetRecordPositionUpdateListener

0
				// Set frame period and timer interval accordingly 
				mPeriodInFrames = mBufferSize / ( 2 * mBitsPersample * nChannels / 8 );
				Log.w(WavAudioRecorder.class.getName(), "Increasing buffer size to " + Integer.toString(mBufferSize));
			} 
			 
			audioRecorder = new AudioRecord(audioSource, sampleRate, channelConfig, audioFormat, mBufferSize);
 
			if (audioRecorder.getState() != AudioRecord.STATE_INITIALIZED) {
				throw new Exception("AudioRecord initialization failed");
			} 
			audioRecorder.setRecordPositionUpdateListener(updateListener);
			audioRecorder.setPositionNotificationPeriod(mPeriodInFrames);
			filePath = null;
			state = State.INITIALIZING;
		} catch (Exception e) {
			if (e.getMessage() != null) {
				Log.e(WavAudioRecorder.class.getName(), e.getMessage());
			} else { 
				Log.e(WavAudioRecorder.class.getName(), "Unknown error occured while initializing recording");
			} 
			state = State.ERROR;