我正在尝试以越来越高的频率背靠背播放两个音频文件(点击和咔哒声)。它在第一秒内按需要工作,然后声音同时开始播放。知道我在这里做错了什么吗?
static float clickClackDelay = 1.0;
- (void)runClickClackTimer {
clickURL = [[NSBundle mainBundle] URLForResource:@"click" withExtension:@"wav"];
clackURL = [[NSBundle mainBundle] URLForResource:@"clack" withExtension:@"wav"];
avClick = [[AVAudioPlayer alloc] initWithContentsOfURL:clickURL error:nil];
avClack = [[AVAudioPlayer alloc] initWithContentsOfURL:clackURL error:nil];
clickClack = [NSTimer scheduledTimerWithTimeInterval:clickClackDelay
target:self
selector:@selector(runClickClackTimer)
userInfo:nil
repeats:NO];
[avClick play];
sleep(clickClackDelay);
[avClack play];
sleep(clickClackDelay);
NSLog(@"Play sound every %.2f", clickClackDelay);
clickClackDelay -= 0.01;
}