Saturday, 15 March 2014

android - AudioRecord: Continuously record audio data and simultaneously analyse it -



android - AudioRecord: Continuously record audio data and simultaneously analyse it -

i trying utilize audiorecord object in android record sound info byte array , simultaneously perform analysis on recorded data. unsure how it. if utilize byte array straight application crashes. need byte array input analysing thread relatively new android development , appreciate help on topic. thanks

byte[] data; public void record()throws ioexception{ int buffersize = audiorecord.getminbuffersize(recorder_samplerate,recorder_channels,recorder_audio_encoding); audiorecord recorder = new audiorecord(mediarecorder.audiosource.mic, recorder_samplerate, recorder_channels,recorder_audio_encoding, buffersize); recorder.startrecording(); isrecording = true; boolean flag = true; info = new byte[buffersize]; while(isrecording){ seek { int result = recorder.read(data, 0, buffersize); if(flag){ thread analysethread = new thread(new runnable() { @override public void run() { theanalysingfunction(); } },"audiorecorder thread"); analysethread.start(); flag=false; } if (audiorecord.error_invalid_operation !=result ) { } else if (result == audiorecord.error_invalid_operation) { log.e("recording", "invalid operation error"); break; } else if (result == audiorecord.error_bad_value) { log.e("recording", "bad value error"); break; } else if (result == audiorecord.error) { log.e("recording", "unknown error"); break; } } grab (exception e) { log.i("error", "audiorecord error"); } } } public void theanalysingfunction(){ // //analyse byte array named info // }

this multithreading. seek analyze buffer. while thread changes simultaneously.

about crash, if u utilize byte buffer, create sure u utilize encoding_pcm_8bit encoding.

android bytearray audiorecord audio-analysis

No comments:

Post a Comment