IOS: Sound generation on iPad with Hz?

Is there an API in one of the iOS layers that I can use to generate a tone by simply specifying it with Hertz. What I want to do is generate a DTMF tone. This link explains how DTMF tones consist of 2 tones:

http://en.wikipedia.org/wiki/Telephone_keypad

This basically means that I need to reproduce 2 tones at the same time ...

So, something like this exists:

SomeCleverPlayerAPI (697, 1336);

If you spent all this time and were looking for a lot of ways to play a sound file, but did not know anything about how to generate a specific tone. Does anyone know please ...

+7
source share
2 answers

Check out the AU API (AudioUnit). It is pretty low level, but it can do what you want. A good introduction (which probably already gives you what you need) can be found here:

http://cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html

+4
source

There is no iOS API for this audio synthesis.

But you can use the Audio Queue or Audio Unit RemoteIO API to play the original sound samples, generate an array of samples from 2 sine waves summarized (say, 44100 samples in 1 second), and then copy the results in the sound callback (1024 samples or any queries callback at the same time).

See Apple aurioTouch and SpeakHere sample applications for using these audio APIs.

Samples can be generated with something simple:

sample[i] = (short int)(v1*sinf(2.0*pi*i*f1/sr) + v2*sinf(2.0*pi*i*f2/sr)); 

where sr is the sampling frequency, f1 and f1 are 2 frequencies, and v1 + v2 is the sum less than 32767.0. You can add rounding or noise smoothing to get cleaner results.

Beware of clicking if the shapes you create do not shrink to zero at the ends.

+3
source

All Articles