Question

I am still new to android and currently I am working on a project, where I have to guide a person using audio signals. What I actually want to do is beep at a frequency only in one ear to tell the person to either turn left or turn right. When directing straight both ears will be beeping.

I found a number of examples here on how to generate the beep sound on android.

Here is an example of how to generate an arbitrary beep sound: Playing an arbitrary tone with Android

All I want is to play it only in one ear and shift between playback in either ears. Anybody has an idea of how this can be done?

Was it helpful?

Solution

You could make three different stereo soundclips where you have sound in left, right and both channels and then play them with SoundPool

OTHER TIPS

Looking at the docs you can control the output with AudioFormat. Not sure if this gives you the precision you need though.

final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
                sampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO,
                AudioFormat.ENCODING_PCM_16BIT, numSamples,
                AudioTrack.MODE_STATIC);

Change to this for left channel output:

final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
                sampleRate, AudioFormat.CHANNEL_OUT_FRONT_LEFT,
                AudioFormat.ENCODING_PCM_16BIT, numSamples,
                AudioTrack.MODE_STATIC);

Docs: http://developer.android.com/reference/android/media/AudioFormat.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top