View Full Version : generate arbitrary tones?
strnbrg
08-17-2009, 03:34 PM
Is there any way to make an android phone emit a sound of arbitrary frequency?
I'm looking at the various media facilities (in particular android.media.ToneGenerator) and don't see anything of that nature; I only see functions for generating the standard DTMF tones.
NKevin
01-18-2010, 05:07 PM
Is there any way to make an android phone emit a sound of arbitrary frequency?
I'm looking at the various media facilities (in particular android.media.ToneGenerator) and don't see anything of that nature; I only see functions for generating the standard DTMF tones.
I don't see an easy way.
You could use android.media.AudioTrack with setPlaybackRate and a "file" consisting of a simple sine wave, but this is an ugly hack to playback a single tone of arbitrary frequency. Better yet you could synthesize the audio files as needed (creating 8-bit PCM files programmatically is left as an exercise for the reader).
IMHO, the "cleanest" approach would be to dynamically generate the appropriate MIDI data, taking advantage of the built-in MIDI decoder.
exmachina
08-05-2010, 04:12 AM
Hi NKevin, you don't happen to know how to adress the "built-in MIDI decoder" in a java program?
/exmachina
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.