2013-09-16 3 views
0

Используя эти параметры записи, я могу получить AVAudioRecorder работать:IOS - AVAudioRecorder - запись с ADPCM или IMA

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?

+0

Я в настоящее время использую эту библиотеку, чтобы сделать кодировку: HTTP: //www.microchip. ком/с kc/ck763/Code/NetVox.X/Audio/audio_adpcm.c – stackOverFlew

+0

pastebin: http://pastebin.com/raw.php?i=8tfR8vdZ – stackOverFlew

ответ

0

1) Пожалуйста, убедитесь, что вы установили сеанс правильно для каждой записи (или) Воспроизведение (или) Оба (т.е. VOIP) следующим образом:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:nil]; 

2) Используйте следующий код, как это работает отлично для меня (я компресс низкого качества, как у меня есть приложение обмена сообщений):

NSDictionary *AudioSettings = [[NSDictionary alloc] initWithObjectsAndKeys: 
           [NSNumber numberWithInt:kAudioFormatAppleIMA4], AVFormatIDKey 
           , [NSNumber numberWithFloat:11025.00], AVSampleRateKey 
           , [NSNumber numberWithInt:1], AVNumberOfChannelsKey 
           , [NSNumber numberWithInt:11025], AVEncoderBitRateKey 
           , [NSNumber numberWithInt:8], AVLinearPCMBitDepthKey 
           , [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey 
           , [NSNumber numberWithInt:1], AVNumberOfChannelsKey 
           , nil 
           ]; 

с уважением Хайдер Сати

Смежные вопросы