DSF2FLAC
|
#include <dsd_decimator.h>
dsdDecimator::dsdDecimator | ( | dsdSampleReader * | r, |
dsf2flac_uint32 | rate | ||
) |
dsdDecimator::dsdDecimator(dsdSampleReader *r, dsf2flac_uint32 rate)
Constructor!
Pass in a dsdSampleReader and the desired output sample rate.
dsdDecimator::~dsdDecimator | ( | ) | [virtual] |
Destructor! Free the lookuptable
dsf2flac_uint32 dsdDecimator::getDecimationRatio | ( | ) | [inline] |
std::string dsdDecimator::getErrorMsg | ( | ) |
bool dsdDecimator::getErrorMsg()
Returns a message describing the last error which caused the reader to become invalid.
unsigned long long int dsdDecimator::dsdDecimator::getLength()
Return the data length in output samples
dsf2flac_uint32 dsdDecimator::getNumChannels | ( | ) | [inline] |
dsf2flac_uint32 dsdDecimator::getOutputSampleRate()
Return the output sample rate
unsigned long long int dsdDecimator::dsdDecimator::getPosition()
Return the current position in output samples
dsf2flac_float64 dsdDecimator::getPositionAsPercent | ( | ) | [inline] |
dsf2flac_float64 dsdDecimator::getPositionInSeconds | ( | ) | [inline] |
void dsdDecimator::getSamples | ( | sampleType * | buffer, |
dsf2flac_uint32 | bufferLen, | ||
dsf2flac_float64 | scale, | ||
dsf2flac_float64 | tpdfDitherPeakAmplitude = 0 |
||
) |
void dsdDecimator::getSamples | ( | short int * | buffer, |
dsf2flac_uint32 | bufferLen, | ||
dsf2flac_float64 | scale, | ||
dsf2flac_float64 | tpdfDitherPeakAmplitude | ||
) |
template <typename sampletype>=""> void getSamples(sampleType *buffer, dsf2flac_uint32 bufferLen, dsf2flac_float64 scale, dsf2flac_float64 tpdfDitherPeakAmplitude);
Read pcm output samples in format sampleType into a buffer of length bufferLen. bufferLen must be a multiple of getNumChannels(). Channels are interleaved into the buffer.
You also need to provide a scaling factor. This is particularly important for int sample types. The raw dsd data has peak amplitude +-1.
If you wish to add TPDF dither to the data before quantization then please also provide the peak amplitude.
These sample types are supported:
short int int long int float dsf2flac_float64
Others should be very simple to add (just take a look at the templates below).
void dsdDecimator::getSamples | ( | int * | buffer, |
dsf2flac_uint32 | bufferLen, | ||
dsf2flac_float64 | scale, | ||
dsf2flac_float64 | tpdfDitherPeakAmplitude | ||
) |
void dsdDecimator::getSamples | ( | long int * | buffer, |
dsf2flac_uint32 | bufferLen, | ||
dsf2flac_float64 | scale, | ||
dsf2flac_float64 | tpdfDitherPeakAmplitude | ||
) |
void dsdDecimator::getSamples | ( | float * | buffer, |
dsf2flac_uint32 | bufferLen, | ||
dsf2flac_float64 | scale, | ||
dsf2flac_float64 | tpdfDitherPeakAmplitude | ||
) |
void dsdDecimator::getSamples | ( | double * | buffer, |
dsf2flac_uint32 | bufferLen, | ||
dsf2flac_float64 | scale, | ||
dsf2flac_float64 | tpdfDitherPeakAmplitude | ||
) |
void dsdDecimator::getSamplesInternal | ( | sampleType * | buffer, |
dsf2flac_uint32 | bufferLen, | ||
dsf2flac_float64 | scale, | ||
dsf2flac_float64 | tpdfDitherPeakAmplitude, | ||
bool | roundToInt | ||
) | [private] |
template <typename sampletype>=""> void dsdDecimator::getSamplesInternal(sampleType *buffer, dsf2flac_uint32 bufferLen, dsf2flac_float64 scale, dsf2flac_float64 tpdfDitherPeakAmplitude, bool roundToInt)
private method. Does the actual calculation for the getSamples method. Using the lookup tables FIR calculation is a pretty simple summing operation.
void dsdDecimator::initLookupTable | ( | const dsf2flac_int32 | nCoefs, |
const dsf2flac_float64 * | coefs, | ||
const dsf2flac_int32 | tzero | ||
) | [private] |
void dsdDecimator::initLookupTable(const dsf2flac_float64 nCoefs,const dsf2flac_float64* coefs)
private method. Initialises the lookup table used for very fast filtering.
bool dsdDecimator::isValid | ( | ) |
Return false if the reader is invalid (format/file error for example).
void dsdDecimator::step | ( | ) | [inline] |
std::string dsdDecimator::errorMsg [private] |
calc_type** dsdDecimator::lookupTable [private] |
dsf2flac_uint32 dsdDecimator::nLookupTable [private] |
dsf2flac_uint32 dsdDecimator::nStep [private] |
dsf2flac_uint32 dsdDecimator::ratio [private] |
dsdSampleReader* dsdDecimator::reader [private] |
dsf2flac_uint32 dsdDecimator::tzero [private] |
bool dsdDecimator::valid [private] |