Re: How to setup the sample rate in an AUGraph
Re: How to setup the sample rate in an AUGraph
- Subject: Re: How to setup the sample rate in an AUGraph
- From: Brian Willoughby <email@hidden>
- Date: Thu, 20 Jul 2017 13:27:07 -0700
On Jul 20, 2017, at 4:02 AM, Laurent Noudohounsi
<email@hidden> wrote:
> But I've some question about the behaviour of a custom callback within an
> AUGraph.
> Indeed, I've the feeling that the AUGraph use default settings for the
> callback options. Like all the graph is in 44100kHz with 2 channels.
Yes, the documentation states that all AudioUnits have 44.1kHz stereo 32-bit
float as the format. You must change the format after connecting all nodes, but
before starting the graph. Note that each AU has both an input format and an
output format. Those should all be set (there are some shortcuts, but when in
doubt set them all).
> I use a file with a sampling rate of 11025 (= 1/4 * 441000). The callback
> tell me that the frame position reach the number of frames too early. For a
> 16sec file, I reach the end at 4sec (btw the 1/4 of 16sec)
It seems that 99% of your problem is the mismatch of sample rates. However,
even after you solve this problem you should be wary of using this technique
for file playback. The FilePlayer AudioUnit will still load from your file in
advance of the playback time, which can lead to your code reacting too early.
You need to account for the latency of your graph, and not stop the audio until
all the samples are flushed. If you do not do this, your code will cut off the
end of the audio file, which won't be heard. In other words, even after you get
rid of the 1/4 rate error, you will still see the frame position reach the
number of frames too early.
> So how can I handle this problem? Can I set global setting to the AUGraph or
> should I set the format for every audio units?
There is no global setting for an AUGraph with regard to sample rate or bit
depth. A global setting is impossible because some nodes can have sample rate
conversion, such that their input and output are different.
You need to choose either 44.1 kHz or 11.025 kHz, and then set all of the AU
nodes to have your chosen rate on both input and output. If you run your graph
at 44.1 kHz, then the FilePlayer should provide sample rate conversion. If you
run your graph at 11.025 kHz, then your output AU will handle conversion to the
hardware sample rate.
Brian Willoughby
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden