Re: PlayFile [was Re: MTCoreAudio]
Re: PlayFile [was Re: MTCoreAudio]
- Subject: Re: PlayFile [was Re: MTCoreAudio]
- From: William Stewart <email@hidden>
- Date: Fri, 9 Dec 2005 12:43:10 -0800
The PlayFile.cpp uses the AUFilePlayer. This AU has an interface -
you can see this in AULab:
Open AULab
New Doc
Edit - Add Generator Track
Choose the Apple - AUFilePlayer
As you add this track you'll see the UI it presents.
If this UI is not what you want, then:
On 09/12/2005, at 12:55 AM, Michael Hanna wrote:
Cool, I actually made a simple playback cocoa app that wraps the
functions found in PlayFile.cpp.
few things I'd like to know:
- the NSButton stays in the on state. How do I farm-out the
playback task to another thread?
The playback is happening in another thread. Once you start the
graph, playback is taking care of itself:
// start playing
XThrowIfError (AUGraphStart (theGraph), "AUGraphStart");
this is the part where you just return...
we wait in the command line for the file to finish playing
// sleep until the file is finished
usleep ((int)fileDuration * 1000 * 1000);
then we clean up.
// lets clean up
- how can I determine at what point the 'playback head' is at?
AudioTimeStamp currentTimeStamp;
UInt32 dataSize = sizeof(currentTimeStamp);
OSStatus result = AudioUnitGetProperty(fileAU,
kAudioUnitProperty_CurrentPlayTime, kAudioUnitScope_Global, 0,
¤tTimeStamp, &dataSize);
Then the currentTimeStamp.mSampleTime will give you the sample number
the file is currently being played at - this is in the time scale/
sample rate of the file. If your file is at a different sample rate
than the file player's output sample rate, you'll need to convert
this number:
There's one thing you should do here that is missing from the SDK's
example:
In the MakeSimpleGraph call, there's the following code:
// prepare the file AU for playback
// set its output channels
XThrowIfError (fileAU.SetNumberChannels (kAudioUnitScope_Output, 0,
fileFormat.NumberChannels()), "SetNumberChannels");
You should add this line straight after that:
// set the output sample rate of the file AU to be the same as the file:
XThrowIfError (fileAU.SetSampleRate (kAudioUnitScope_Output, 0,
fileFormat.mSampleRate), "SetSampleRate");
This makes sure that the time line of the file and the AU is the
same, and will also ensure that you don't get two sample rate
conversions. I'll add this to the SDK example for its next release
Bill
I'd like to make an NSSlider that moves along with the playback.
Ideally, the user can move the slider knob to change the playback
location..
Michael
On 8-Dec-05, at 4:29 PM, William Stewart wrote:
Have a look at PlayFile in the Simple directory in CA SDK
On 08/12/2005, at 2:37 PM, Michael Hanna wrote:
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
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