Best code examples for Android AudioRecord class (android.media.AudioRecord)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AudioRecord class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android AudioRecord examples from Open Source projects
Examples using Android AudioRecord release method:
This code example shows how to use the following methods: release, stop
129:	iTrack.stop(); 
-
146:	iTrack.release(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: read, release, startRecording, stop
70:	recorder.startRecording(); 
71:	recorder.read(readData, 0, readData.length); 
72:	recorder.stop(); 
73:	recorder.release(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: release, stop
40:	androidRecorder.stop(); 
41:	androidRecorder.release(); 
Full Snippet Info
5
CodeRank
Examples using Android AudioRecord getAudioFormat method:
This code example shows how to use the following methods: getAudioFormat, getChannelCount, getSampleRate, release
190:	if( mRecorder == null || mRecorder.getSampleRate() != rate || 
191:	mRecorder.getChannelCount() != channels || 
192:	mRecorder.getAudioFormat() != encodingConfig || 
-
196:	mRecorder.release(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getAudioFormat, getChannelCount, getSampleRate, release
186:	if( mRecorder == null || mRecorder.getSampleRate() != rate || 
187:	mRecorder.getChannelCount() != channels || 
188:	mRecorder.getAudioFormat() != encodingConfig || 
-
192:	mRecorder.release(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getAudioFormat, getChannelConfiguration, getSampleRate
21:	if (audioRecord.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT){ 
-
24:	else if (audioRecord.getAudioFormat() == AudioFormat.ENCODING_PCM_8BIT){ 
-
30:	if (audioRecord.getChannelConfiguration() == AudioFormat.CHANNEL_CONFIGURATION_MONO){ 
-
38:	waveHeader.setSampleRate(audioRecord.getSampleRate()); 
Full Snippet Info
5
CodeRank
Examples using Android AudioRecord getState method:
This code example shows how to use the following methods: getState, startRecording
30:	AudioRecord recorder = new AudioRecord(audioSource, 
-
33:	if (recorder.getState() != AudioRecord.STATE_INITIALIZED) { 
-
38:	recorder.startRecording(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getState, setPositionNotificationPeriod, setRecordPositionUpdateListener
150:	audioRecorder = new AudioRecord(audioSource, sampleRate, channelConfig, audioFormat, mBufferSize); 
151:	if (audioRecorder.getState() != AudioRecord.STATE_INITIALIZED) { 
-
154:	audioRecorder.setRecordPositionUpdateListener(updateListener); 
155:	audioRecorder.setPositionNotificationPeriod(mPeriodInFrames); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getState, setNotificationMarkerPosition, setPositionNotificationPeriod, setRecordPositionUpdateListener
76:	sampleRate, channelConfig, audioFormat, mAudioBufferSize); 
-
84:	mAudioRecord.setNotificationMarkerPosition(10000); 
85:	mAudioRecord.setPositionNotificationPeriod(1000); 
86:	mAudioRecord.setRecordPositionUpdateListener(mListener); 
-
88:	int audioRecordState = mAudioRecord.getState(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getRecordingState, getState, startRecording
109:	if (_mic != null && _mic.getState() == AudioRecord.STATE_INITIALIZED) { 
-
113:	_mic.startRecording(); 
-
119:	+ _mic.getState() + ", recordingState=" 
120:	+ _mic.getRecordingState()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getRecordingState, release, stop
182:	if (audioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) { 
183:	audioRecord.stop(); 
-
185:	audioRecord.release(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getRecordingState, getState, read, startRecording, stop
231:	AudioRecord recorder = new AudioRecord(AudioSource.MIC, 8000, AudioFormat.CHANNEL_IN_MONO, 
-
234:	if (recorder.getRecordingState() == android.media.AudioRecord.RECORDSTATE_STOPPED) 
235:	recorder.startRecording(); // check to see if the Recorder 
-
240:	recorder.read(audioData, 0, bufferSize); // read the PCM 
-
246:	if (recorder.getState() == android.media.AudioRecord.RECORDSTATE_RECORDING) 
247:	recorder.stop(); // stop the recorder 
Full Snippet Info
6
CodeRank
Examples using Android AudioRecord startRecording method:
This code example shows how to use the following methods: startRecording
37:	: AudioFormat.CHANNEL_CONFIGURATION_STEREO, AudioFormat.ENCODING_PCM_16BIT, minBufferSize); 
38:	recorder.startRecording(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: read, startRecording, stop
95:	audioRecord.startRecording(); 
96:	mSamplesRead = audioRecord.read(buffer, 0, buffersizebytes); 
97:	audioRecord.stop(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: startRecording
284:	final AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, 
-
289:	audioRecord.startRecording(); 
-
295:	new Thread(new Runnable() { 
Full Snippet Info
5
CodeRank
Examples using Android AudioRecord read method:
This code example shows how to use the following methods: read, release, startRecording, stop
17:	AudioRecord record = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, 44100, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, (minBuffer * 100)); 
-
19:	record.startRecording(); 
-
21:	nbPoint = record.read(point, 0, point.length); 
-
23:	record.stop(); 
24:	record.release(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: read, release, startRecording, stop
22:	AudioRecord record = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, 
-
27:	record.startRecording(); 
-
29:	nbPoint = record.read(point, 0, point.length); 
-
31:	record.stop(); 
32:	record.release(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: read, setPositionNotificationPeriod, setRecordPositionUpdateListener, startRecording
155:	minbufferSize); 
-
157:	audioRecord.setPositionNotificationPeriod(bufferSize); 
158:	audioRecord.setRecordPositionUpdateListener(new OnRecordPositionUpdateListener() { 
-
175:	audioRecord.startRecording(); 
-
179:	audioRecord.read(buffer, 0, bufferSize); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getState, setPositionNotificationPeriod, setRecordPositionUpdateListener
179:	aRecorder = new AudioRecord(audioSource, sampleRate, channelConfig, audioFormat, bufferSize); 
180:	if (aRecorder.getState() != AudioRecord.STATE_INITIALIZED) 
-
182:	aRecorder.setRecordPositionUpdateListener(updateListener); 
183:	aRecorder.setPositionNotificationPeriod(framePeriod); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: read, setPositionNotificationPeriod, setRecordPositionUpdateListener, startRecording
111:	sampleRate, nChannelConfig, audioConfig, bufferSize); 
-
128:	recordInstance.setRecordPositionUpdateListener(updateListener); 
129:	recordInstance.setPositionNotificationPeriod(framePeriod); 
130:	recordInstance.startRecording(); 
131:	recordInstance.read(dataBuffer, 0, dataBuffer.length); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: read, setPositionNotificationPeriod, setRecordPositionUpdateListener, startRecording
111:	sampleRate, nChannelConfig, audioConfig, bufferSize); 
-
128:	recordInstance.setRecordPositionUpdateListener(updateListener); 
129:	recordInstance.setPositionNotificationPeriod(framePeriod); 
130:	recordInstance.startRecording(); 
131:	recordInstance.read(dataBuffer, 0, dataBuffer.length); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getState, setNotificationMarkerPosition, setPositionNotificationPeriod, setRecordPositionUpdateListener
81:	mAudioBufferSize); 
-
88:	mAudioRecord.setNotificationMarkerPosition(10000); 
89:	mAudioRecord.setPositionNotificationPeriod(1000); 
90:	mAudioRecord.setRecordPositionUpdateListener(mListener); 
-
92:	int audioRecordState = mAudioRecord.getState(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getState, setNotificationMarkerPosition, setPositionNotificationPeriod, setRecordPositionUpdateListener
81:	mAudioBufferSize); 
-
88:	mAudioRecord.setNotificationMarkerPosition(10000); 
89:	mAudioRecord.setPositionNotificationPeriod(1000); 
90:	mAudioRecord.setRecordPositionUpdateListener(mListener); 
-
92:	int audioRecordState = mAudioRecord.getState(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getState, setPositionNotificationPeriod, setRecordPositionUpdateListener
199:	channelConfig, audioFormat, bufferSize); 
-
201:	if (audioRecorder.getState() != AudioRecord.STATE_INITIALIZED) 
-
203:	audioRecorder.setRecordPositionUpdateListener(updateListener); 
204:	audioRecorder.setPositionNotificationPeriod(framePeriod); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getState, setPositionNotificationPeriod, setRecordPositionUpdateListener
177:	aRecorder = new AudioRecord(audioSource, sampleRate, channelConfig, audioFormat, bufferSize); 
178:	if (aRecorder.getState() != AudioRecord.STATE_INITIALIZED) 
-
180:	aRecorder.setRecordPositionUpdateListener(updateListener); 
181:	aRecorder.setPositionNotificationPeriod(framePeriod); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getState, setPositionNotificationPeriod, setRecordPositionUpdateListener
245:	aRecorder = new AudioRecord(aSource, sRate, cConfig, aFormat, bufferSize); 
246:	aRecorder.setRecordPositionUpdateListener(updateListener); 
247:	aRecorder.setPositionNotificationPeriod(framePeriod); 
-
253:	if (aRecorder.getState() == AudioRecord.STATE_INITIALIZED) 
Full Snippet Info
5
CodeRank
Examples using Android AudioRecord stop method:
This code example shows how to use the following methods: read, startRecording, stop
95:	audioRecord.startRecording(); 
96:	mSamplesRead = audioRecord.read(buffer, 0, buffersizebytes); 
97:	audioRecord.stop(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: read, startRecording, stop
142:	AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, AudioFormat.CHANNEL_IN_MONO, audioEncoding, recBufferSize); 
-
144:	audioRecord.startRecording(); 
145:	audioRecord.read(recData, 0, recBufferSize); 
146:	audioRecord.stop(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: release, stop
147:	recorder.stop(); 
148:	recorder.release(); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getAudioFormat, getChannelConfiguration, getSampleRate
29:	if (audioRecord.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) { 
-
31:	} else if (audioRecord.getAudioFormat() == AudioFormat.ENCODING_PCM_8BIT) { 
-
37:	if (audioRecord.getChannelConfiguration() == AudioFormat.CHANNEL_CONFIGURATION_MONO) { 
-
45:	waveHeader.setSampleRate(audioRecord.getSampleRate()); 
Full Snippet Info
5
CodeRank
Examples for other Android AudioRecord methods:
Related Android AudioRecord Questions & Answers:
AudioRecord Class Overview
The AudioRecord class manages the audio resources for Java applications to record audio from the audio input hardware of the platform. This is achieved by "pulling" (reading) the data from the AudioRecord object. The application is responsible for polling the AudioRecord object in time using one of the following three methods: read(byte[], int, int), read(short[], int, int) or read(ByteBuffer, int). The choice of which method to use will be based on the audio data storage format that is the most convenient for the user of AudioRecord. Upon creation, an AudioRecord object initializes its associated audio buffer that it will fill with the new audio data. The size of this buffer, specified during the construction, determines how long an AudioRecord can record before "over-running" data that has not been read yet. Data should be read from the audio hardware in ch...
Methods
  • getSampleRate
    Returns the configured audio data sample rate in Hz
  • getState
    Returns the state of the AudioRecord instance.
  • read
    Reads audio data from the audio hardware for recording into a buffer.
  • release
    Releases the native AudioRecord resources.
  • setNotificationMarkerPosition
    Sets the marker position at which the listener is called, if set with setRecordPositionUpdateListener(OnRecordPositionUpdateListener) or setRecordPositionUpdateListener(OnRecordPositionUpdateListener, Handler).
  • setPositionNotificationPeriod
    Sets the period at which the listener is called, if set with setRecordPositionUpdateListener(OnRecordPositionUpdateListener) or setRecordPositionUpdateListener(OnRecordPositionUpdateListener, Handler).
  • setRecordPositionUpdateListener
    Sets the listener the AudioRecord notifies when a previously set marker is reached or for each periodic record head position update.
  • stop
    Stops recording.