Re: Simple code to use an effect
Re: Simple code to use an effect
- Subject: Re: Simple code to use an effect
- From: Chris Rogers <email@hidden>
- Date: Mon, 18 Feb 2002 11:37:37 -0800
Hi,
I modified the DefaultOutput Unit sample code in order to add
effect to the playback so I can test the ones I wrote (is there a
simple app that would let me do that?) I don't think that I am too
far away from having it working but it still doesn't playback after
much efforts trying.
We have a very nice one written in Java which we're hoping to put out
there soon. The Java calls and the C APIs match very closely...
Original code is UsingAudioConverterNoAC.cpp (since I use default
output 32-bit float stereo 44100.)
I added an effect au (matrix reverb).
I feed the matrix render function with the sin generator in 32-bit
float format. I also setup the AudioStreamBasicDescription for the
effect au (same as the output au.)
Then I do :
AudioUnitConnection theConnection;
theConnection.sourceAudioUnit = theEffectUnit;
theConnection.sourceOutputNumber = 0;
theConnection.destInputNumber = 0;
verify_noerr(AudioUnitSetProperty(theOutputUnit,
kAudioUnitProperty_MakeConnection,
kAudioUnitScope_Input,
0,
&theConnection,
sizeof(theConnection)));
Is that the way it should be? In particular, the scope is input, so
I need to give a source, right? The command could have been clearer
if it was given an sense of direction. Connection doesn't say much
about the way of the stream. Just a suggestion.
This looks correct to me. By the way, the AUGraph APIs allow you
to deal with several AudioUnits and their connections in a simpler way...
What are the sourceOutput and destInput numbers representing? I
can't find any relation anywhere to with these number used here. I
must have looked a dozen times in the headers and the pdfs. If I use
1 instead of 0, then the effect won't be pulled. Why?
The sourceOutput number represents the output bus (stream) number for the
source AudioUnit. In your case, the reverb has only one output bus, so this
number must be zero. destInput represents the input bus number for the
destination AudioUnit. The DefaultOutput AudioUnit is your destination
and may have one or more input busses (streams) depending on how many
input streams the default hardware device supports (for built-in hardware
this would be one input bus).
In order to find out if the filter gets pulled, I built the sample
effect au in the SDK and put a debug statement in the process loop.
I get there. But I still can not hear anything. However since I
invoke start on the default output au only, it is pulling its
source correctly or it wouldn't reach the breakpoint in the effect
au. Right?
It seems like it's connected properly if you're reaching your breakpoint.
Are you sure that the reverb AudioUnit is getting its sine wave input?
This is what I would check next.
Is there an order to do things. Can I make the connection at anytime
(as soon as I get two au refs) and then change the properties?
You have to be careful to not change the connections in another thread while
the AudioUnits are running. The AUGraph APIs allow you to change connections
on-the-fly even while the graph is running.
Chris Rogers
Core Audio Engineer
--
_______________________________________________
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.