Re: Noisy DefaultOutputUnit
Re: Noisy DefaultOutputUnit
- Subject: Re: Noisy DefaultOutputUnit
- From: Paul Scott <email@hidden>
- Date: Sat, 26 Jan 2008 21:36:15 -0800
Also, I expect that this would never actually happen in your app.
Why would you need to change the sample rate of the data you're
playing? Just pick a reasonable value and stick with it.
I wouldn't actually be changing rates, no. I was only trying to
discover what was causing the clicks so I could avoid them in my
application.
So, in other words: if you don't want clicks, just start the output
AU once. Don't expect to stop and start it without some
discontinuity.
Well, this is a bit of a problem. I really don't want my application
continuously spitting out floats to generate silence when there's no
reason to. I'd like to be able to turn off the callback routine
without sounding like I unplugged my guitar from the amp. Isn't there
a clean way to do this?
Now: We're still getting clicks when the sample rate is changed. I
don't know how to fix that one, if it is fixable. (Is it expected to
be able to change the AUs sample rate w/o a discontinuity?)
There is no requirement for changing sample rates. In fact, it is
desirable not to. However, If the clicks are the result of a failure
to keep a smooth flow of samples, then I'd like to know where that's
happening because it may affect me later on down the road even with a
fixed sample rate.
(Also, note that the way sSampleRate is set is not thread-safe.
I'm not going to use this code as-is in my application. I'm just using
it as a learning tool.
Yes, but it isn't necessary [to call CFRunLoopRun]. You can start
and stop the AU on the main thread. There is no need to call
CFRunLoopRun() yourself, since Cocoa already does it for you. (Keep
in mind that MyRenderer() will always get called on another thread.)
That's good to know. I have very little experience writing
applications on Mac OSX. This is one area I need to study. There's
plenty of documentation available on the subject, so I better read up
on it.
Let's imagine you have two buttons, one to start the audio and one
to stop. Your code would look like this:
- (void) start: (id) sender
{
// set up the AU's input format with the current sample rate,
encoding, etc.
// call AudioUnitInitialize() on it
// call AudioOutputUnitStart() on it
// Then just return. Cocoa will run the run loop for you. No need
to call CFRunLoopRun() yourself.
}
- (void) stop: (id) sender
{
// Call AudioOutputUnitStop().
// Call AudioUnitUninitialize().
}
But doesn't this cause the clicks? I really don't want the user to
have any clue as to when I attach or detach the audio unit.
I guess it's time to stop experimenting with the example and code up a
prototype application to get a better idea.
Paul
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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