I don't consider madplay really to be an example, at least not a simple one, precisely because it is so complex. It's a full-featured command-line decoder and player. However, I think minimad ought to be quite a bit easier to wrap your head around, and it uses exactly the same high-level MAD API that madplay does.
I did wrap the minimad example easily into a class, but I then got stuck. Firstly, it outputs to stdio. Can MAD actually output to the audio device or is that beyond the scope of the library (i.e. it's only a decoder). I figured I could replace stdio with /dev/pcm (or audio?), but this, I'm afraid, is not very portable, is it?
Writing these questions down, I realize how "trivial" they are. I think it shows clearly that documentation is needed, though I understand MAD still has some way left to go for a 1.0 release (true?) and things will change. Have you considered to use a documentation tool (e.g. Doxygen) for the code?
I wondered if anybody has written a fairly decoupled C++ wrapper class. It doesn't have to be quite:
MP3File m("my_song.mp3"); m.play();
but at least closer to that than to the 2000+ line example included.
I don't think I've seen anything like this yet, but it sounds like it might be useful.
Absolutely. It's great that MAD provides a fine level of control, but a class like the above, with additional stop(), pause(), jump(int) functions is probably enough for many.
- Marius