android-audiorecord

Detect human voice from audio file input

廉价感情. 提交于 2019-12-02 15:50:44
I am trying to implement automatic voice recording functionality, similar to the Talking Tom app. I use the following code to read input from the audio recorder and analyse the buffer : float totalAbsValue = 0.0f; short sample = 0; numberOfReadBytes = audioRecorder.read( audioBuffer, 0, bufferSizeInBytes); // Analyze Sound. for( int i=0; i<bufferSizeInBytes; i+=2 ) { sample = (short)( (audioBuffer[i]) | audioBuffer[i + 1] << 8 ); totalAbsValue += Math.abs( sample ) / (numberOfReadBytes/2); } // Analyze temp buffer. tempFloatBuffer[tempIndex%3] = totalAbsValue; float temp = 0.0f; for( int i=0;

Android AudioRecord fails to initialize

 ̄綄美尐妖づ 提交于 2019-12-02 03:20:29
问题 I've been having an issue with using AudioRecord for Android. I've read as much as I can find online about it, but I cannot seem to get a good initialization. I have tried the Android 2.2 emulator, 1.5 emulator and my phone, an HTC Incredible running Froyo. The emulators and my phone fail initialization. I've tried sampling rates of 8000, 11025, and 44100, formats of CHANNEL_IN_MONO/STEREO and CHANNEL_CONFIGURATION_MONO/STEREO, 8bit and 16bit encoding (8 bit makes the getMinBufferSize fail),

AudioRecord start() error status -38

血红的双手。 提交于 2019-12-02 01:35:10
问题 I'm trying to set up an audio recorder and I keep getting a specific error and I can't figure out why. in my code I have checked what state the audio recorder is in with the Log before and after the startrecording() method. ar = new AudioRecord(audiosource, sampleRate, channelConfiguration, audioEncoding, buffersizebytes); Log.d("info", "ar.getState() before = " + String.valueOf(ar.getState())); ar.startRecording(); Log.d("info", "ar.getState() after = " +String.valueOf(ar.getState())); When

AudioRecord start() error status -38

不想你离开。 提交于 2019-12-02 01:03:54
I'm trying to set up an audio recorder and I keep getting a specific error and I can't figure out why. in my code I have checked what state the audio recorder is in with the Log before and after the startrecording() method. ar = new AudioRecord(audiosource, sampleRate, channelConfiguration, audioEncoding, buffersizebytes); Log.d("info", "ar.getState() before = " + String.valueOf(ar.getState())); ar.startRecording(); Log.d("info", "ar.getState() after = " +String.valueOf(ar.getState())); When I run the app I'm getting these messages in logcat. D/info﹕ ar.getState() before = 1 E/AudioRecord﹕

Android AudioRecord fails to initialize

空扰寡人 提交于 2019-12-01 23:26:21
I've been having an issue with using AudioRecord for Android. I've read as much as I can find online about it, but I cannot seem to get a good initialization. I have tried the Android 2.2 emulator, 1.5 emulator and my phone, an HTC Incredible running Froyo. The emulators and my phone fail initialization. I've tried sampling rates of 8000, 11025, and 44100, formats of CHANNEL_IN_MONO/STEREO and CHANNEL_CONFIGURATION_MONO/STEREO, 8bit and 16bit encoding (8 bit makes the getMinBufferSize fail), and AudioSource of MIC and DEFAULT. All result in the variable test becoming 0 after running a get

Android AudioRecord to File then use AudioTrack for Playback

独自空忆成欢 提交于 2019-12-01 13:06:13
Basically, I use AudioRecord to record a sound file to sdcard directory. It records for 5 seconds and then playback using AudioTrack. Well, for me, the recorded file doesn't exist. Maybe it didn't record successfully. Anything I did wrong in recording? what about the playback portion? public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); int minBufferSize = AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 44100,

Unable to access microphone when another app is using it in Android

我与影子孤独终老i 提交于 2019-11-30 19:17:26
I'm using code from the following URL in order to get sound data from the microphone with AudioRecord: http://www.dreamincode.net/forums/topic/303235-visualizing-sound-from-the-microphone/ The problem I'm seeing is that if another app is also using the microphone, I'm getting an error (status -3) from AudioRecord. Everything works as expected if I kill the other app which is using the microphone. Is there an elegant solution to allow my app to access the microphone even if another app is already using it? Thank you. Sadly, only one app at a time can access the microphone (just like the camera)

Unable to access microphone when another app is using it in Android

ぐ巨炮叔叔 提交于 2019-11-30 16:57:16
问题 I'm using code from the following URL in order to get sound data from the microphone with AudioRecord: http://www.dreamincode.net/forums/topic/303235-visualizing-sound-from-the-microphone/ The problem I'm seeing is that if another app is also using the microphone, I'm getting an error (status -3) from AudioRecord. Everything works as expected if I kill the other app which is using the microphone. Is there an elegant solution to allow my app to access the microphone even if another app is

Audio Recording in Stereo giving same data in Left and Right channels

為{幸葍}努か 提交于 2019-11-30 16:48:37
I am trying to record and process audio data based on differences in what gets recorded in the left and right channel. For this I am using Audio Record class, with MIC as input and STEREO mode. recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT, bufferSize); My issue is that I get exactly the same data in both the channels. (alternate samples are separated to get individual channel inputs). Please help. I am not sure why this is happening. Using this configuration: private int audioSource = MediaRecorder

AudioRecord and AudioTrack latency

老子叫甜甜 提交于 2019-11-30 13:53:06
I'm trying to develop an aplication like iRig for android, so the first step is to capture the mic input and play it at the same time. I have it, but the problem is that i get some latency that makes this unusable, and if I start processing the buffer i'm afraid it will get totally unusable. I use audiorecord and audiotrack like this: new Thread(new Runnable() { public void run() { while(mRunning){ mRecorder.read(mBuffer, 0, mBufferSize); //Todo: Apply filters here into the buffer and then play it modified mPlayer.write(mBuffer, 0, mBufferSize); //Log.v("MY AMP","ARA"); } And the