Works great, just remember buffersize MUST be a power of 2. Also PCM_16BIT encoding is best. Also the bigger the buffersize the more time it takes to capture each burst. If you need more accuracy I would go with decreasing sample rate over increasing buffersize. Just keep in mind nyquist limits it to being able to analyze to half the sample rate and lower.
This library wants to see floats not integers like the ones provided by the buffer. So I just cycled through and mapped it correctly [for 16bit of course.]
- map(buffer[i], -32768, 32767, -1,1);
I had a lot of problems getting my app to launch properly without complaining about stop calls.
Then I tried this.
- @Override
- void onStop() {
- audioRecord.stop();
- audioRecord.release();
- super.onStop();
- }
Also the permissions are set in the PDE under Android>Sketch Permissions, only one you need for basic audio stuff like setting up a buffer and doing an FFT analysis are RECORD_AUDIO