现在,我通过从AVAudioUnitEQ记录它来保存文件。
[mainEQ installTapOnBus:0 bufferSize:0 format:[mainEQ outputFormatForBus:0] block:^(AVAudioPCMBuffer *buf, AVAudioTime *when){
if(!recordIsGoing){
[mainEQ removeTapOnBus:0];
}
else{
[writeAudioFile writeFromBuffer:buf error:nil];
// NSLog(@"%lld", writeAudioFile.length);
}
}];但是这种方法需要先前的文件回放。有办法保存混合文件而不播放吗?
UPD:我可以把AUAudioUnit.outputBusses接到mainEQ。现在的挑战是拿出数据,并希望这些数据将是我所需要的。
已解决:问题已由此答案 Can I use AVAudioEngine to read from a file, process with an audio unit and write to a file, faster than real-time?解决
发布于 2016-01-25 08:05:47
我认为您可以首先将数据转换为NSData并进行存储。当你拿回它的时候,你可以把它转换回来。
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:buf];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"yourfilename.dat"];
// Save it into file system
[data writeToFile:dataPath atomically:YES];https://stackoverflow.com/questions/34986453
复制相似问题