Matthew DeNardo
2005-Nov-11 23:07 UTC
[Flac] how to include FLAC in a CoreAudio wave player
Hi everyone, I'm still new at this audio development thing in OSX as all of my prior experience is in database applications. I'm also new to C++ and the Xcode environment, which makes things interesting as I learn. There is a CoreAudio wave player written in C++ to which I would like to add FLAC playback support. I have looked through the libFLAC++ API and think I have an idea of what files/functions to use, but am not really sure how to go about implementing them. I think I want to use the file decoder class so I can just pass it the name of the FLAC file I want to play and use new, init, set and process_until_end_of_file functions to do what I need. I have an idea of how this will work in my head, but am having trouble translating it to code. I also am having trouble figuring out how this will hook back in to the existing application. I'm sure one of you with more experience can push me in the right direction. I want to learn to do it myself, but I also don't want to spin my wheels for months at a time (as I have been, since I only do this in my spare time) without signs of progress. Thanks, Matt __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com
On Fri, Nov 11, 2005 at 11:07:44PM -0800, Matthew DeNardo wrote:> There is a CoreAudio wave player written in C++ to > which I would like to add FLAC playback support. I > have looked through the libFLAC++ API and think I have > an idea of what files/functions to use, but am not > really sure how to go about implementing them.You might take a look at http://svn.xiph.org/trunk/xiph-qt/ which is some in-development code by Arek Korbok to add CoreAudio components for vorbis and speex; that might give you a place to start for implementing a flac component. HTH, -r
--- Matthew DeNardo <matt_denardo@yahoo.com> wrote:> There is a CoreAudio wave player written in C++ to > which I would like to add FLAC playback support. I > have looked through the libFLAC++ API and think I have > an idea of what files/functions to use, but am not > really sure how to go about implementing them. > > I think I want to use the file decoder class so I can > just pass it the name of the FLAC file I want to play > and use new, init, set and process_until_end_of_file > functions to do what I need. I have an idea of how > this will work in my head, but am having trouble > translating it to code. I also am having trouble > figuring out how this will hook back in to the > existing application.I don't know how deep you've gotten into the API docs, but since the C++ library is mostly a wrapper around the C one, most of the documentation is for at the C level, but can be trivially applied to the C++ class since the calls have similar names/signatures. the C++ just makes the C callbacks into virtual methods mostly. so I would say first look a http://flac.sourceforge.net/api/group__flac__file__decoder.html#_details and dive down into the individual functions for details (maybe you have already done this). there are also examples in the unit tests of how to create a class derived from the file decoder; see src/test_libFLAC++/decoders.c in the source distribution and search for FileDecoder. most of the code in there is thousands of lines of tests but the actual class setup is pretty simple. it's hard to know how to help with hooking it into the app without knowing the app. the libFLAC decoder is pull-based, i.e. one you process_until_end_of_file(), control is only going to come back to you during callbacks (mostly write) or end of stream. if the app is push based you will have to do frames at a time into a fifo (see the source for the winamp or xmms plugins), or use multiple threads. Josh __________________________________ Start your day with Yahoo! - Make it your home page! http://www.yahoo.com/r/hs
On 11/12/05, Ralph Giles <giles@xiph.org> wrote:> On Fri, Nov 11, 2005 at 11:07:44PM -0800, Matthew DeNardo wrote: > > > There is a CoreAudio wave player written in C++ to > > which I would like to add FLAC playback support. I > > have looked through the libFLAC++ API and think I have > > an idea of what files/functions to use, but am not > > really sure how to go about implementing them. > > You might take a look at http://svn.xiph.org/trunk/xiph-qt/ > which is some in-development code by Arek Korbok to add > CoreAudio components for vorbis and speex; that might give > you a place to start for implementing a flac component. > > HTH, > -r >Well, the CoreAudio FLAC component is mostly ready and working. No need to write it. It just needs a bit of refactoring, and I will add it to the repository soon. If this is a CoreAudio player it probably uses CoreAudio mechanisms to handle media(audio) files. Hence, once the CAFLAC component is installed, it should be quite simple (using CA API, not the Ogg/FLAC libraries/frameworks directly) to make the player use that component for FLAC-file decompression. Hope this helps. Arek