Hello, I'm writing an app to do a "live" FFT on the audio read in by the device's microphone.
After struggling with some JNI issues I finally have my FFT working pretty quickly, but now I'm having an issue with AudioRecord. The FFT computes in about 300 ms (depending on the number of samples) and is in its own thread, allowing the canvas to draw the output (I have it draw the resulting spectrum). Everything is working more-or-less as desired, but there is a 2-3 second delay between when I play a tone and when the FFT will "read" it. Even on a transform with very few samples which only takes 5ms, this delay is present, so I must assume it has to do with AudioRecord. Has anyone else experienced such a delay? The following is the code for intializing and reading from the AudioRecord instance: private static final int AUDIO_SAMPLE_FREQ = 8000; private static final int TRANSFORM_SAMPLES = 1024; private static final int LOW_FREQ = 75; private static final int HIGH_FREQ = 360; private short[] signal; AudioRecord recorder = null; int buffsize = AudioRecord.getMinBufferSize(8000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); try { recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, AUDIO_SAMPLE_FREQ, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, buffsize); } catch (IllegalArgumentException e) { e.printStackTrace(); } ... mic.startRecording(); ... mic.read(signal, 0, TRANSFORM_SAMPLES); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "android-framework" group. To post to this group, send email to android-framework@googlegroups.com To unsubscribe from this group, send email to android-framework+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-framework?hl=en -~----------~----~----~----~------~----~------~--~---