Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Real-time audio processing in Android

I'm trying to figure out how to write an app that can decode audio morse code on the fly. I found this document which explains how to record audio from the microphone in Android. What I'd like to know is whether it's possible to access the raw input from the microphone or whether it has to be written/read to a file.

Thanks.

like image 791
Jeremy Logan Avatar asked Feb 13 '10 09:02

Jeremy Logan


People also ask

What is AudioFlinger Android?

AudioFlinger. We know that AudioFlinger (Sometimes called AF) is the core of the entire audio system in Android. It is a system service which starts during boot and enables the platform for audio related use-cases in the following ways. 1. Provide the access interface for the upper layer for using Audio.

What are Android sound effects?

Introduction to Android Audio Effects Audio effects are used to enhance audibility of sound or to improve a specific audio feature. Android source code comes with few default audio effects like bassboost, equalizer, loudness enhancer which are then applied to the track using AudioFlinger while playing audio.


2 Answers

If you use MediaRecorder (the example, above) it will save compressed audio to a file.

If you use AudioRecord, you can get audio samples directly.

Yes, what you want to do should be possible.

like image 188
dmazzoni Avatar answered Sep 17 '22 13:09

dmazzoni


Using AudioRecord is overkill. Just check MediaRecorder.getMaxAmplitude() every 1000 milliseconds for loud noises versus silence.

If you really need to analyze the waveform, then yes you need AudioRecord. Get the raw data and calculate something like the root mean squared of the part of the raw bytes you are concerned with to get a sense of the volume.

But, why do all that when MediaRecorder.getMaxAmplitude() is so much easier to use.

see my code from this answer: this question

like image 42
gregm Avatar answered Sep 18 '22 13:09

gregm