arduino-audio-tools
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
MP3EncoderLAME Class Reference

Encodes PCM data to the MP3 format and writes the result to a stream This is basically just a wrapper using https://github.com/pschatzmann/codec-lame. More...

#include <CodecMP3LAME.h>

Inheritance diagram for MP3EncoderLAME:
AudioEncoder AudioWriter MimeSource AudioInfoSupport

Classes

class  FrameWriter
 Receives the output of LAME and passes it on in complete MP3 frames. More...
 

Public Member Functions

 MP3EncoderLAME (bool splitFrames=false)
 
 MP3EncoderLAME (Print &out_stream, bool splitFrames=false)
 
 ~MP3EncoderLAME ()
 
AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
AudioInfoLAME & audioInfoExt ()
 
virtual AudioInfo audioInfoOut ()
 
bool begin ()
 
virtual bool begin (AudioInfo info)
 
bool begin (AudioInfoLAME from)
 
AudioInfoLAME defaultConfig ()
 
liblame::MP3EncoderLAME * driver ()
 
void end ()
 
virtual uint32_t frameDurationUs ()
 Optional rtsp function: provide the frame duration in microseconds.
 
virtual int frameSize ()
 
const char * mime ()
 Provides the mime type of the encoded result.
 
virtual operator bool ()
 
virtual uint16_t samplesPerFrame ()
 Optional rtsp function: provide samples per the frame.
 
void setAudioInfo (AudioInfo from)
 Defines the Audio Info.
 
void setAudioInfo (AudioInfoLAME from)
 Defines the Audio Info.
 
void setOutput (Print &out_stream)
 Defines the output stream.
 
size_t write (const uint8_t *data, size_t len)
 

Protected Member Functions

void createEnc ()
 
void writeBlocking (Print *out, uint8_t *data, size_t len)
 

Protected Attributes

liblame::MP3EncoderLAME * enc =nullptr
 
FrameWriter frame_writer {frames}
 
HeaderParserMP3 frames
 
AudioInfo info
 
AudioInfoLAME lame_info
 
Print * p_print =nullptr
 
bool split_frames = false
 

Static Protected Attributes

static constexpr int kMaxFrameSize = 2048
 Buffer size for the frame splitting: bigger than the largest MP3 frame.
 

Detailed Description

Encodes PCM data to the MP3 format and writes the result to a stream This is basically just a wrapper using https://github.com/pschatzmann/codec-lame.

LAME delivers its output in arbitrary chunks (zero, one or several MP3 frames per write()). Pass splitFrames = true to the constructor to get exactly one complete MP3 frame per write() to the output instead - as e.g. the video muxers (MuxerMTS, MuxerAVI, ...) expect it.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ MP3EncoderLAME() [1/2]

MP3EncoderLAME ( bool  splitFrames = false)
inline
Parameters
splitFramestrue: write exactly one complete MP3 frame per write()

◆ MP3EncoderLAME() [2/2]

MP3EncoderLAME ( Print &  out_stream,
bool  splitFrames = false 
)
inline
Parameters
splitFramestrue: write exactly one complete MP3 frame per write()

◆ ~MP3EncoderLAME()

~MP3EncoderLAME ( )
inline

Member Function Documentation

◆ audioInfo()

AudioInfo audioInfo ( )
inlineoverridevirtualinherited

provides the actual input AudioInfo

Implements AudioInfoSupport.

Reimplemented in CodecNOP, MP3EncoderShine, BinaryContainerEncoder, and MP3ParserEncoder.

◆ audioInfoExt()

AudioInfoLAME & audioInfoExt ( )
inline

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ begin() [1/3]

bool begin ( )
inlinevirtual

Implements AudioWriter.

◆ begin() [2/3]

virtual bool begin ( AudioInfo  info)
inlinevirtualinherited

◆ begin() [3/3]

bool begin ( AudioInfoLAME  from)
inline

◆ createEnc()

void createEnc ( )
inlineprotected

◆ defaultConfig()

AudioInfoLAME defaultConfig ( )
inline

◆ driver()

liblame::MP3EncoderLAME * driver ( )
inline

◆ end()

void end ( )
inlinevirtual

Implements AudioWriter.

◆ frameDurationUs()

virtual uint32_t frameDurationUs ( )
inlinevirtualinherited

Optional rtsp function: provide the frame duration in microseconds.

Reimplemented in ADPCMEncoder, MP3EncoderShine, OpusOggEncoder, MP3ParserEncoder, and MetaDataFilterEncoder.

◆ frameSize()

virtual int frameSize ( )
inlinevirtualinherited

Optional rtsp function: provide the encoded size (in bytes) of one frame, once known (e.g. after the encoder has seen real data). Lets an RTSPFormat size its RTP fragments to match one frame instead of a fixed guess, so throughput actually tracks frameDurationUs() - a fragment size covering several frames' worth of bytes sent at one-frame timing overruns real-time bandwidth and, over UDP (no flow control), causes packet loss. Returns 0 if not yet known/not applicable (fixed-frame-size codecs have no need to override this).

Reimplemented in ADPCMEncoder, EncoderALAC, AMRNBEncoder, AMRWBEncoder, and MP3ParserEncoder.

◆ mime()

const char * mime ( )
inlinevirtual

Provides the mime type of the encoded result.

Implements AudioEncoder.

◆ operator bool()

virtual operator bool ( )
inlinevirtual

Implements AudioWriter.

◆ samplesPerFrame()

virtual uint16_t samplesPerFrame ( )
inlinevirtualinherited

Optional rtsp function: provide samples per the frame.

Reimplemented in OpusAudioEncoder, OpusMultiStreamAudioEncoder, MP3EncoderShine, MP3ParserEncoder, and MetaDataFilterEncoder.

◆ setAudioInfo() [1/2]

void setAudioInfo ( AudioInfo  from)
inlinevirtual

Defines the Audio Info.

Reimplemented from AudioEncoder.

◆ setAudioInfo() [2/2]

void setAudioInfo ( AudioInfoLAME  from)
inline

Defines the Audio Info.

◆ setOutput()

void setOutput ( Print &  out_stream)
inlinevirtual

Defines the output stream.

Reimplemented from AudioEncoder.

◆ write()

size_t write ( const uint8_t *  data,
size_t  len 
)
inlinevirtual

Implements AudioWriter.

◆ writeBlocking()

void writeBlocking ( Print *  out,
uint8_t *  data,
size_t  len 
)
inlineprotectedinherited

Member Data Documentation

◆ enc

liblame::MP3EncoderLAME* enc =nullptr
protected

◆ frame_writer

FrameWriter frame_writer {frames}
protected

◆ frames

HeaderParserMP3 frames
protected

◆ info

AudioInfo info
protectedinherited

◆ kMaxFrameSize

constexpr int kMaxFrameSize = 2048
staticconstexprprotected

Buffer size for the frame splitting: bigger than the largest MP3 frame.

◆ lame_info

AudioInfoLAME lame_info
protected

◆ p_print

Print* p_print =nullptr
protected

◆ split_frames

bool split_frames = false
protected

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