Search code examples
androidaudioaudio-recording

How to record sound in Android app


I'm developing an Android application, a part of this app is a simple xylophone, what i must do is the implementation of a function, that records the xylophone sounds when the user press a button.

When a user press a button, like do, re mi, etc the sounds is played using a mp3 saved in raw folder...

1) Is it possible do this ? 2) Can someone explain how i can "capture" the sound and record it in sd card? 3) Is it possible implements "record" "play" "stop" "reproduce" function ?


Solution

  • Without root, Android can't record internally (or say 'digitally') what is coming out of the speaker or the headphones. The reason might be copyright issues, so that it is not possible to produce digital copies of what is played back over the Android device.

    Of course, you can record it with the internal microphone(s) if the signal is loud enough, but the loss of quality is significant. Additionally, you have background noise and the tapping noise of the finger tips of the user on your xylophone.

    The best solution would be that you mix the samples corresponding to the keys programmatically and send the result to the speaker and at the same time into a sound file. Complicated, but optimal.