Re: How to monitor what is being recorded?
Re: How to monitor what is being recorded?
- Subject: Re: How to monitor what is being recorded?
- From: Rolf Nilsson <email@hidden>
- Date: Sat, 12 Jun 2004 16:31:37 +0200
----- Original Message -----
From: "William Stewart" <email@hidden>
To: "Roni Music" <email@hidden>
Cc: <email@hidden>
Sent: Saturday, June 12, 2004 3:37 AM
Subject: Re: How to monitor what is being recorded?
> >> What's the failure case when you set the connection?
> >
> > There is no failure but also no sound so it seems there is
something I
> > do not understand?
> >
> > When I set up the connection below, I expect that whatever arrives
at
> > the input (bus 1?) is also sent to the output device at bus 0?
> >
> > AudioUnitConnection connection;
> > connection.sourceAudioUnit = theInputUnit;
> > connection.sourceOutputNumber = 1;
> > connection.destInputNumber = 0;
> > AudioUnitSetProperty( theOutputUnit,
> > kAudioUnitProperty_MakeConnection, kAudioUnitScope_Input,
> > 0/*inElement*/, &connection,
> > sizeof(AudioUnitConnection));
> >
> >
> > But if I make the connection, the render callback for the output is
> > never called.
> > So when I make the connection does that mean that there is no need
for
> > the render callback?
>
> Yes - the callback is there really to tell you that Input is there...
> but if you already in the I/O Proc because you are doing output to the
> device you are getting input from, then you don't need it... However,
> if you've installed it, it should still fire,
it fires as soon as I remove the connection, so the output device works
OK
> so I expect that
> something is not quite right... If you install an AU between the
> connection between the input and output, then that would be a good
test
> case, as I'm not quite convinced that connecting the output unit to
> itself is really working...
I tried to set up a delay unit for a test:
// open delay unit
Component comp;
ComponentDescription desc;
desc.componentType = kAudioUnitType_Effect;
desc.componentSubType = kAudioUnitSubType_Delay;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
comp = FindNextComponent(NULL, &desc);
XThrowIf(comp == NULL, -1, "find delay unit");
XThrowIfError(OpenAComponent(comp, &mDelayUnit), "open delay unit");
XThrowIfError(AudioUnitInitialize(mDelayUnit), "init delay unit");
-----
then make the connections, first from the input to the delay unit:
AudioUnitConnection connection;
connection.sourceAudioUnit = mInputUnit;
connection.sourceOutputNumber = 1;
connection.destInputNumber = 0;
XThrowIfError(AudioUnitSetProperty(mDelayUnit,
kAudioUnitProperty_MakeConnection, kAudioUnitScope_Input,
0/*inElement*/, &connection, sizeof(AudioUnitConnection)),
"kAudioUnitProperty_MakeConnection failed");
then from the delay unit to the output device:
connection.sourceAudioUnit = mDelayUnit;
connection.sourceOutputNumber = 0;
connection.destInputNumber = 0;
XThrowIfError(AudioUnitSetProperty(mOutputUnit,
kAudioUnitProperty_MakeConnection, kAudioUnitScope_Input,
0/*inElement*/, &connection, sizeof(AudioUnitConnection)),
"kAudioUnitProperty_MakeConnection failed");
Now the output render callback is called but still no sound
Any ideas?
I have two workarounds that works OK:
1. Transfer the data from the input device callback to the output
callback via a simple non-blocking cue.
On my dual processor Mac the callbacks are in separate threads so this
could eventually go wrong
or will the input and output callbacks never be called at the same time?
2. I use the same callback for both the input and output and store the
samples in a temporary buffer
and check if it is the input (bus 1 -> storing data) or the output (bus
0 -> copy the stored data)
both methods could probably go wrong but the worst that could happen is
wrong samples being played, not a crash
I guess it's a bad idea to have locks inside the callback?
I still would prefer the "AudioUnitConnection" way to get play thru
Rolf
>
> Bill
>
>
> > The output unit works fine by itself (trying it with a simple sinus
> > tone) and is created with
> > kAudioUnitType_Output, kAudioUnitSubType_HALOutput and
> > kAudioUnitManufactor_Apple
> >
> > then
> > FinNextComponent() and OpenAComponent()
> >
> > then
> > _SetRenderCallback
> > and _StreamFormat to the sames as the input
> >
> > and lastly _MakeConnection as above and AudioUnitInitialize()
> >
> > The InputDevice is set up exactly as in your CAAudioFileRecorder
> > example (the output is disabled and the input is enabled)
> >
> > Is there any example of playthru with
> > kAudioUnitProperty_MakeConnection in the develop examples?
> >
> > Any help appreciated
> >
> > Rolf
_______________________________________________
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.