On Sun, Oct 02, 2005 at 02:01:50PM +0200, Mario Lang wrote: > Hi. > > My little time-compressing audio player yatm currently supports 3 different > audio formats, ogg and speex via the xiph libraries, and mpeg via libmad. > I currently just blindly try to launch the decoder for either ogg, speex or > mp3 in series. SO if the first fails, I try the second, and so on. Which > kinda works but is a bit ugly. I'd like to add flac support at some point, > which would make this even more ugly. > Additionally, libsndfile support wouldnt be that bad either, so, I am > wondering, is there a reliable way to detect a audio streams file > format just given some bits of the header? So that I could set the > appropriate decoder algorithm based on that analysis? Or is > there actually a library one step higher level than libsndfile which > does generic audioformat to PCM? I guess not...
Hi, you might want to take a look at Aqualung (aqualung.sf.net) which is a music player program supporting a reasonable range of formats. The input library (the part of the software that opens soundfiles, determines their format and decodes them to float PCM) is a component not too tightly integrated with the rest of the app. In fact, it is built separately as a lib and linked statically to the rest of the program. However, it supports only read-only access, and was not meant to be used out of the scope of its mother application, which means you won't be able to use it as an immediate drop-in solution. (It might be possible with some hacking, since interdependencies with the rest of the program are not conceptual and remain mostly because of my laziness and limited resources.) This module (called the "file decoder") works by probing individual format plugins on the file (well, not plugins in the usual sense, they are only modules with a predefined, simple api) that are responsible for correctly reporting whether they are able to deal with the file. This part of the software itself is fairly structured (at least I believe so), there are no excessive comments but the big picture should be clear for any programmer after a bit of investigation. If you decide to take a look, download the CVS sources of Aqualung and look in src/decoder/. Feel free to contact me if you have questions. Tom