iOSでシステムサウンドとして使用出来るファイルは、以下を満たす必要がある。
- 長さは30秒以内
- フォーマットは、リニアPCM or IMA4(IMA/ADPCM)
- ファイル形式は、".caf" or ".aif" or ".wav"
参考:公式リファレンス System Sound Services Reference
例:sound.wavというファイルを鳴らす場合(※ AudioToolbox.frameworkが必要)
# import <AudioToolbox/AudioToolbox.h>
SytemSoundID *mBeep;
// システムサウンド生成
NSString *path = [[NSBundle mainBundle] pathForResource:@"sound" ofType:@"wav"];
NSURL *url = [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)url, &mBeep);
// 再生
AudioServicesPlaySystemSound(mBeep);
// 破棄
AudioServicesDisposeSystemSoundID(mBeep);