2

以下代码在 44100 深度 2 处工作正常(一些检查和代码被消除),这似乎是默认值。由于此界面可用,但没有很好地记录,有人知道如何更改默认质量吗?

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];
4

1 回答 1

1

这应该可以解决问题。

更多在这里

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,u.a[3],u.a[2],u.a[1],u.a[0]);

 u.propertyResult = AudioSessionGetProperty ( kAudioSessionProperty_CurrentHardwareSampleRate , &F64datasize, &F64realSampleRate );
 NSLog(@"Get Error Current Sample Rate %ld %lx %c%c%c%c",u.propertyResult,u.propertyResult,u.a[3],u.a[2],u.a[1],u.a[0]);
 NSLog(@"Sample Rate is %f",F64realSampleRate);
于 2011-11-01T15:44:46.757 回答