これらの録音設定を使用して、AVAudioRecorder を機能させることができます。
recordSetting = [NSDictionary dictionaryWithObjectsAndKeys:
// [NSNumber numberWithFloat:2048.0f],AVSampleRateKey,
// [NSNumber numberWithInt:1],AVNumberOfChannelsKey,
// [NSNumber numberWithInt:8],AVLinearPCMBitDepthKey,
[NSNumber numberWithInt:kAudioFormatLinearPCM],AVFormatIDKey,
// [NSNumber numberWithBool:NO], AVLinearPCMIsFloatKey,
// [NSNumber numberWithBool:0], AVLinearPCMIsBigEndianKey,
// [NSNumber numberWithBool:NO], AVLinearPCMIsNonInterleaved,
// [NSNumber numberWithInt:256], AVEncoderBitRateKey,
[NSData data], AVChannelLayoutKey, nil];
recorder = [[ AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:&err];
if(!recorder){
NSLog(@"recorder: %@ %d %@", [err domain], [err code], [[err userInfo] description]);
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle: @"Warning"
message: [err localizedDescription]
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
return;
}
これを変更するとすぐに:
[NSNumber numberWithInt:kAudioFormatLinearPCM],AVFormatIDKey,
これに:
[NSNumber numberWithInt:kAudioFormatAppleIMA4],AVFormatIDKey,
次のエラーが表示されます。
recorder: NSOSStatusErrorDomain 1718449215 {
}
つまり、オーディオ形式はサポートされていません。kAudioFormatUnsupportedDataFormatError
ADPCM または IMA を AVAudioRecorder と連携させるにはどうすればよいですか?