Book Image

Android NDK: Beginner's Guide

By : Sylvain Ratabouil
Book Image

Android NDK: Beginner's Guide

By: Sylvain Ratabouil

Overview of this book

Table of Contents (18 chapters)
Android NDK Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Recording sounds


Android devices are all about interactions. Interactions can come not only from touches and sensors, but also from audio input. Most Android devices provide a microphone to record sound and allow an application such as the Android desktop search to offer vocal features to record queries.

If the sound input is available, OpenSL ES gives native access to the sound recorder. It collaborates with a buffer queue to take data from the input device and fill an output sound buffer from it. The setup is pretty similar to what has been done with AudioPlayer, except that data source and data sink are permuted.

Have a go hero – recording and playing a sound

To discover how recording works, record a sound when an application starts and play it when it has finished recording. Turning SoundManager into a recorder can be done in four steps:

  1. Using status startSoundRecorder() to initialize the sound recorder. Invoke it right after startSoundPlayer().

  2. With void recordSound(), start recording a...