Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error: &setCategoryError];
  2. if (setCategoryError){
  3. NSLog(@"Error setting category! %@", [setCategoryError localizedDescription]);
  4. return NO;
  5. }
  6.  
  7.  
  8. NSError *error = NULL;
  9. NSMutableDictionary *options = [NSMutableDictionary dictionaryWithCapacity:5];
  10.  
  11. [options setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey]; //format
  12. [options setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; //sample rate
  13. [options setValue:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey]; //channels
  14. //encoder
  15. [options setValue:[NSNumber numberWithInt:AVAudioQualityHigh] forKey:AVEncoderAudioQualityKey]; //channels
  16. [options setValue:[NSNumber numberWithInt:16] forKey:AVEncoderBitDepthHintKey]; //channels
  17.  
  18. self.audiorecorder = [[AVAudioRecorder alloc] initWithURL:mediaURL settings:options error:&error];
  19. self.audiorecorder.meteringEnabled = YES;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement