cannyboy
cannyboy

Reputation: 24426

How to play a tone on iPhone

Is it possible to easily play a tone, or series of tones on the iPhone (like morse code, beep beeeeeep beep)?

Is there any sample code out there that would point me in the right direction?

(I remember on the Commodore 64 it was about 4 lines of code !)

Upvotes: 1

Views: 3153

Answers (2)

micmoo
micmoo

Reputation: 6081

You can use:

#import <AudioToolbox/AudioToolbox.h>
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);

I'm pretty sure that do what you want it to do just fine. MAKE SURE you link to the AudioToolbox framework first!

Upvotes: 3

Andrew Pouliot
Andrew Pouliot

Reputation: 5421

  1. Think different. Use an audio file. :) Lots of easy ways to play those.

  2. Look at the AudioQueue library in AudioToolbox.framework. AudioQueueNewOutput might be what you're looking for, though I haven't used these in a while. You can provide your audio data in the callback.

Upvotes: 2

Related Questions