MultiChannelMixer添加到AUGraph时保持静音

MultiChannelMixer添加到AUGraph时保持静音

本文介绍了将kAudioUnitSubType_MultiChannelMixer添加到AUGraph时保持静音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将调音台插入AUGraph,否则在Mac OS和iOS上都可以正常工作.

I'm having trouble inserting a mixer unit into an AUGraph that otherwise works OK on both Mac OS and iOS.

我的工作图如下:

(My Audio render callback) <- [Format converter] <- [DefaultOutput]

此外,我能够像这样成功地插入一个EQ单元:

In addition, I'm able to successfully insert an EQ unit like this:

(My Audio render callback) <- [Format converter] <- [GraphicEQ] <- [DefaultOutput]

我的目标是插入一个混音器单元,但不添加EQ,因此我可以独立于iOS上的系统音量来控制图形的音量.但是,当我设置图表时,看起来看起来不错,但是我得到的只是寂静.

My goal is to insert a mixer unit but no EQ so I can control the volume of my graph independently of the system volume on iOS. However, when I set up the graph it seems to look OK, but all I get is silence.

图形如下:

(My Audio render callback) <- [Format converter] <- [MultiChannelMixer] <- [DefaultOutput]

...以及CAShow的输出:

…and the output of CAShow:

AudioUnitGraph 0x397000:
  Member Nodes:
    node 1: 'auou' 'def ' 'appl', instance 0x8039704d O I
    node 2: 'aumx' 'mcmx' 'appl', instance 0x8039704e O I
    node 3: 'aufc' 'conv' 'appl', instance 0x8039704f O I
  Connections:
    node   3 bus   0 => node   2 bus   0  [ 2 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
    node   2 bus   0 => node   1 bus   0  [ 2 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
  Input Callbacks:
    {0x100035d90, 0x10037cd60} => node   3 bus   0  [2 ch, 44100 Hz]
  CurrentState:
    mLastUpdateError=0, eventsToProcess=F, isRunning=T (1)

最后,删除了通过错误检查设置图表的代码,并删除了iOS专用代码:

And, finally, the code that's setting up the graph with error-checking and iOS-specific code removed:

// A description of the output device we're looking for.
AudioComponentDescription outputDescription;
outputDescription.componentType = kAudioUnitType_Output;
outputDescription.componentSubType = kAudioUnitSubType_DefaultOutput;
outputDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
outputDescription.componentFlags = 0;
outputDescription.componentFlagsMask = 0;

// A description of the mixer unit
AudioComponentDescription mixerDescription;
mixerDescription.componentType = kAudioUnitType_Mixer;
mixerDescription.componentSubType = kAudioUnitSubType_MultiChannelMixer;
mixerDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
mixerDescription.componentFlags = 0;
mixerDescription.componentFlagsMask = 0;

// A description for the libspotify -> standard PCM device
AudioComponentDescription converterDescription;
converterDescription.componentType = kAudioUnitType_FormatConverter;
converterDescription.componentSubType = kAudioUnitSubType_AUConverter;
converterDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
converterDescription.componentFlags = 0;
converterDescription.componentFlagsMask = 0;

// Create an AUGraph
OSErr status = NewAUGraph(&audioProcessingGraph);

// Open the graph. AudioUnits are open but not initialized (no resource allocation occurs here)
AUGraphOpen(audioProcessingGraph);

// Add audio output...
status = AUGraphAddNode(audioProcessingGraph, &outputDescription, &outputNode);

// Add mixer
status = AUGraphAddNode(audioProcessingGraph, &mixerDescription, &mixerNode);

// Get mixer unit so we can change volume etc
status = AUGraphNodeInfo(audioProcessingGraph, mixerNode, NULL, &mixerUnit);

// Set mixer bus count
UInt32 busCount = 1;
status = AudioUnitSetProperty(mixerUnit, kAudioUnitProperty_ElementCount, kAudioUnitScope_Input, 0, &busCount, sizeof(busCount));

// Create PCM converter
status = AUGraphAddNode(audioProcessingGraph, &converterDescription, &inputConverterNode);

// Connect converter to mixer
status = AUGraphConnectNodeInput(audioProcessingGraph, inputConverterNode, 0, mixerNode, 0);

// Connect mixer to output
status = AUGraphConnectNodeInput(audioProcessingGraph, mixerNode, 0, outputNode, 0);

// Set render callback
AURenderCallbackStruct rcbs;
rcbs.inputProc = AudioUnitRenderDelegateCallback;
rcbs.inputProcRefCon = (__bridge void *)(self);

status = AUGraphSetNodeInputCallback(audioProcessingGraph, inputConverterNode, 0, &rcbs);

// Init Queue
status = AUGraphInitialize(audioProcessingGraph);

AUGraphUpdate(audioProcessingGraph, NULL);
AUGraphStart(audioProcessingGraph);

推荐答案

...,当然,在将问题发布到这里之后,我偶然发现了答案.

…and of course just after posting my question here, I stumble upon the answer.

看来,至少在Mac OS上,调音台的输入音量默认为0.0.手动设置输入音量,将其固定在正确的位置:

It seems that, on Mac OS at least, the input volume on a mixer defaults to 0.0. Manually setting the input volume fixed it right up:

status = AudioUnitSetParameter(mixerUnit, kMultiChannelMixerParam_Volume, kAudioUnitScope_Input, 0, 1.0, 0);

这篇关于将kAudioUnitSubType_MultiChannelMixer添加到AUGraph时保持静音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 01:00