Android audio FFT to retrieve specific frequency magnitude using audiorecord

First you need to ensure that the result you are getting is correctly converted to a float/double. I’m not sure how the short[] version works, but the byte[] version only returns the raw byte version. This byte array then needs to be properly converted to a floating point number. The code for the conversion should … Read more

Android AudioRecord class – process live mic audio quickly, set up callback function

After experimenting lots with the notifications and a bunch of other techniques I settled on this code: private class AudioIn extends Thread { private boolean stopped = false; private AudioIn() { start(); } @Override public void run() { android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO); AudioRecord recorder = null; short[][] buffers = new short[256][160]; int ix = 0; try { // … Read more

Android AudioRecord vs. MediaRecorder for recording audio

If you want to do your analysis while recording is still in progress, you need to use AudioRecord, as MediaRecorder automatically records into a file. AudioRecord has the disadvantage, that after calling startRecording() you need to poll the data yourself from the AudioRecord instance. Also, you must read and process the data fast enough such … Read more