Re: QTSoundFilePlayer
Re: QTSoundFilePlayer
- Subject: Re: QTSoundFilePlayer
- From: Kevin Boyce <email@hidden>
- Date: Tue, 28 Dec 2004 08:37:41 -0500
On Dec 27, 2004, at 3:07 PM, Michael Hanna wrote:
Hello all.
I'm just learning Cocoa and Objective-c, and I'm trying to make a
simple sound player out of the QTSoundFilePlayer classes found at
http://www.snoize.com/
Welcome, me too! I'm writing a sound effects player, since my amateur
theatre group just did "City of Angels", which has about 12 million
sound effects, and I couldn't find a shareware product that really
worked for me. So voila, an excuse to learn Cocoa (and ObjC, and
XCode, and QT and CoreAudio, and IB, and...)!
I'm also using QTSoundfilePlayer, and had the same problem:
this seems to work OK, but the field doesn't refresh every 0.2
seconds(about every 1.5 seconds). Is it because I added the NSTimer to
the wrong thread(I know very little about threads)?
Oh yeah, threads. I had to learn about them too!
But no, your problem is almost certainly that currentMediaTime is
calculated in the feeder thread of QTSoundFilePlayer, and only updated
once every time it fills the buffer. With the default buffer settings,
that can easily be more than one second. Also, it reports the time at
the *end* of the buffer it just converted, so you may be displaying
time a second and a half ahead of the actual playback position.
I've modified QTSoundFilePlayer to keep track of currentMediaTime in
the playback thread, which calls the renderBuffer callback many times
per second, so currentMediaTime is much more accurate.
(My version also adds a fadeOut method, in which it is discovered that
the default HAL output AU doesn't handle AudioUnitScheduleParameters()
calls, so we have to step down the volume only once per buffer. Sigh.)
Anyway, for now you can get my modified versions at
http://www.kevland.com/coreaudio/
Kurt, if you're listening, I'd be interested to know what you think of
my approach. I was hoping not to have to learn too much about the
inner workings of QTSoundFilePlayer, but then I was also hoping the
same about NSTableView, and that didn't work out either... Whether
I've solved the problem in a sensible way I have no idea, but it seems
to work.
Michael, let me know if this helps any.
-Kevin
--
Kevin Boyce
"Burn the land, and boil the sea; You can't take the sky from me."
_______________________________________________
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