Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AvAudioRecorder settings configuration help

I want to record a .caf file then send it as a mail attachment and pick it up on my mac. The problem is the caf file is not playable outside my app, only in my app. What setting do i have to use to play the .caf file whit Quicktime on my mac here are my setting. I save the audio file in the iphone Documents directory.

 NSDictionary *settings =[NSDictionary dictionaryWithObjectsAndKeys:
                            [NSNumber numberWithInt: kAudioFormatAppleLossless],    AVFormatIDKey,
                            [NSNumber numberWithFloat: 44100.0],                 AVSampleRateKey,
                            [NSNumber numberWithInt: 2],                         AVNumberOfChannelsKey,
                            [NSNumber numberWithInt:128000],                     AVEncoderBitRateKey,
                            [NSNumber numberWithInt: AVAudioQualityMax],         AVEncoderAudioQualityKey,
                          nil];

I am using a external platform to send the attachment, i am sending it to a web server converted in base

        NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSString *filePath2 = [documentsDirectory stringByAppendingPathComponent:@"VoiceMail.caf"];
    attachment1.FileData = [serv convertFileToB64String:filePath2 fileName:@"VoiceMail.caf"];
    attachment1.FileName = @"VoiceMail.caf";
    message.Attachments = [[NSMutableArray alloc] initWithObjects:attachment1, nil];
like image 444
Radu Avatar asked Aug 05 '11 12:08

Radu


Video Answer


1 Answers

Try this setting, this should work.

   NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];

    [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey]; 
    [recordSetting setValue:[NSNumber numberWithFloat:9500.0] forKey:AVSampleRateKey]; 
    [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
    [recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityHigh] forKey:AVEncoderAudioQualityKey];
    [recordSetting setValue :[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
    [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
    [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
like image 111
Baby Groot Avatar answered Oct 03 '22 05:10

Baby Groot