Axarydax
Axarydax

Reputation: 16603

Generate arbitrary beep in Android

as far as I know, there is no simple way in Android to generate a beep (equivalent to Console.Beep(int frequency, int length) in .NET). The only one that looked promising - ToneGenerator class, can generate only a limited selection of tones.

Do I have to generate a waveform by hand, push its data to AudioTrack and play it or is there a library or open source code that does it?

Upvotes: 2

Views: 3316

Answers (2)

Charles Chevrey
Charles Chevrey

Reputation: 11

I've been looking for the same. Found on this very site an answer:

  1. Calculate numbers for a waveform with a given frequency
  2. Convert the resulting array to PCM format
  3. Feed AudioTrack to play it back.

That's a good start.

I don't have the URL but you will find the code easily in FAQ looking for someone asking for "...arbitrary frequency"

Upvotes: 1

Related Questions