我正在通过AudioKit(版本4.5.3)在iOS上构建一个APP,我发现AKTimePitch类不适用于我,这是我的代码(objective-c xcode 10):
(IBAction)startButton:(id)sender {
NSURL *url = [[NSBundle mainBundle] URLForResource:@"burncalory" withExtension:@"m4a"];
AKAudioFile *file = [[AKAudioFile alloc] initForReading:url error:nil];
AKAudioPlayer *player = [[AKAudioPlayer alloc] initWithFile:file looping:NO lazyBuffering:YES error:nil completionHandler:^{
NSLog(@"Finished!");
}];
AKTimePitch *akTimePitch = [[AKTimePitch alloc] init:player rate:2.0 pitch:1600 overlap:8];
AudioKit.output = akTimePitch;
[akTimePitch start];
[AudioKit startAndReturnError:nil];
[player playFrom:0.0];
}
我检查了操场(4.5.3),“时间拉伸和音调转换”示例效果很好。
我在使用AKTimePitch的代码中有问题吗?还是我的音频文件example.m4a
有问题?顺便说一下,AKAudioPlayer可以加载并播放此音频文件。
答案 0 :(得分:1)
经过一些测试,我发现init
方法中的参数无效,但是在akTimePitch.pitch=1600
之前添加[player playFrom:0.0]
之后,AKTimePitch效果就可以了!我不知道为什么AKTimePitch *akTimePitch = [[AKTimePitch alloc] init:player rate:2.0 pitch:1600 overlap:8];
不能正常工作...