• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: PlayFile
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PlayFile


  • Subject: Re: PlayFile
  • From: Michael Hanna <email@hidden>
  • Date: Fri, 9 Dec 2005 23:20:27 -0800

Thanks Bill, I took a look at AULab.. a nice piece of software. I'd like to make my own software similar to the AUFilePlayer. Current implementation is simply a NSMovieView and would like to take advantage of the features CoreAudio has to offer.

Michael

On 9-Dec-05, at 12:43 PM, William Stewart wrote:

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, &currentTimeStamp, &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
References: 
 >MTCoreAudio (From: Michael Hanna <email@hidden>)
 >Re: MTCoreAudio (From: William Stewart <email@hidden>)
 >PlayFile [was Re: MTCoreAudio] (From: Michael Hanna <email@hidden>)
 >Re: PlayFile [was Re: MTCoreAudio] (From: William Stewart <email@hidden>)

  • Prev by Date: More on: Error in AudioUnitRender()
  • Next by Date: Re: PlayFile
  • Previous by thread: Re: PlayFile [was Re: MTCoreAudio]
  • Next by thread: Re: PlayFile
  • Index(es):
    • Date
    • Thread