我有一个自产生的DTMF声音(与一个wav头)产生的程序,我希望能够快速播放,事实上,只要用户触摸一个按钮。这个DTMF声音必须无限地播放/循环,直到我停止为止。其他一些声音必须能够同时播放。
我对音频编程非常陌生,我测试了很多方法,现在我迷失了方向。
我怎样才能做到这一点?
需要:
发布于 2011-09-28 10:53:14
AVAudioPlayer
--如果你能忍受一些延迟,OpenAL (例如芬奇) --如果你真的需要尽可能低的延迟。
发布于 2011-09-28 11:02:55
我使用已经存在的.wav文件。我可以轻松地演奏。
用于运行以下代码。包括AudioToolbox框架。
写入.h文件#import <AudioToolbox/AudioToolbox.h>
写入.m文件
-(IBAction)startSound{
//Get the filename of the sound file:
NSString *path = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], @"/sound1.wav"];
//declare a system sound
SystemSoundID soundID;
//Get a URL for the sound file
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
//Use audio sevices to create the sound
AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
//Use audio services to play the sound
[self sound];
timer =[ [NSTimer scheduledTimerWithTimeInterval:2.1 target:self selector:@selector(sound) userInfo:nil repeats:YES]retain];
}
https://stackoverflow.com/questions/7573922
复制相似问题