• 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: Newbie confusion!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie confusion!


  • Subject: Re: Newbie confusion!
  • From: Jeff Moore <email@hidden>
  • Date: Tue, 28 Aug 2007 11:48:53 -0700


On Aug 27, 2007, at 10:39 PM, Jason Staczek wrote:

Hi,

I'm confused about a few things. Been working through some of the
examples as I try to get my own CA app up and running.

1. Are the CAxxx.cpp files in Examples/PublicUtility officially part
of the Core Audio SDK? I ask because they're sitting in "Examples" and
not part of the framework itself. Obviously lots of useful stuff, but
should I treat it as library code or sample code only, to be tweaked
and modified?

It is sample code. Do with it as you please (well, in accordance with the Sample Code License of course).


That said, you'll find that pretty much all of the CoreAudio examples make use of the PublicUtility code. Plus we do update it and fix bugs with new SDK releases. So if you aren't directly using the code as is, you might want to make a copy of it in your own project before making changes.

2. I'm perplexed by the various BufferList wrappers. I see
CABufferList and CAAudioBufferList. CABufferList seems to do
more/better stuff, but mentions AUBufferList as preferred, which I
can't find at all. Tips?

CAAudioBufferList is just a collection of functions for doing things with AudioBufferLists without the overhead of creating a whole C++ object. It's emphasis is on being simple and lightweight without pulling in a variety of other libraries or frameworks.


CABufferList is a similar collection of functions for doing stuff with AudioBufferLists in the form of a full C++ class that subclasses AudioBufferList. Note that this class has a direct dependency on CoreServices, which may or may not be a concern.

AUBufferList is defined as part of the AUBuffer class that you'll find in /Developer/Examples/CoreAudio/AudioUnits/AUPublic/Utility. This class is optimized to work withe rest of the AUPublic code and is specialized for dealing with the needs of AudioUnits.

Which of these classes you use depends on your situation. If you are writing an AudioUnit, you should probably use AUBufferList. If you want the convenience of the full C++ object, you should use CABufferList. If you are concerned about your linkage, you should use CAAudioBufferList


3. I'm trying to use the following code to open and read an audio file (.m4a):

    CAAudioFile* file = new CAAudioFile();
    file->Open(fileToOpen); // obtained from NSOpenPanel
    int n = file->GetNumberFrames(); // returns 3485696
    CABufferList* cabl = CABufferList::New("whatever",
file->GetFileDataFormat());
    cabl->AllocateBuffers(0x40000);
    UInt32 frames = 0x8000;
    file->Read(frames,  &cabl->GetModifiableBufferList());

file->Read succeeds, but sets frames == 1. What am I doing wrong to
make it read just one frame?

It's hard to say. I'm not as familiar with this bit of code as I am a lot of the other bits of PublicUtility.


At any rate, this class looks to be a very light weight wrapper around <AudioToolbox/ExtendedAudioFile.h>. I note that this class seems to have a lot of logging scaffolding in it, so you might want to enable that to see what's going on.


By the way, similar code will open and play that same .m4a file using
the CAChannelMappingPlayer...

I'm pretty sure that CAChannelMappingPlayer ultimately uses CAAudioFile to read the file data, so you might want to check out how this code works.


--

Jeff Moore
Core Audio
Apple


_______________________________________________ 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: 
 >Newbie confusion! (From: "Jason Staczek" <email@hidden>)

  • Prev by Date: Re: Writing Cocoa UIs with C++?
  • Next by Date: Fwd: Writing Cocoa UIs with C++?
  • Previous by thread: Newbie confusion!
  • Next by thread: Re: Core Audio Clock example?
  • Index(es):
    • Date
    • Thread