IPhone AVCaptureDeviceInput How to set the quality of audio capture?

The following code works fine (some checks and code fixed) at level 44100 of depth 2, which is apparently the default. Since this interface is useful but not well documented, does anyone know how to change the default quality?

audioCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio]; captureSession = [[AVCaptureSession alloc] init]; audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioCaptureDevice error:&error]; [captureSession addInput:audioInput]; audioOutput = [[AVCaptureAudioDataOutput alloc] init]; [audioOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()]; [captureSession addOutput:audioOutput]; 
+2
source share
1 answer

That should do the trick.

More here

http://developer.apple.com/library/ios/#documentation/AudioToolbox/Reference/AudioSessionServicesReference/Reference/reference.html

  union { OSStatus propertyResult; char a[4]; } u; Float64 F64sampleRate = 8192.0; Float64 F64realSampleRate = 0; UInt32 F64datasize = 8; u.propertyResult = AudioSessionSetProperty ( kAudioSessionProperty_PreferredHardwareSampleRate ,sizeof(F64sampleRate) , &F64sampleRate ); NSLog(@"Set Error Set Sample Rate %ld %lx %c%c%c%c",u.propertyResult,u.propertyResult,ua[3],ua[2],ua[1],ua[0]); u.propertyResult = AudioSessionGetProperty ( kAudioSessionProperty_CurrentHardwareSampleRate , &F64datasize, &F64realSampleRate ); NSLog(@"Get Error Current Sample Rate %ld %lx %c%c%c%c",u.propertyResult,u.propertyResult,ua[3],ua[2],ua[1],ua[0]); NSLog(@"Sample Rate is %f",F64realSampleRate); 
+1
source

All Articles