Re: Re: C++ wrapper

Samuel Krempp <[email protected]>
Newsgroups gmane.comp.audio.mad.devel
Message-ID <[email protected]>
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)

-- 
Samuel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.