Search code examples
androidaudiocallbackandroid-audiorecord

Android: an external hardware interrupt from Audio


My Android Java Application needs to use audio signal change as an external interrupt (ex: rising edge) to trigger other modules (ex:GPS, Bluetooth, etc.)

The closer solution is AudioReord.setRecordPositionUpdateListener.onPeriodicNotification() refer to [Android: AudioRecord Class Problem: Callback is never called

I am still looking for a external hardware interrupt from audio. Then, I can write a callback or listener function to get a trigger by a external hardware interrupt(ex: rising edge) from audio to enable other modules (ex:GPS, Bluetooth, etc.). This is similar like a microprocessor 8051 with an interrupt service routine. The 8051 can get a interrupt by a external interrupt from a audio level (ex: rising edge).

Is there any solution can implement a hardware external interrupt from audio ?


Solution

  • What you are asking for is simply not possible with Android: you can not have an interrupt service routine in user space, and there is no API available for edge detection of audio exposed to user space.

    Instead, you should record the audio, process it to detect a rising edge, and call your listener function when a rising edge is detected.