struct RemiAudio::DSP::Ditherer
- RemiAudio::DSP::Ditherer
- Struct
- Value
- Object
Overview
A record that is used to hold dithering state for TPDF dithering. This structure can be used to convert samples from one type to another.
The Ditherer struct also contains methods for converting sample formats
without dithering.
Defined in:
remiaudio/dsp/ditherer.crConstructors
Class Method Summary
-
.withConvertedSamples(from : SampleData, srcFormat : SampleFormat, destFormat : SampleFormat, *, useNoiseShaping : Bool = false, & : Sample, Int32 -> )
For each sample in
from, this converts the sample using aDithererto the destination format, then yields the converted sample and its index. -
.withDitheredSamples(from : RemiAudio::SampleData, srcFormat : SampleFormat, targetBitDepth : Int, *, useNoiseShaping : Bool = false, & : RemiAudio::Sample, Int32 -> )
For each sample in
from, this converts the sample using aDithererto the destination format, then yields the converted sample and its index.
Instance Method Summary
-
#dither(sample : RemiAudio::Sample, srcFormat : SampleFormat, targetBitDepth : Int, *, useNoiseShaping = false) : Sample
Converts
sampleto a signed integer sample oftargetBitDepthbits while applying TPDF dithering when needed. -
#ditherOrConvert(sample : RemiAudio::Sample, srcFormat : SampleFormat, destFormat : SampleFormat, *, useNoiseShaping : Bool = false) : RemiAudio::Sample
Converts
samplefromsrcFormattodestFormat, applying dithering using#ditheras-needed.
Constructor Detail
Class Method Detail
For each sample in from, this converts the sample using a Ditherer to
the destination format, then yields the converted sample and its index.
Unlike Ditherer.withDitheredSamples, this uses the #ditherOrConvert
method internally.
For each sample in from, this converts the sample using a Ditherer to
the destination format, then yields the converted sample and its index.
Instance Method Detail
Converts sample to a signed integer sample of targetBitDepth bits
while applying TPDF dithering when needed. The format of sample must be
supplied via srcFormat. The returned value is guaranteed to fit in
targetBitDepth bits.
If the sample is already an integer sample, and targetBitDepth is
already greater than or equal to the current bit depth, then the sample is
simply coerced to the appropriate integer type without dithering.
Unsupported bit depths will cause this to raise an InvalidBitDepthError.
Converts sample from srcFormat to destFormat, applying dithering
using #dither as-needed.
Unlike the #dither method, this knows how to convert between float
formats.