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

ATRAC decoder (ATRAC1, ATRAC3, ATRAC3+ and ATRAC9) which converts the raw ATRAC frames into 16 bit PCM data. This class depends on https://github.com/pschatzmann/codec-atrac which is based on the ATRAC decoders of FFmpeg. More...

#include <CodecATRAC.h>

Inheritance diagram for DecoderATRAC:
Inheritance graph
[legend]
Collaboration diagram for DecoderATRAC:
Collaboration graph
[legend]

Public Member Functions

 DecoderATRAC (ATRACType type=ATRAC3)
 
 ~DecoderATRAC ()
 
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 
bool begin () override
 
bool begin (ATRACType type, int sampleRate, int channels, int blockAlign, const uint8_t *extra=nullptr, size_t extraSize=0)
 Starts the decoder with the parameters found in the header of the stream.
 
virtual bool begin (AudioInfo info) override
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
void end () override
 
void flush ()
 Drops partial data and resets the decoder state, e.g. after a seek.
 
int frameSize ()
 Size of one ATRAC frame in bytes.
 
Print * getOutput ()
 
ATRACType getType ()
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual bool isResultPCM ()
 Returns true to indicate that the decoding result is PCM data.
 
const char * mime () override
 Provides the mime type of the data that is expected by this decoder.
 
 operator bool () override
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
void setAudioInfo (AudioInfo from) override
 for most decoders this is not needed
 
void setBlockSize (int blockSize) override
 Defines the size of one ATRAC frame (block align) in bytes.
 
bool setCodecConfig (const uint8_t *data, size_t len) override
 Defines the codec specific header (e.g. the WAV fmt extension)
 
void setExtraData (const uint8_t *data, size_t len) override
 Defines the codec specific header (e.g. the WAV fmt extension)
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
virtual void setOutput (AudioOutput &out_stream)
 Defines where the decoded result is written to.
 
virtual void setOutput (AudioStream &out_stream)
 Defines where the decoded result is written to.
 
virtual void setOutput (Print &out_stream) override
 Defines where the decoded result is written to.
 
void setType (ATRACType type)
 Defines the ATRAC variant (must be called before begin())
 
AudioFormat wavFormat () override
 
size_t write (const uint8_t *data, size_t len) override
 Decodes the data: any amount of data can be provided.
 

Public Attributes

int id
 custom id to be used by application
 

Protected Member Functions

void decodeFrame ()
 
void notifyAudioChange (AudioInfo info)
 
void writeBlocking (Print *out, uint8_t *data, size_t len)
 

Static Protected Member Functions

static int atrac9FrameSize (const uint8_t *extra, size_t size)
 

Protected Attributes

int block_align = 0
 
Vector< uint8_t > extradata
 
Vector< uint8_t > frame
 
size_t frame_pos = 0
 
int frame_size = 0
 
AudioInfo info
 
bool is_notify_active = true
 
bool is_open = false
 
Vector< AudioInfoSupport * > notify_vector
 
ATRACDecoder * p_decoder = nullptr
 
Print * p_print = nullptr
 
Vector< int16_t > pcm
 
ATRACType type = ATRAC3
 

Static Protected Attributes

static const int MAX_SAMPLES_PER_FRAME = 2048
 ATRAC3+ has the largest frames: 2048 samples per channel.
 

Detailed Description

ATRAC decoder (ATRAC1, ATRAC3, ATRAC3+ and ATRAC9) which converts the raw ATRAC frames into 16 bit PCM data. This class depends on https://github.com/pschatzmann/codec-atrac which is based on the ATRAC decoders of FFmpeg.

The decoder needs to know the stream parameters which are usually found in the header of a container: register one decoder per type with WAVDecoder::addDecoder() to process WAV files (.at3, .at9), use ContainerATRACOMA or ContainerATRACAEA (see ContainerATRAC.h) for OMA and AEA files, or call begin(type, sampleRate, channels, blockAlign, extradata, extradataSize) yourself if you get the raw frames from somewhere else. The write() method can be called with any amount of data: the frames of blockAlign bytes are assembled internally.

Type blockAlign extradata
ATRAC1 212 * channels -
ATRAC3 frame size 10, 12 or 14 bytes
ATRAC3PLUS frame size -
ATRAC9 frame size (or 0: derived) 12 bytes (rate and channels)
Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ DecoderATRAC()

DecoderATRAC ( ATRACType  type = ATRAC3)
inline

◆ ~DecoderATRAC()

~DecoderATRAC ( )
inline

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport &  bi)
inlinevirtualinherited

◆ atrac9FrameSize()

static int atrac9FrameSize ( const uint8_t *  extra,
size_t  size 
)
inlinestaticprotected

ATRAC9 config header: the packet size is the frame size << superframe index (see ATRACDecoder)

◆ audioInfo()

AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ begin() [1/3]

bool begin ( )
inlineoverridevirtual

Starts the decoder with the values defined with setAudioInfo(), setBlockSize() and setCodecConfig()

Reimplemented from AudioDecoder.

◆ begin() [2/3]

bool begin ( ATRACType  type,
int  sampleRate,
int  channels,
int  blockAlign,
const uint8_t *  extra = nullptr,
size_t  extraSize = 0 
)
inline

Starts the decoder with the parameters found in the header of the stream.

◆ begin() [3/3]

virtual bool begin ( AudioInfo  info)
inlineoverridevirtualinherited

Reimplemented from AudioWriter.

Reimplemented in DecoderBasic, and OggContainerDecoder.

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ decodeFrame()

void decodeFrame ( )
inlineprotected

◆ end()

void end ( )
inlineoverridevirtual

Reimplemented from AudioDecoder.

◆ flush()

void flush ( )
inline

Drops partial data and resets the decoder state, e.g. after a seek.

◆ frameSize()

int frameSize ( )
inline

Size of one ATRAC frame in bytes.

◆ getOutput()

Print * getOutput ( )
inlineinherited

◆ getType()

ATRACType getType ( )
inline

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ isResultPCM()

virtual bool isResultPCM ( )
inlinevirtualinherited

Returns true to indicate that the decoding result is PCM data.

Reimplemented in CopyDecoder, DecoderNetworkFormat, and ContainerM4A.

◆ mime()

const char * mime ( )
inlineoverridevirtual

Provides the mime type of the data that is expected by this decoder.

Implements AudioDecoder.

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

operator bool ( )
inlineoverridevirtual

Implements AudioWriter.

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport &  bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  from)
inlineoverridevirtualinherited

for most decoders this is not needed

Implements AudioWriter.

Reimplemented in DecoderALAC, CodecChain, DSFDecoder, DecoderL8, OpusAudioDecoder, OpusMultiStreamAudioDecoder, CodecNOP, G729Decoder, and G7xxDecoder.

◆ setBlockSize()

void setBlockSize ( int  blockSize)
inlineoverridevirtual

Defines the size of one ATRAC frame (block align) in bytes.

Implements AudioDecoderExt.

◆ setCodecConfig()

bool setCodecConfig ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Defines the codec specific header (e.g. the WAV fmt extension)

Reimplemented from AudioDecoder.

◆ setExtraData()

void setExtraData ( const uint8_t *  data,
size_t  len 
)
inlineoverridevirtual

Defines the codec specific header (e.g. the WAV fmt extension)

Reimplemented from AudioDecoderExt.

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active)

◆ setOutput() [1/3]

virtual void setOutput ( AudioOutput &  out_stream)
inlinevirtualinherited

Defines where the decoded result is written to.

Reimplemented in ContainerATRAC, ADTSDecoder, CodecChain, MTSDecoder, MTSDecoderTSDemux, and MetaDataFilterDecoder.

◆ setOutput() [2/3]

virtual void setOutput ( AudioStream &  out_stream)
inlinevirtualinherited

Defines where the decoded result is written to.

Reimplemented in ContainerATRAC, ADTSDecoder, CodecChain, MTSDecoder, MTSDecoderTSDemux, and MetaDataFilterDecoder.

◆ setOutput() [3/3]

virtual void setOutput ( Print &  out_stream)
inlineoverridevirtualinherited

◆ setType()

void setType ( ATRACType  type)
inline

Defines the ATRAC variant (must be called before begin())

◆ wavFormat()

AudioFormat wavFormat ( )
inlineoverridevirtual

Provides the WAV format tag of the selected type, so that the decoder can be registered with WAVDecoder::addDecoder(): ATRAC3, ATRAC3+ and ATRAC9 are supported in WAV files

Reimplemented from AudioDecoderExt.

◆ write()

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

Decodes the data: any amount of data can be provided.

Implements AudioWriter.

◆ writeBlocking()

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

Member Data Documentation

◆ block_align

int block_align = 0
protected

◆ extradata

Vector<uint8_t> extradata
protected

◆ frame

Vector<uint8_t> frame
protected

◆ frame_pos

size_t frame_pos = 0
protected

◆ frame_size

int frame_size = 0
protected

◆ id

int id
inherited

custom id to be used by application

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ is_open

bool is_open = false
protected

◆ MAX_SAMPLES_PER_FRAME

const int MAX_SAMPLES_PER_FRAME = 2048
staticprotected

ATRAC3+ has the largest frames: 2048 samples per channel.

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ p_decoder

ATRACDecoder* p_decoder = nullptr
protected

◆ p_print

Print* p_print = nullptr
protectedinherited

◆ pcm

Vector<int16_t> pcm
protected

◆ type

ATRACType type = ATRAC3
protected

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