1) 我想做一个像会说话的汤姆这样的 iPhone 应用。我已经从 :--> https://github.com/zoul/Finch 站点下载了示例示例。它与给定的音频文件播放良好。但我想用音高效果播放我录制的文件。我的问题是当我传递我录制的文件(使用 AVAudioRecorder 录制)时,错误就像“读取声音数据失败”。请帮助我为什么会发生此错误。使用 AVAudioRecorded 录制文件时是否有任何文件格式问题或任何设置问题?我的设置代码在这里....
NSArray *dirPaths;
NSString *docsDir;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
NSString *soundFilePath = [docsDir stringByAppendingPathComponent:@"sound.caf"];
soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt: AVAudioQualityMedium],AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],AVNumberOfChannelsKey,
[NSNumber numberWithFloat: 44100.0],AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatLinearPCM], AVFormatIDKey,
[NSNumber numberWithBool:YES],AVLinearPCMIsBigEndianKey,
nil];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL settings:recordSettings error:&error];
if(error)
{
NSLog(@"error in AudioRecorder Initializing...: %@", [error localizedDescription]);
}
else
{
//audioRecorder.meteringEnabled = YES;
[audioRecorder prepareToRecord];
}
2)我从http://dirac.dspdimension.com/Dirac3_Technology_Home_Page/Dirac3_Technology.html 站点找到了另一个示例。在这个例子中,我可以播放我录制的文件,但是干扰太多了。播放后声音一直在播放,无法停止。有时当音调改变时应用程序崩溃。在这个例子中,他们使用“libDIRAC_iOS4-fat.a”库。那么我们可以使用这个库吗?以及我们如何才能停止播放声音。
有什么方法可以轻松使用吗?
提前致谢。