DSF2FLAC
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions
DsfFileReader Class Reference

This class extends dsdSampleReader providing access to dsd samples and other info from dsf files. More...

#include <dsf_file_reader.h>

Inheritance diagram for DsfFileReader:
DsdSampleReader

List of all members.

Public Member Functions

 DsfFileReader (char *filePath)
 Class constructor.
virtual ~DsfFileReader ()
 Class destructor.
dsf2flac_uint32 getSamplingFreq ()
 Returns the DSD sampling rate of this reader (Hz).
bool step ()
 Step the reader forward by 8 DSD samples.
void rewind ()
 Set the reader position back to the start of the DSD data.
dsf2flac_int64 getLength ()
 Returns the total number of DSD samples in the reader.
dsf2flac_uint32 getNumChannels ()
 Returns the number of channels in the reader.
bool msbIsPlayedFirst ()
 Describes the order that the samples are packed into the int8 buffer entries.
bool samplesAvailable ()
 Returns false if there are no more samples left in the reader.
ID3_Tag getID3Tag (dsf2flac_uint32 trackNum)
 Return the ID3 tag corresponding to the provided track number.
void dispFileInfo ()
 Can be called to display some useful info to stdout.
bool isValid ()
 Return false if the reader is invalid (format/file error for example).
std::string getErrorMsg ()
 Returns a message explaining why the reader is invalid.
dsf2flac_float64 getLengthInSeconds ()
 Returns the total length of the reader in seconds.
virtual dsf2flac_uint32 getNumTracks ()
 Returns the number of audio tracks in the reader.
virtual dsf2flac_uint64 getTrackStart (dsf2flac_uint32 trackNum)
 Returns the start position of the specified track.
virtual dsf2flac_uint64 getTrackEnd (dsf2flac_uint32 trackNum)
 Returns the end position of the specified track.
dsf2flac_int64 getPosition ()
 Return the current position of the reader in DSD samples.
dsf2flac_float64 getPositionInSeconds ()
 Return the current position of the reader in seconds.
dsf2flac_float64 getPositionAsPercent ()
 Return the current position of the reader as a percent of the total length.
boost::circular_buffer
< dsf2flac_uint8 > * 
getBuffer ()
 Returns an array of circular buffers, one for each track.
dsf2flac_uint32 getBufferLength ()
 Returns the length of the buffers (the number of uint8 numbers, NOT the number of DSD samples).
bool setBufferLength (dsf2flac_uint32 bufferLength)
 Sets the length of the buffers (the number of uint8 numbers, NOT the number of DSD samples).
ID3_Tag getID3Tag ()
 Return the ID3 tag of the first track in this reader.
virtual dsf2flac_uint8 getIdleSample ()
 Return the idle tone used by this reader, by default the buffers are populated with this idle tone.

Static Public Member Functions

static char * latin1_to_utf8 (char *latin1)
 convert latin1 encoded char into utf8.

Protected Member Functions

void allocateBuffer ()
 Allocates the circular buffers.
void clearBuffer ()
 Clear the buffers and fill with idleSample.

Private Member Functions

void allocateBlockBuffer ()
 Allocates the block buffer which holds the dsd data read from the file for when it is required by the circular buffer.
bool readHeaders ()
 Reads lots of info from the file.
void readMetadata ()
 Attempts to read the metadata from the end of the dsf file.
bool readNextBlock ()
 This private function is called whenever new data from the file is needed for the block buffer.

Static Private Member Functions

static bool checkIdent (dsf2flac_int8 *a, dsf2flac_int8 *b)
 A handy little helper for checking idents.

Detailed Description

This class extends dsdSampleReader providing access to dsd samples and other info from dsf files.

Some of the rarer features of dsf are not well tested due to a lack of files: 8bit dsd


Constructor & Destructor Documentation

DsfFileReader::DsfFileReader ( char *  filePath)

Class constructor.

filePath must be a valid dsf file location. If there is an issue reading or loading the file then isValid() will be false.

Class destructor.

Closes the file and frees the internal buffers.


Member Function Documentation

Allocates the block buffer which holds the dsd data read from the file for when it is required by the circular buffer.

void DsdSampleReader::allocateBuffer ( ) [protected, inherited]

Allocates the circular buffers.

Child classes need to call this once they know the number of channels!

bool DsfFileReader::checkIdent ( dsf2flac_int8 *  a,
dsf2flac_int8 *  b 
) [static, private]

A handy little helper for checking idents.

void DsdSampleReader::clearBuffer ( ) [protected, inherited]

Clear the buffers and fill with idleSample.

Can be called to display some useful info to stdout.

boost::circular_buffer< dsf2flac_uint8 > * DsdSampleReader::getBuffer ( ) [inherited]

Returns an array of circular buffers, one for each track.

Each circular buffer contains getBufferLength() uint8 numbers. The DSD samples are packed into these uint8 numbers. The next uint8 set of 8 DSD samples is added into position 0 when step() is called. By default the buffer is filled with getIdleSample().

dsf2flac_uint32 DsdSampleReader::getBufferLength ( ) [inherited]

Returns the length of the buffers (the number of uint8 numbers, NOT the number of DSD samples).

std::string DsdSampleReader::getErrorMsg ( ) [inherited]

Returns a message explaining why the reader is invalid.

ID3_Tag DsfFileReader::getID3Tag ( dsf2flac_uint32  trackNum) [inline, virtual]

Return the ID3 tag corresponding to the provided track number.

Reimplemented from DsdSampleReader.

ID3_Tag DsdSampleReader::getID3Tag ( ) [inline, inherited]

Return the ID3 tag of the first track in this reader.

Useful for when there is only a single track in the reader.

virtual dsf2flac_uint8 DsdSampleReader::getIdleSample ( ) [inline, virtual, inherited]

Return the idle tone used by this reader, by default the buffers are populated with this idle tone.

dsf2flac_int64 DsfFileReader::getLength ( ) [inline, virtual]

Returns the total number of DSD samples in the reader.

Implements DsdSampleReader.

dsf2flac_float64 DsdSampleReader::getLengthInSeconds ( ) [inherited]

Returns the total length of the reader in seconds.

dsf2flac_uint32 DsfFileReader::getNumChannels ( ) [inline, virtual]

Returns the number of channels in the reader.

Implements DsdSampleReader.

virtual dsf2flac_uint32 DsdSampleReader::getNumTracks ( ) [inline, virtual, inherited]

Returns the number of audio tracks in the reader.

Reimplemented in DsdiffFileReader.

dsf2flac_int64 DsdSampleReader::getPosition ( ) [inline, inherited]

Return the current position of the reader in DSD samples.

This is the position of the first entry in the circular buffers.

dsf2flac_float64 DsdSampleReader::getPositionAsPercent ( ) [inherited]

Return the current position of the reader as a percent of the total length.

dsf2flac_float64 DsdSampleReader::getPositionInSeconds ( ) [inherited]

Return the current position of the reader in seconds.

dsf2flac_uint32 DsfFileReader::getSamplingFreq ( ) [inline, virtual]

Returns the DSD sampling rate of this reader (Hz).

Implements DsdSampleReader.

virtual dsf2flac_uint64 DsdSampleReader::getTrackEnd ( dsf2flac_uint32  trackNum) [inline, virtual, inherited]

Returns the end position of the specified track.

Reimplemented in DsdiffFileReader.

virtual dsf2flac_uint64 DsdSampleReader::getTrackStart ( dsf2flac_uint32  trackNum) [inline, virtual, inherited]

Returns the start position of the specified track.

Reimplemented in DsdiffFileReader.

bool DsdSampleReader::isValid ( ) [inherited]

Return false if the reader is invalid (format/file error for example).

static char* DsdSampleReader::latin1_to_utf8 ( char *  latin1) [static, inherited]

convert latin1 encoded char into utf8.

bool DsfFileReader::msbIsPlayedFirst ( ) [inline, virtual]

Describes the order that the samples are packed into the int8 buffer entries.

Implements DsdSampleReader.

bool DsfFileReader::readHeaders ( ) [private]

Reads lots of info from the file.

void DsfFileReader::readMetadata ( ) [private]

Attempts to read the metadata from the end of the dsf file.

bool DsfFileReader::readNextBlock ( ) [private]

This private function is called whenever new data from the file is needed for the block buffer.

void DsfFileReader::rewind ( ) [virtual]

Set the reader position back to the start of the DSD data.

Note that child classes implementing this method must call clearBuffer();

Implements DsdSampleReader.

bool DsfFileReader::samplesAvailable ( ) [inline, virtual]

Returns false if there are no more samples left in the reader.

Reimplemented from DsdSampleReader.

bool DsdSampleReader::setBufferLength ( dsf2flac_uint32  bufferLength) [inherited]

Sets the length of the buffers (the number of uint8 numbers, NOT the number of DSD samples).

Note that this will cause rewind() to be called.

bool DsfFileReader::step ( ) [virtual]

Step the reader forward by 8 DSD samples.

This causes the next 8 DSD samples to be added into the front of the circular buffers (one uint8).

Implements DsdSampleReader.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables