Re: Multiple Newbie CoreAudio AU and AUHAL problems
Re: Multiple Newbie CoreAudio AU and AUHAL problems
- Subject: Re: Multiple Newbie CoreAudio AU and AUHAL problems
- From: William Stewart <email@hidden>
- Date: Tue, 8 Jun 2004 16:19:21 -0700
On 07/06/2004, at 9:47 PM, Chilton Webb wrote:
>
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);
This call is a problem - it opens a V1 version of the AU and is
deprecated....
You need to find and open the AUHAL unit the same way as you do for the
effect
type - output type 'auou'
subtype - ahal
manu - appl
>
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?
here or somewhere :-)
If you are going to change the format (for instance you should run this
at the sample rate of the device), then you initialize this AFTER
you've set its formats.
>
>
{
>
// 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;
Nope... outputNumber of the delay unit is 0 not 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?
not sure what you mean...
There is a technote about using the AUHAL unit for Input - you should
check that to make sure you are following all the necessary set up
steps (there were also a slew of emails a few weeks ago on this list
about it as well...) Tech notes are available at
http://developer.apple.com/audio
Bill
>
// 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.
>
>
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
Culture Ship Names:
Ravished By The Sheer Implausibility Of That Last Statement [GSV]
I said, I've Got A Big Stick [OU]
Inappropiate Response [OU]
Far Over The Borders Of Insanity And Still Accelerating [Eccentric]
________________________________________________________________________
__
_______________________________________________
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.