Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get iPhone OS 3.1 muffled keyboard sound?

I have added the iPhone's Tock sound to my own custom keyboard like this:

NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:@"Tock" ofType:@"aiff"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound(soundID);
// we don't dispose of the sound to keep the sound in the cache for the next time
//AudioServicesDisposeSystemSoundID(soundID);

In iPhone OS 3.1, however, the keyboard Tock sound has been muffled, e.g. is much more silent than other sounds and than it was in 3.0. My method's sound is still very loud and at the maximum volume. How could I get the same volume as the iPhone's default keyboard?

By the way, the Tock sound in Twitterrific is muffled appropriately.

Cheers

MrMage

like image 783
MrMage Avatar asked Oct 03 '09 15:10

MrMage


People also ask

Why is my keyboard Sound so low on my iPhone?

Go into your iPhone Settings > Sounds & Haptics > Turn off Keyboard Clicks and switch back on after about 10 seconds. Let us know if you're still experiencing the same behavior.


1 Answers

Using 0x450 as the SystemSoundID works for me at the correct volume - note that it doesn't respect the keyboard clicks on/off preference.

I'm not sure how portable this is - it works for me on the simulator and on an iPod Touch 3rd gen. I suspect it works on all devices but could change without notice in a software update.

I got this number by setting a breakpoint on AudioServicesPlaySystemSound and pressing a normal keyboard key - the first assembly instruction copies the SystemSoundID into a register, so you can see it in the Registers view in the debugger.

like image 116
Sam McCall Avatar answered Oct 17 '22 08:10

Sam McCall