小编mic*_*ben的帖子

使用单声道输入和立体声输出设置音频单元iOS

我正在尝试设置一个能够进行单声道输入和立体声输出的音频单元.打算通过左声道输出播放正弦波音调,并通过右声道输出定期播放不同的符号波.

我收到错误,

'NSInternalInconsistencyException', reason: ' Error initialing unit: -50;
Run Code Online (Sandbox Code Playgroud)

当我尝试在这里初始化我的音频单元时,

// Initialize audio unit
OSErr err = AudioUnitInitialize(self.ioUnit);
NSAssert1(err == noErr, @"Error initializing unit: %hd", err);
Run Code Online (Sandbox Code Playgroud)

我认为这与我如何设置音频单元有关,

// Audio component description
AudioComponentDescription desc;
desc.componentType          = kAudioUnitType_Output;
desc.componentSubType       = kAudioUnitSubType_RemoteIO;
desc.componentManufacturer  = kAudioUnitManufacturer_Apple;
desc.componentFlags         = 0;
desc.componentFlagsMask     = 0;

// Get component
AudioComponent inputComponent = AudioComponentFindNext(NULL, &desc);

// Get Audio units
AudioComponentInstanceNew(inputComponent, &ioUnit);

// Enable input, which disabled by default. Output enable by default
UInt32 enableInput = 1;
AudioUnitSetProperty(ioUnit,
                     kAudioOutputUnitProperty_EnableIO,
                     kAudioUnitScope_Input, …
Run Code Online (Sandbox Code Playgroud)

core-audio audiounit ios

5
推荐指数
1
解决办法
2507
查看次数

标签 统计

audiounit ×1

core-audio ×1

ios ×1