2012-03-28 9 views
5

Ich habe Probleme beim Einfügen einer Mixereinheit in eine AUGraph, die ansonsten unter Mac OS und iOS funktioniert.Stille beim Hinzufügen von kAudioUnitSubType_MultiChannelMixer zu AUGraph

Mein Arbeits Diagramm sieht wie folgt aus:

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

Darüber hinaus bin ich der Lage, eine EQ-Einheit wie diese erfolgreich einzufügen:

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

Mein Ziel ist es, eine Mischeinheit einzufügen, aber Kein EQ, damit ich die Lautstärke meines Graphen unabhängig von der Systemlautstärke auf iOS steuern kann. Wie auch immer, wenn ich das Diagramm einstelle, scheint es zu Blick OK, aber alles, was ich bekomme, ist Stille.

Hier ist, was die Grafik wie folgt aussieht:

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

... und die Ausgabe von 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) 

Und schließlich der Code, der die Grafik mit Fehlerprüfung und iOS- Einrichtung ist spezifischer Code entfernt:

// 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); 
+0

also funktionierte das mit dem GraphicEQ anstelle des Mischers? Mit demselben Rückruf? Kannst du es ohne Callback funktionieren lassen? – hooleyhoop

Antwort

13

... und natürlich, gerade nachdem ich meine Frage hier gepostet habe, stolpere ich über die Antworten.

Es scheint, dass unter Mac OS zumindest die Eingangslautstärke eines Mixers auf 0,0 eingestellt ist. Manuelles Einstellen des Eingangsvolumens fixierte es richtig:

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

Für mich Einstellung der kAudioUnitScope_Output anstelle von KAudioUnitScope_Input. – user523234

+2

FYI: Ich musste Ein- und Ausgang setzen, um ein Signal zu erhalten. – hobotron

Verwandte Themen