arduino-audio-tools
Loading...
Searching...
No Matches
DSFDecoder Class Reference

Decodes DSF files containing DSD audio and converts to PCM. More...

#include <CodecDSF.h>

Inheritance diagram for DSFDecoder:
AudioDecoder AudioWriter AudioInfoSource AudioWriter AudioInfoSource AudioInfoSupport AudioInfoSupport AudioInfoSupport AudioInfoSupport

Public Member Functions

 DSFDecoder ()=default
 DSFDecoder (DSFMetadata metaData)
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
AudioInfo audioInfo () override
 provides the actual input AudioInfo
virtual AudioInfo audioInfoOut ()
virtual AudioInfo audioInfoOut ()
virtual bool begin (AudioInfo info) override
bool begin ()
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
void end () override
const DSFMetadata getMetadata ()
Print * getOutput ()
Print * getOutput ()
bool isHeaderAvailable ()
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
virtual bool isResultPCM ()
 Returns true to indicate that the decoding result is PCM data.
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 ()
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
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 setAudioInfo (AudioInfo from) override
virtual bool setCodecConfig (const uint8_t *data, size_t len)
 Some decoders need e.g. a magic cookie to provide the relevant info for decoding.
virtual bool setCodecConfig (const uint8_t *data, size_t len)
 Some decoders need e.g. a magic cookie to provide the relevant info for decoding.
void setInfoCallback (void(*callback)(const DSFFormat &fmt))
 Register a callback that receives the raw DSFFormat header after parsing.
void setMetaData (DSFMetadata metaData)
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active).
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 (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 (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.
virtual void setOutput (Print &out_stream) override
 Defines where the decoded result is written to.
size_t write (const uint8_t *data, size_t len)

Public Attributes

int id
 custom id to be used by application

Protected Member Functions

bool allChannelsHaveData (int bytesNeeded)
size_t bufferDSDData (const uint8_t *data, size_t len, size_t startPos)
float clip (float value)
void convertDSDToPCM ()
int findTag (const char *tag, const uint8_t *data, size_t len)
int getFilterStages ()
int getOutputBufferSize ()
void notifyAudioChange (AudioInfo info)
void notifyAudioChange (AudioInfo info)
bool parseData (const uint8_t *data, size_t len)
bool parseFMT (const uint8_t *data, size_t len)
int popcount8 (uint8_t v)
size_t processDSDData (const uint8_t *data, size_t len, size_t startPos)
size_t processHeader (const uint8_t *data, size_t len)
void setupDecimationStep ()
void setupFilters ()
void writeBlocking (Print *out, uint8_t *data, size_t len)
void writeBlocking (Print *out, uint8_t *data, size_t len)
void writePCMSample (float filteredValue)

Protected Attributes

uint32_t blockPos = 0
Vector< SingleBuffer< uint8_t > > channelDsdBuffers
Vector< LowPassFilter< float > > channelFilters
uint32_t decimationStep
bool headerParsed = false
AudioInfo info
void(* infoCallback )(const DSFFormat &fmt) = nullptr
bool is_notify_active = true
bool isActive = false
DSFMetadata meta
Vector< AudioInfoSupport * > notify_vector
Print * p_print = nullptr
SingleBuffer< uint8_t > pcmBuffer {0}

Detailed Description

Decodes DSF files containing DSD audio and converts to PCM.

Author
pschatzmann

Uses per-channel buffers for correct block-level de-interleaving, bit-counting decimation, and cascaded Butterworth low-pass filters for anti-aliasing.

Constructor & Destructor Documentation

◆ DSFDecoder() [1/2]

DSFDecoder ( )
default

◆ DSFDecoder() [2/2]

DSFDecoder ( DSFMetadata metaData)
inline

Member Function Documentation

◆ addNotifyAudioChange() [1/2]

virtual void addNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Adds target to be notified about audio changes.

Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.

◆ addNotifyAudioChange() [2/2]

virtual void addNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

Adds target to be notified about audio changes.

Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.

◆ allChannelsHaveData()

bool allChannelsHaveData ( int bytesNeeded)
inlineprotected

◆ audioInfo()

AudioInfo audioInfo ( )
inlineoverridevirtual

provides the actual input AudioInfo

Reimplemented from AudioDecoder.

◆ audioInfoOut() [1/2]

◆ audioInfoOut() [2/2]

◆ begin() [1/2]

virtual bool begin ( AudioInfo info)
inlineoverridevirtualinherited

Reimplemented from AudioWriter.

◆ begin() [2/2]

bool begin ( )
inlinevirtual

Reimplemented from AudioDecoder.

◆ bufferDSDData()

size_t bufferDSDData ( const uint8_t * data,
size_t len,
size_t startPos )
inlineprotected

◆ clearNotifyAudioChange() [1/2]

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

◆ clearNotifyAudioChange() [2/2]

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

◆ clip()

float clip ( float value)
inlineprotected

◆ convertDSDToPCM()

void convertDSDToPCM ( )
inlineprotected

◆ end()

void end ( )
inlineoverridevirtual

Reimplemented from AudioDecoder.

◆ findTag()

int findTag ( const char * tag,
const uint8_t * data,
size_t len )
inlineprotected

◆ getFilterStages()

int getFilterStages ( )
inlineprotected

◆ getMetadata()

const DSFMetadata getMetadata ( )
inline

◆ getOutput() [1/2]

Print * getOutput ( )
inlineinherited

◆ getOutput() [2/2]

Print * getOutput ( )
inlineinherited

◆ getOutputBufferSize()

int getOutputBufferSize ( )
inlineprotected

◆ isHeaderAvailable()

bool isHeaderAvailable ( )
inline

◆ isNotifyActive() [1/2]

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ isNotifyActive() [2/2]

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ isResultPCM() [1/2]

virtual bool isResultPCM ( )
inlinevirtualinherited

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

Reimplemented in ContainerM4A, CopyDecoder, and DecoderNetworkFormat.

◆ isResultPCM() [2/2]

virtual bool isResultPCM ( )
inlinevirtualinherited

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

Reimplemented in ContainerM4A, CopyDecoder, and DecoderNetworkFormat.

◆ mime()

const char * mime ( )
inlineoverridevirtual

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

Implements AudioDecoder.

◆ notifyAudioChange() [1/2]

void notifyAudioChange ( AudioInfo info)
inlineprotectedinherited

◆ notifyAudioChange() [2/2]

void notifyAudioChange ( AudioInfo info)
inlineprotectedinherited

◆ operator bool()

operator bool ( )
inlinevirtual

Implements AudioWriter.

◆ parseData()

bool parseData ( const uint8_t * data,
size_t len )
inlineprotected

◆ parseFMT()

bool parseFMT ( const uint8_t * data,
size_t len )
inlineprotected

◆ popcount8()

int popcount8 ( uint8_t v)
inlineprotected

◆ processDSDData()

size_t processDSDData ( const uint8_t * data,
size_t len,
size_t startPos )
inlineprotected

◆ processHeader()

size_t processHeader ( const uint8_t * data,
size_t len )
inlineprotected

◆ removeNotifyAudioChange() [1/2]

virtual bool removeNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

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

◆ removeNotifyAudioChange() [2/2]

virtual bool removeNotifyAudioChange ( AudioInfoSupport & bi)
inlinevirtualinherited

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

◆ setAudioInfo() [1/2]

void setAudioInfo ( AudioInfo from)
inlineoverridevirtualinherited

for most decoders this is not needed

Implements AudioWriter.

Reimplemented in CodecNOP, and CodecNOP.

◆ setAudioInfo() [2/2]

void setAudioInfo ( AudioInfo from)
inlineoverride

◆ setCodecConfig() [1/2]

virtual bool setCodecConfig ( const uint8_t * data,
size_t len )
inlinevirtualinherited

Some decoders need e.g. a magic cookie to provide the relevant info for decoding.

Reimplemented in DecoderALAC, and MultiDecoder.

◆ setCodecConfig() [2/2]

virtual bool setCodecConfig ( const uint8_t * data,
size_t len )
inlinevirtualinherited

Some decoders need e.g. a magic cookie to provide the relevant info for decoding.

Reimplemented in DecoderALAC, and MultiDecoder.

◆ setInfoCallback()

void setInfoCallback ( void(* callback )(const DSFFormat &fmt))
inline

Register a callback that receives the raw DSFFormat header after parsing.

◆ setMetaData()

void setMetaData ( DSFMetadata metaData)
inline

◆ setNotifyActive() [1/2]

void setNotifyActive ( bool flag)
inlineinherited

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

◆ setNotifyActive() [2/2]

void setNotifyActive ( bool flag)
inlineinherited

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

◆ setOutput() [1/6]

virtual void setOutput ( AudioOutput & out_stream)
inlinevirtualinherited

Defines where the decoded result is written to.

◆ setOutput() [2/6]

virtual void setOutput ( AudioOutput & out_stream)
inlinevirtualinherited

Defines where the decoded result is written to.

◆ setOutput() [3/6]

virtual void setOutput ( AudioStream & out_stream)
inlinevirtualinherited

Defines where the decoded result is written to.

◆ setOutput() [4/6]

virtual void setOutput ( AudioStream & out_stream)
inlinevirtualinherited

Defines where the decoded result is written to.

◆ setOutput() [5/6]

◆ setOutput() [6/6]

◆ setupDecimationStep()

void setupDecimationStep ( )
inlineprotected

◆ setupFilters()

void setupFilters ( )
inlineprotected

◆ write()

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

Implements AudioWriter.

◆ writeBlocking() [1/2]

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

◆ writeBlocking() [2/2]

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

◆ writePCMSample()

void writePCMSample ( float filteredValue)
inlineprotected

Member Data Documentation

◆ blockPos

uint32_t blockPos = 0
protected

◆ channelDsdBuffers

Vector<SingleBuffer<uint8_t> > channelDsdBuffers
protected

◆ channelFilters

Vector<LowPassFilter<float> > channelFilters
protected

◆ decimationStep

uint32_t decimationStep
protected

◆ headerParsed

bool headerParsed = false
protected

◆ id

int id
inherited

custom id to be used by application

◆ info

AudioInfo info
protectedinherited

◆ infoCallback

void(* infoCallback) (const DSFFormat &fmt) = nullptr
protected

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ isActive

bool isActive = false
protected

◆ meta

DSFMetadata meta
protected

◆ notify_vector

Vector< AudioInfoSupport * > notify_vector
protectedinherited

◆ p_print

Print * p_print = nullptr
protectedinherited

◆ pcmBuffer

SingleBuffer<uint8_t> pcmBuffer {0}
protected

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