AudioRecord setRecordPositionUpdateListener - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AudioRecord setRecordPositionUpdateListener method.

This code example shows how to use the following methods:getState, setPositionNotificationPeriod, setRecordPositionUpdateListener
				// Set frame period and timer interval accordingly 
				mPeriodInFrames = mBufferSize / ( 2 * mBitsPersample * mNumOfChannels / 8 );
				Log.w(PcmAudioRecorder.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(PcmAudioRecorder.class.getName(), e.getMessage());
			} else { 
				Log.e(PcmAudioRecorder.class.getName(), "Unknown error occured while initializing recording");
			} 
			state = State.ERROR;
7
CodeRank
This code example shows how to use the following methods:getState, setNotificationMarkerPosition, setPositionNotificationPeriod, setRecordPositionUpdateListener
			int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
			mAudioBufferSize = 2 * AudioRecord.getMinBufferSize(sampleRate,
					channelConfig, audioFormat);
			mAudioBufferSampleSize = mAudioBufferSize / 2;
			mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
					sampleRate, channelConfig, audioFormat, mAudioBufferSize);
			Log.v(TAG, "Setup of AudioRecord okay. Buffer size = "
					+ mAudioBufferSize);
			Log.v(TAG, "   Sample buffer size = " + mAudioBufferSampleSize);
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} 
 
		mAudioRecord.setNotificationMarkerPosition(10000);
		mAudioRecord.setPositionNotificationPeriod(1000);
		mAudioRecord.setRecordPositionUpdateListener(mListener);
 
		int audioRecordState = mAudioRecord.getState();
		if (audioRecordState != AudioRecord.STATE_INITIALIZED) {
			Log.e(TAG, "AudioRecord is not properly initialized");

6
CodeRank
This code example shows how to use the following methods:getState, setPositionNotificationPeriod, setRecordPositionUpdateListener
					// Set frame period and timer interval accordingly 
					framePeriod = bufferSize / ( 2 * bSamples * nChannels / 8 );
					Log.w(RehearsalAudioRecorder.class.getName(), "Increasing buffer size to " + Integer.toString(bufferSize));
				} 
 
				aRecorder = new AudioRecord(audioSource, sampleRate, channelConfig, audioFormat, bufferSize);
				if (aRecorder.getState() != AudioRecord.STATE_INITIALIZED)
					throw new Exception("AudioRecord initialization failed");
				aRecorder.setRecordPositionUpdateListener(updateListener);
				aRecorder.setPositionNotificationPeriod(framePeriod);
			} else 
			{ // RECORDING_COMPRESSED 
				mRecorder = new MediaRecorder();
				mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
				mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
				mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
			} 
			cAmplitude = 0;
			fPath = null;
			state = State.INITIALIZING;
6
CodeRank
This code example shows how to use the following methods:read, setPositionNotificationPeriod, setRecordPositionUpdateListener, startRecording
		Log.d(TAG, "bufferSize1:" + bufferSize1 + " bufferSize2:" + bufferSize2
				+ " sampleRate:" + sampleRate + " nChannelConfig:"
				+ nChannelConfig + " audioConfig:" + audioConfig);
		dataBuffer = new byte[PACKAGE_SIZE];
		recordInstance = new AudioRecord(MediaRecorder.AudioSource.MIC,
				sampleRate, nChannelConfig, audioConfig, bufferSize);
		// TODO may get null record instance 
		updateListener = new AudioRecord.OnRecordPositionUpdateListener() {
			public void onPeriodicNotification(AudioRecord recorder) {
				if (!isRecording) {
					Log.d(TAG, "not recording,discard data!");
					return; 
				} 
				int readsize = recordInstance.read(dataBuffer, 0,
						dataBuffer.length);
				sendDataMessage(dataBuffer, readsize);
			} 
 
			public void onMarkerReached(AudioRecord recorder) {
				// NOT USED 

6
CodeRank
This code example shows how to use the following methods:getState, setNotificationMarkerPosition, setPositionNotificationPeriod, setRecordPositionUpdateListener
			mAudioRecord = new AudioRecord(
					MediaRecorder.AudioSource.MIC,
					sampleRate,
					channelConfig,
					audioFormat,
					mAudioBufferSize);
			Log.v(TAG, "Setup of AudioRecord okay. Buffer size = " + mAudioBufferSize);
			Log.v(TAG, "   Sample buffer size = " + mAudioBufferSampleSize);
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} 
		 
		mAudioRecord.setNotificationMarkerPosition(10000);
		mAudioRecord.setPositionNotificationPeriod(1000);
		mAudioRecord.setRecordPositionUpdateListener(mListener);
		 
		int audioRecordState = mAudioRecord.getState();
		if(audioRecordState != AudioRecord.STATE_INITIALIZED) {
			Log.e(TAG, "AudioRecord is not properly initialized");
			finish();

6
CodeRank
This code example shows how to use the following methods:read, setPositionNotificationPeriod, setRecordPositionUpdateListener, startRecording
		Log.d(TAG, "bufferSize1:" + bufferSize1 + " bufferSize2:" + bufferSize2
				+ " sampleRate:" + sampleRate + " nChannelConfig:"
				+ nChannelConfig + " audioConfig:" + audioConfig);
		dataBuffer = new byte[PACKAGE_SIZE];
		recordInstance = new AudioRecord(MediaRecorder.AudioSource.MIC,
				sampleRate, nChannelConfig, audioConfig, bufferSize);
		// TODO may get null record instance 
		updateListener = new AudioRecord.OnRecordPositionUpdateListener() {
			public void onPeriodicNotification(AudioRecord recorder) {
				if (!isRecording) {
					Log.d(TAG, "not recording,discard data!");
					return; 
				} 
				int readsize = recordInstance.read(dataBuffer, 0,
						dataBuffer.length);
				sendDataMessage(dataBuffer, readsize);
			} 
 
			public void onMarkerReached(AudioRecord recorder) {
				// NOT USED 

6
CodeRank
This code example shows how to use the following methods:getState, setNotificationMarkerPosition, setPositionNotificationPeriod, setRecordPositionUpdateListener
            mAudioRecord = new AudioRecord(
                    MediaRecorder.AudioSource.MIC,
                    sampleRate,
                    channelConfig,
                    audioFormat,
                    mAudioBufferSize);
            Log.v(TAG, "Ustanawianie obiektu AudioRecord udane. Rozmiar buforu = " + mAudioBufferSize);
            Log.v(TAG, "   Rozmiar buforu testowego = " + mAudioBufferSampleSize);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } 
 
        mAudioRecord.setNotificationMarkerPosition(10000);
        mAudioRecord.setPositionNotificationPeriod(1000);
        mAudioRecord.setRecordPositionUpdateListener(mListener);
 
        int audioRecordState = mAudioRecord.getState();
        if(audioRecordState != AudioRecord.STATE_INITIALIZED) {
            Log.e(TAG, "Obiekt AudioRecord zostal niewlasciwie zainicjowany");
            finish();

6
CodeRank
This code example shows how to use the following methods:read, setPositionNotificationPeriod, setRecordPositionUpdateListener, startRecording
6
CodeRank
This code example shows how to use the following methods:getState, setPositionNotificationPeriod, setRecordPositionUpdateListener
                            "Increasing buffer size to " 
                                    + Integer.toString(bufferSize));
                } 
 
                audioRecorder = new AudioRecord(audioSource, sampleRate,
                        channelConfig, audioFormat, bufferSize);
 
                if (audioRecorder.getState() != AudioRecord.STATE_INITIALIZED)
                    throw new Exception("AudioRecord initialization failed");
                audioRecorder.setRecordPositionUpdateListener(updateListener);
                audioRecorder.setPositionNotificationPeriod(framePeriod);
            } else { // RECORDING_COMPRESSED 
                mediaRecorder = new MediaRecorder();
                mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                mediaRecorder
                        .setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
                mediaRecorder
                        .setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
            } 
            cAmplitude = 0;
6
CodeRank
This code example shows how to use the following methods:getState, setPositionNotificationPeriod, setRecordPositionUpdateListener
					// Set frame period and timer interval accordingly 
					framePeriod = bufferSize / ( 2 * bSamples * nChannels / 8 );
					Log.w(RehearsalAudioRecorder.class.getName(), "Increasing buffer size to " + Integer.toString(bufferSize));
				} 
				 
				aRecorder = new AudioRecord(audioSource, sampleRate, channelConfig, audioFormat, bufferSize);
				if (aRecorder.getState() != AudioRecord.STATE_INITIALIZED)
					throw new Exception("AudioRecord initialization failed");
				aRecorder.setRecordPositionUpdateListener(updateListener);
				aRecorder.setPositionNotificationPeriod(framePeriod);
			} else 
			{ // RECORDING_COMPRESSED 
				mRecorder = new MediaRecorder();
				mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
				mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
				mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
			} 
			cAmplitude = 0;
			fPath = null;
			state = State.INITIALIZING;
5
CodeRank

Related AudioRecord setRecordPositionUpdateListener Questions & Answers:

setRecordPositionUpdateListener Method Overview
Sets the listener the AudioRecord notifies when a previously set marker is reached or for each periodic record head position update.
See Code Examples for other Android AudioRecord Methods: