AudioRecord getRecordingState - 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 getRecordingState method.

This code example shows how to use the following methods:getRecordingState, getState, stop
                    + ".startRec(): Failed to initialise microphone."); 
        } 
    } 
 
    protected void stopRec() { 
        if ((_mic != null) && (_mic.getState() == AudioRecord.STATE_INITIALIZED)) {
            if (_mic.getRecordingState() != AudioRecord.RECORDSTATE_STOPPED) {
                _mic.stop();
            } 
            Log.debug(this.getClass().getSimpleName()
                    + ".stopRec(): mic stopped"); 
        } 
 
        if (_me != null) {
            Thread tmic = _me;
            _me = null;
            try { 
                tmic.join(1000);
                Log.debug( 
                        this.getClass().getSimpleName()
7
CodeRank
This code example shows how to use the following methods:getRecordingState, release, stop
            } 
        } 
 
        public void cleanup() { 
            // stop things 
            if (audioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
                audioRecord.stop();
            } 
            audioRecord.release();
            if (isLiveMode) {
                audioTrack.stop();
                audioTrack.release();
            } 
            if (instrumentalReader != null) {
                try { 
                    Resample.close(); 
                    instrumentalReader.closeWaveFile();
                } catch (IOException e) {
                    // no recovery possible here 
                    e.printStackTrace();
7
CodeRank
This code example shows how to use the following methods:getRecordingState, getState, read, startRecording, stop
		return tmpData;
	} 
 
	  private byte[] fillBuffer(byte[] audioData, int bufferSize) {
 
		    AudioRecord recorder = new AudioRecord(AudioSource.MIC, 8000, AudioFormat.CHANNEL_IN_MONO,
		            AudioFormat.ENCODING_PCM_16BIT, bufferSize); // instantiate the
		                                                            // AudioRecorder 
		    if (recorder.getRecordingState() == android.media.AudioRecord.RECORDSTATE_STOPPED)
		        recorder.startRecording(); // check to see if the Recorder
		                                    // has stopped or is not 
		                                    // recording, and make it 
		                                    // record. 
 
		    recorder.read(audioData, 0, bufferSize); // read the PCM
		                                                // audio data 
		                                                // into the 
		                                                // audioData 
		                                                // array 
 

6
CodeRank
This code example shows how to use the following methods:getRecordingState, release, stop
 
    /** 
     * Stops audio recorder. 
     */ 
    private void stopAudioRecorder() { 
        if (mAudioRecord != null && mAudioRecord.getRecordingState() != AudioRecord.RECORDSTATE_STOPPED) {
            mAudioRecord.stop();
            mAudioRecord.release();
            mAudioRecord = null;
        } 
 
        Process.setThreadPriority(Process.THREAD_PRIORITY_DEFAULT);
 
        mRecording.set(false);
        mStarted.set(false);
        mAmplitude = 0;
    } 
 
    private void readAmplitude() { 
        if (mAudioRecord.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) {
5
CodeRank
This code example shows how to use the following methods:getRecordingState, getState, startRecording
    protected int getOutboundTimestamp() { 
        return (int) (this.getTime() - _timestampRecStart);
    } 
 
    protected void startRec() { 
        if (_mic != null && _mic.getState() == AudioRecord.STATE_INITIALIZED) {
            AndroidLog.getLog().debug( 
                    this.getClass().getSimpleName()
                            + ".startRec(): starting mic"); 
            _mic.startRecording();
            resetTimestampRecStart(); 
            _countFrames = 0;
 
            AndroidLog.getLog().debug( 
                    this.getClass().getSimpleName() + ".startRec(): state="
                            + _mic.getState() + ", recordingState="
                            + _mic.getRecordingState());
 
            if (_me == null) {
                _me = new Thread(this, "mic");

5
CodeRank
This code example shows how to use the following methods:getRecordingState, release, stop
            } 
        } 
 
        public void cleanup() { 
            // stop things 
            if (audioRecord.getRecordingState() == AudioRecord.RECORDSTATE_RECORDING) {
                audioRecord.stop();
            } 
            audioRecord.release();
            if (isLiveMode) {
                audioTrack.stop();
                audioTrack.release();
            } 
            if (instrumentalReader != null) {
                try { 
                    Resample.close(); 
                    instrumentalReader.closeWaveFile();
                } catch (IOException e) {
                    // no recovery possible here 
                    e.printStackTrace();
5
CodeRank
This code example shows how to use the following methods:getRecordingState, release
	 */ 
	private void startRecorder() 
	{ 
		if(audioRecord != null)
		{ 
			audioRecord.release();
			audioRecord = null;
		} 
		//Create AudioRecord: 
		audioRecord = ((AndroidAudioSpecification) audioSpec).getAudioRecord(this.bufferSize);
		audioRecord.startRecording();
		/* Set thread priority to high */ 
		android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
	} 
 
	@Override 
	protected AudioStream getRecordedStream() throws Exception
	{ 
		//If first time recording -> recorder not yet started -> initiate recorder 
		if(audioRecord == null || audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING)

4
CodeRank

Related AudioRecord getRecordingState Questions & Answers:

getRecordingState Method Overview
Returns the recording state of the AudioRecord instance.
See Code Examples for other Android AudioRecord Methods: