I just looked through the archives to find information on MAD and if there was any higher-level way of getting an MP3 decoded and came across the recent post about a C++ wrapper.
I'd be very interested in such a thing as I'm not particularly keen on implementing all the different callback functions if I don't have to. All I need is some method for getting one decoded sample at a time for further processing within a beat-tracking application.
Samuel, what functionality do you have at the moment? Would it be possible to just send the wrapper a filename and then proceed to call a read() method or such? Does it take care of downsampling to 16-bit, frequency conversion (if necessary), checking endian-ness etc?
Erik
On Tue, 2004-01-13 at 16:02, Erik Jälevik wrote:
Samuel, what functionality do you have at the moment? Would it be possible to just send the wrapper a filename and then proceed to call a read() method or such? Does it take care of downsampling to 16-bit, frequency conversion (if necessary), checking endian-ness etc?
it's not too ugly, but not complete nor polished yet. I have a stream class that takes care of all precise stuff to extract things from the inout (file or whatever, it works on C++ streambufs, it accepts file names, istreams, and streambufs out of the box and the caller can make a streambuf around whatever he wants supported - for exemple a C FILE*. I might provide a sample FILE-wrapping streambuf, there are some all over the web and it fits in a dozen lines)
The higher-level class (which I called Engine, out of better names) drives a stream and allows for very high-level usage :
void open_mp3(std::string fname); void reset(); // clear all stateful data
// the final pcm samples are obtained in a 'synth' : bool get_synth(); // try and get a synth from our stream (false if it has none left)
// dump current synth to iterators. template<class Iter> bool dump_cur_synth(Iter& left, Iter& right, size_t size);
I'm mostly using native float output, so I havent worked into pcm conversions from Mad's fixed point format except to float. But using adequate iterators (and destination types with proper conversion), this function should support interleaved channels destination, and byte-reordering. I'll write ready-to-use iterator adapters to show how to use it..
I'm planning on adding a few things even if only for my own usage. Biggest planned features are seeking and resampling, and detecting lame info in ancillary bits about precise begin and end of the track (needed for gapless playback, as mp3 itself is not gapless) but maybe that'll be outside the mad wrapper class, as it is not strictly mad stuff.
I'll also add a dither function (good simple triangular, using boost.org libs for generating the random numbers), and this kind of added value will be inside the wrapper class (along with the functions to process the pcm data synthesized by mad)