Multiple Newbie CoreAudio AU and AUHAL problems
Multiple Newbie CoreAudio AU and AUHAL problems
- Subject: Multiple Newbie CoreAudio AU and AUHAL problems
- From: Chilton Webb <email@hidden>
- Date: Mon, 7 Jun 2004 23:47:04 -0500
Hi,
Here is my one test function. It compiles fine. To me, most everything
looks like it is in its place. But it does not do what I want (which is
play audio through from mic to speaker, with an AU messing with the
audio as it passes through). Nor does it do much of anything, due to
errors I'm getting back when I try to enable input. If you get a
minute, feel free to point out any or all of the various errors that
surely haunt this code.
Thank you,
-Chilton
(who has read the manuals, and is now thoroughly confused)
-----------------------
void testit (void) {
ComponentDescription desc;
desc.componentType = kAudioUnitType_Effect; //'aufx'
desc.componentSubType = kAudioUnitSubType_Delay;
desc.componentManufacturer = kAudioUnitManufacturer_Apple; //'appl'
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
Component auComp = FindNextComponent (NULL, &desc);
if (auComp == NULL) {
fprintf (stderr, "didn't find the component\n");
return;
}
AudioUnit delayUnit;
OSErr result = OpenAComponent (auComp, &delayUnit);
if (result) {
fprintf (stderr, "Error:%d opening AU\n", result);
return;
}
fprintf (stderr, "Okay, we have our component...\n");
{
OSStatus err = noErr;
AudioUnit AUHAL;
UInt32 enableIO = 1;
err = OpenDefaultAudioOutput(&AUHAL);
err = AudioUnitInitialize(AUHAL);
err = AudioUnitSetProperty(AUHAL, kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input,1, &enableIO, enableIO);
/* 1) According to the RTF...
"To receive input, the client should first enable input on AUHAL."
But here I get kAudioUnitErr_InvalidProperty. Why?
*/
err = AudioUnitInitialize(delayUnit);
// 2) Do I need to initialize my delayUnit here?
{
// 3) hook up AUHAL's input to our filter
struct AudioUnitConnection connection;
OSStatus err;
err = connectAUToInput(delayUnit,AUHAL);
/* I'm trying to feed input into my filter. So here I create a
connection
between the client output of AUHAL (1) and the input (0) of my
filter.
*/
connection.sourceAudioUnit = AUHAL;
connection.sourceOutputNumber = 1;
connection.destInputNumber = 0;
err = AudioUnitSetProperty(delayUnit,
kAudioUnitProperty_MakeConnection,
kAudioUnitScope_Input,
0,
&connection,
sizeof(connection));
}
{
// hook up our filter to the AUHAL's output
struct AudioUnitConnection connection;
OSStatus err;
err = connectAUToInput(delayUnit,AUHAL);
/* I'm trying to feed input into my filter. So here I create a
connection
between the client output of AUHAL (1) and the input (0) of my
filter.
*/
connection.sourceAudioUnit = delayUnit;
connection.sourceOutputNumber = 1;
connection.destInputNumber = 0;
err = AudioUnitSetProperty(AUHAL,
kAudioUnitProperty_MakeConnection,
kAudioUnitScope_Input,
0,
&connection,
sizeof(connection));
}
err = AudioOutputUnitStart(AUHAL);
// What's the proper way to handle things with the AU HAL?
// Do I poll for data somewhere, or eh what?
err = AudioOutputUnitStop(AUHAL);
}
CloseComponent (delayUnit);
}
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.