Created
April 3, 2012 19:57
-
-
Save bartolsthoorn/2295141 to your computer and use it in GitHub Desktop.
*** AudioUnitSetProperty (set EQ unit output stream format) error: -1073751081 FFFFFFCE prin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2012-04-03 21:49:21.266 MixerHost[73746:10703] The stereo stream format for the "guitar" mixer input bus: | |
2012-04-03 21:49:21.268 MixerHost[73746:10703] Sample Rate: 44100 | |
2012-04-03 21:49:21.269 MixerHost[73746:10703] Format ID: lpcm | |
2012-04-03 21:49:21.270 MixerHost[73746:10703] Format Flags: C2C | |
2012-04-03 21:49:21.270 MixerHost[73746:10703] Bytes per Packet: 4 | |
2012-04-03 21:49:21.272 MixerHost[73746:10703] Frames per Packet: 1 | |
2012-04-03 21:49:21.272 MixerHost[73746:10703] Bytes per Frame: 4 | |
2012-04-03 21:49:21.273 MixerHost[73746:10703] Channels per Frame: 2 | |
2012-04-03 21:49:21.274 MixerHost[73746:10703] Bits per Channel: 32 | |
2012-04-03 21:49:21.275 MixerHost[73746:10703] The mono stream format for the "beats" mixer input bus: | |
2012-04-03 21:49:21.275 MixerHost[73746:10703] Sample Rate: 44100 | |
2012-04-03 21:49:21.276 MixerHost[73746:10703] Format ID: lpcm | |
2012-04-03 21:49:21.277 MixerHost[73746:10703] Format Flags: C2C | |
2012-04-03 21:49:21.277 MixerHost[73746:10703] Bytes per Packet: 4 | |
2012-04-03 21:49:21.278 MixerHost[73746:10703] Frames per Packet: 1 | |
2012-04-03 21:49:21.284 MixerHost[73746:10703] Bytes per Frame: 4 | |
2012-04-03 21:49:21.285 MixerHost[73746:10703] Channels per Frame: 1 | |
2012-04-03 21:49:21.286 MixerHost[73746:10703] Bits per Channel: 32 | |
2012-04-03 21:49:21.287 MixerHost[73746:10703] readAudioFilesIntoMemory - file 0 | |
2012-04-03 21:49:21.388 MixerHost[73746:10703] Finished reading file 0 into memory | |
2012-04-03 21:49:21.389 MixerHost[73746:10703] readAudioFilesIntoMemory - file 1 | |
2012-04-03 21:49:21.487 MixerHost[73746:10703] Finished reading file 1 into memory | |
2012-04-03 21:49:21.488 MixerHost[73746:10703] Configuring and then initializing audio processing graph | |
2012-04-03 21:49:21.489 MixerHost[73746:10703] Adding nodes to audio processing graph | |
2012-04-03 21:49:21.508 MixerHost[73746:10703] Setting mixer unit input bus count to: 2 | |
2012-04-03 21:49:21.513 MixerHost[73746:10703] Setting kAudioUnitProperty_MaximumFramesPerSlice for mixer unit global scope | |
2012-04-03 21:49:21.526 MixerHost[73746:10703] Registering the render callback with mixer unit input bus 0 | |
2012-04-03 21:49:21.527 MixerHost[73746:10703] Registering the render callback with mixer unit input bus 1 | |
2012-04-03 21:49:21.528 MixerHost[73746:10703] Setting stereo stream format for mixer unit "guitar" input bus | |
2012-04-03 21:49:21.529 MixerHost[73746:10703] Setting mono stream format for mixer unit "beats" input bus | |
2012-04-03 21:49:21.530 MixerHost[73746:10703] Setting sample rate for mixer unit output scope | |
2012-04-03 21:49:21.530 MixerHost[73746:10703] Setting sample rate for EQ unit output scope | |
2012-04-03 21:49:21.531 MixerHost[73746:10703] *** AudioUnitSetProperty (set EQ unit output stream format) error: -1073751081 FFFFFFCE prin | |
2012-04-03 21:49:21.532 MixerHost[73746:10703] Bus 0 now on | |
2012-04-03 21:49:21.533 MixerHost[73746:10703] Bus 1 now on | |
2012-04-03 21:49:24.751 MixerHost[73746:10703] Starting audio processing graph | |
2012-04-03 21:49:24.752 MixerHost[73746:10703] *** AUGraphStart error: -1073750905 FF000000 XâEÿ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark - | |
#pragma mark Audio processing graph setup | |
// This method performs all the work needed to set up the audio processing graph: | |
// 1. Instantiate and open an audio processing graph | |
// 2. Obtain the audio unit nodes for the graph | |
// 3. Configure the Multichannel Mixer unit | |
// * specify the number of input buses | |
// * specify the output sample rate | |
// * specify the maximum frames-per-slice | |
// 4. Initialize the audio processing graph | |
- (void) configureAndInitializeAudioProcessingGraph { | |
NSLog (@"Configuring and then initializing audio processing graph"); | |
OSStatus result = noErr; | |
//............................................................................ | |
// Create a new audio processing graph. | |
result = NewAUGraph (&processingGraph); | |
if (noErr != result) {[self printErrorMessage: @"NewAUGraph" withStatus: result]; return;} | |
//............................................................................ | |
// Specify the audio unit component descriptions for the audio units to be | |
// added to the graph. | |
// I/O unit | |
AudioComponentDescription iOUnitDescription; | |
iOUnitDescription.componentType = kAudioUnitType_Output; | |
iOUnitDescription.componentSubType = kAudioUnitSubType_RemoteIO; | |
iOUnitDescription.componentManufacturer = kAudioUnitManufacturer_Apple; | |
iOUnitDescription.componentFlags = 0; | |
iOUnitDescription.componentFlagsMask = 0; | |
// EQ unit | |
AudioComponentDescription EQUnitDescription; | |
EQUnitDescription.componentType = kAudioUnitType_Effect; | |
EQUnitDescription.componentSubType = kAudioUnitSubType_NBandEQ; | |
EQUnitDescription.componentManufacturer = kAudioUnitManufacturer_Apple; | |
EQUnitDescription.componentFlags = 0; | |
EQUnitDescription.componentFlagsMask = 0; | |
// Multichannel mixer unit | |
AudioComponentDescription MixerUnitDescription; | |
MixerUnitDescription.componentType = kAudioUnitType_Mixer; | |
MixerUnitDescription.componentSubType = kAudioUnitSubType_MultiChannelMixer; | |
MixerUnitDescription.componentManufacturer = kAudioUnitManufacturer_Apple; | |
MixerUnitDescription.componentFlags = 0; | |
MixerUnitDescription.componentFlagsMask = 0; | |
//............................................................................ | |
// Add nodes to the audio processing graph. | |
NSLog (@"Adding nodes to audio processing graph"); | |
AUNode iONode; // node for I/O unit | |
AUNode mixerNode; // node for Multichannel Mixer unit | |
AUNode EQNode; | |
// Add the nodes to the audio processing graph | |
// I/O! | |
result = AUGraphAddNode ( | |
processingGraph, | |
&iOUnitDescription, | |
&iONode); | |
if (noErr != result) {[self printErrorMessage: @"AUGraphNewNode failed for I/O unit" withStatus: result]; return;} | |
// EQ! | |
result = AUGraphAddNode ( | |
processingGraph, | |
&EQUnitDescription, | |
&EQNode | |
); | |
if (noErr != result) {[self printErrorMessage: @"AUGraphNewNode failed for EQ unit" withStatus: result]; return;} | |
// MIXING! | |
result = AUGraphAddNode ( | |
processingGraph, | |
&MixerUnitDescription, | |
&mixerNode | |
); | |
if (noErr != result) {[self printErrorMessage: @"AUGraphNewNode failed for Mixer unit" withStatus: result]; return;} | |
//............................................................................ | |
// Open the audio processing graph | |
// Following this call, the audio units are instantiated but not initialized | |
// (no resource allocation occurs and the audio units are not in a state to | |
// process audio). | |
result = AUGraphOpen (processingGraph); | |
if (noErr != result) {[self printErrorMessage: @"AUGraphOpen" withStatus: result]; return;} | |
//............................................................................ | |
// Obtain the mixer unit instance from its corresponding node. | |
result = AUGraphNodeInfo ( | |
processingGraph, | |
mixerNode, | |
NULL, | |
&mixerUnit | |
); | |
if (noErr != result) {[self printErrorMessage: @"AUGraphNodeInfo" withStatus: result]; return;} | |
//............................................................................ | |
// Multichannel Mixer unit Setup | |
UInt32 busCount = 2; // bus count for mixer unit input | |
UInt32 guitarBus = 0; // mixer unit bus 0 will be stereo and will take the guitar sound | |
UInt32 beatsBus = 1; // mixer unit bus 1 will be mono and will take the beats sound | |
NSLog (@"Setting mixer unit input bus count to: %lu", busCount); | |
result = AudioUnitSetProperty ( | |
mixerUnit, | |
kAudioUnitProperty_ElementCount, | |
kAudioUnitScope_Input, | |
0, | |
&busCount, | |
sizeof (busCount) | |
); | |
if (noErr != result) {[self printErrorMessage: @"AudioUnitSetProperty (set mixer unit bus count)" withStatus: result]; return;} | |
NSLog (@"Setting kAudioUnitProperty_MaximumFramesPerSlice for mixer unit global scope"); | |
// Increase the maximum frames per slice allows the mixer unit to accommodate the | |
// larger slice size used when the screen is locked. | |
UInt32 maximumFramesPerSlice = 4096; | |
result = AudioUnitSetProperty ( | |
mixerUnit, | |
kAudioUnitProperty_MaximumFramesPerSlice, | |
kAudioUnitScope_Global, | |
0, | |
&maximumFramesPerSlice, | |
sizeof (maximumFramesPerSlice) | |
); | |
if (noErr != result) {[self printErrorMessage: @"AudioUnitSetProperty (set mixer unit input stream format)" withStatus: result]; return;} | |
// Attach the input render callback and context to each input bus | |
for (UInt16 busNumber = 0; busNumber < busCount; ++busNumber) { | |
// Setup the struture that contains the input render callback | |
AURenderCallbackStruct inputCallbackStruct; | |
inputCallbackStruct.inputProc = &inputRenderCallback; | |
inputCallbackStruct.inputProcRefCon = soundStructArray; | |
NSLog (@"Registering the render callback with mixer unit input bus %u", busNumber); | |
// Set a callback for the specified node's specified input | |
result = AUGraphSetNodeInputCallback ( | |
processingGraph, | |
mixerNode, | |
busNumber, | |
&inputCallbackStruct | |
); | |
if (noErr != result) {[self printErrorMessage: @"AUGraphSetNodeInputCallback" withStatus: result]; return;} | |
} | |
NSLog (@"Setting stereo stream format for mixer unit \"guitar\" input bus"); | |
result = AudioUnitSetProperty ( | |
mixerUnit, | |
kAudioUnitProperty_StreamFormat, | |
kAudioUnitScope_Input, | |
guitarBus, | |
&stereoStreamFormat, | |
sizeof (stereoStreamFormat) | |
); | |
if (noErr != result) {[self printErrorMessage: @"AudioUnitSetProperty (set mixer unit guitar input bus stream format)" withStatus: result];return;} | |
NSLog (@"Setting mono stream format for mixer unit \"beats\" input bus"); | |
result = AudioUnitSetProperty ( | |
mixerUnit, | |
kAudioUnitProperty_StreamFormat, | |
kAudioUnitScope_Input, | |
beatsBus, | |
&monoStreamFormat, | |
sizeof (monoStreamFormat) | |
); | |
if (noErr != result) {[self printErrorMessage: @"AudioUnitSetProperty (set mixer unit beats input bus stream format)" withStatus: result];return;} | |
NSLog (@"Setting sample rate for mixer unit output scope"); | |
// Set the mixer unit's output sample rate format. This is the only aspect of the output stream | |
// format that must be explicitly set. | |
result = AudioUnitSetProperty ( | |
mixerUnit, | |
kAudioUnitProperty_SampleRate, | |
kAudioUnitScope_Output, | |
0, | |
&graphSampleRate, | |
sizeof (graphSampleRate) | |
); | |
if (noErr != result) {[self printErrorMessage: @"AudioUnitSetProperty (set mixer unit output stream format)" withStatus: result]; return;} | |
NSLog (@"Setting sample rate for EQ unit output scope"); | |
result = AudioUnitSetProperty ( | |
EQUnit, | |
kAudioUnitProperty_SampleRate, | |
kAudioUnitScope_Output, | |
0, | |
&graphSampleRate, | |
sizeof (graphSampleRate) | |
); | |
if (noErr != result) {[self printErrorMessage: @"AudioUnitSetProperty (set EQ unit output stream format)" withStatus: result]; return;} | |
//............................................................................ | |
// Connect the nodes of the audio processing graph | |
NSLog (@"Connecting the mixer output to the input of (before: the I/O unit output element)-, EQ!!"); | |
result = AUGraphConnectNodeInput ( | |
processingGraph, | |
mixerNode, // source node | |
0, // source node output bus number | |
EQNode, // destination node | |
0 // desintation node input bus number | |
); | |
if (noErr != result) {[self printErrorMessage: @"AUGraphConnectNodeInput" withStatus: result]; return;} | |
result = AUGraphConnectNodeInput ( | |
processingGraph, | |
EQNode, // source node | |
0, // source node output bus number | |
iONode, // destination node | |
0 // desintation node input bus number | |
); | |
if (noErr != result) {[self printErrorMessage: @"AUGraphConnectNodeInput" withStatus: result]; return;} | |
//............................................................................ | |
// Initialize audio processing graph | |
// Diagnostic code | |
// Call CAShow if you want to look at the state of the audio processing | |
// graph. | |
NSLog (@"Audio processing graph state immediately before initializing it:"); | |
CAShow (processingGraph); | |
NSLog (@"Initializing the audio processing graph"); | |
// Initialize the audio processing graph, configure audio data stream formats for | |
// each input and output, and validate the connections between audio units. | |
result = AUGraphInitialize (processingGraph); | |
if (noErr != result) {[self printErrorMessage: @"AUGraphInitialize" withStatus: result]; return;} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment