Arduino LibMAD
All Classes Files Functions Pages
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
libmad::MP3DecoderMAD Class Reference

A simple Arduino API for the libMAD MP3 decoder. The data is provided with the help of write() calls. The decoded result is available either via a callback method or via an Arduino stream. More...

#include <MP3DecoderMAD.h>

Public Member Functions

 MP3DecoderMAD (MP3DataCallback dataCallback, MP3InfoCallback infoCB=nullptr)
 
void setBufferSize (size_t size)
 Set the maximum buffer size which is used for parsing the data. More...
 
 MP3DecoderMAD (Print &mad_output_streamput, MP3InfoCallback infoCB=nullptr)
 
void setOutput (Print &out)
 
void setDataCallback (MP3DataCallback cb)
 Defines the callback which receives the decoded data.
 
void setInfoCallback (MP3InfoCallback cb)
 Defines the callback which receives the Info changes.
 
void begin ()
 
void end ()
 
MadAudioInfo audioInfo ()
 Provides the last valid audio information.
 
size_t write (const void *in_ptr, size_t in_size)
 Makes the mp3 data available for decoding: however we recommend to provide the data via a callback or input stream.
 
 operator bool ()
 Returns true as long as we are processing data.
 

Protected Member Functions

int findSyncWord (int offset)
 Finds the MP3 synchronization word which demarks the start of a new segment. More...
 
virtual void decode (Range r)
 Decodes a frame.
 
size_t appendToBuffer (const void *in_ptr, int in_size)
 we add the data to the buffer until it is full
 
size_t writeFrame (const void *in_ptr, size_t in_size)
 appends the data to the frame buffer and decodes
 
size_t maxFrameSize ()
 Determines the maximum frame (buffer) size.
 
Range synchronizeFrame ()
 Synchronizes a Frame.
 
Range frameRange ()
 Determines the next start and end synch word in the buffer.
 
void advanceFrameBuffer (int offset)
 Advances the frame buffer.
 
void output (void *data, struct mad_header const *header, struct mad_pcm *pcm)
 output decoded data More...
 

Static Protected Member Functions

static int16_t scale (mad_fixed_t sample)
 Scales the sample from internal MAD format to int16.
 

Protected Attributes

size_t max_buffer_size = 1024
 
size_t frame_counter = 0
 
bool active
 
struct mad_stream stream
 
struct mad_frame frame
 
struct mad_synth synth
 
MadInputBuffer buffer
 
MadAudioInfo mad_info
 

Detailed Description

A simple Arduino API for the libMAD MP3 decoder. The data is provided with the help of write() calls. The decoded result is available either via a callback method or via an Arduino stream.

Author
Phil Schatzmann

Member Function Documentation

◆ findSyncWord()

int libmad::MP3DecoderMAD::findSyncWord ( int  offset)
inlineprotected

Finds the MP3 synchronization word which demarks the start of a new segment.

Parameters
offset
Returns
int

◆ output()

void libmad::MP3DecoderMAD::output ( void *  data,
struct mad_header const *  header,
struct mad_pcm *  pcm 
)
inlineprotected

output decoded data

notify abmad_output_stream changes

◆ setBufferSize()

void libmad::MP3DecoderMAD::setBufferSize ( size_t  size)
inline

Set the maximum buffer size which is used for parsing the data.

Parameters
size

The documentation for this class was generated from the following file: