CopySamples gives more than binary choice of dither algorithm...
... And so a separate function CopySamplesNoDither is not needed
This commit is contained in:
parent
6eb5f3ac5b
commit
50a26d9caf
|
@ -691,7 +691,7 @@ size_t Mixer::Process(size_t maxToProcess)
|
|||
mBuffer[0].ptr() + (c * SAMPLE_SIZE(mFormat)),
|
||||
mFormat,
|
||||
maxOut,
|
||||
mHighQuality,
|
||||
mHighQuality ? gHighQualityDither : gLowQualityDither,
|
||||
mNumChannels,
|
||||
mNumChannels);
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ size_t Mixer::Process(size_t maxToProcess)
|
|||
mBuffer[c].ptr(),
|
||||
mFormat,
|
||||
maxOut,
|
||||
mHighQuality);
|
||||
mHighQuality ? gHighQualityDither : gLowQualityDither);
|
||||
}
|
||||
}
|
||||
// MB: this doesn't take warping into account, replaced with code based on mSamplePos
|
||||
|
|
|
@ -43,11 +43,10 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "Prefs.h"
|
||||
#include "Dither.h"
|
||||
#include "Internat.h"
|
||||
|
||||
static DitherType gLowQualityDither = DitherType::none;
|
||||
static DitherType gHighQualityDither = DitherType::none;
|
||||
DitherType gLowQualityDither = DitherType::none;
|
||||
DitherType gHighQualityDither = DitherType::shaped;
|
||||
static Dither gDitherAlgorithm;
|
||||
|
||||
void InitDitherers()
|
||||
|
@ -104,29 +103,17 @@ void SamplesToFloats(constSamplePtr src, sampleFormat srcFormat,
|
|||
{
|
||||
CopySamples( src, srcFormat,
|
||||
reinterpret_cast<samplePtr>(dst), floatSample, len,
|
||||
true, // doesn't matter, no dither happens when destination is float
|
||||
DitherType::none,
|
||||
srcStride, dstStride);
|
||||
}
|
||||
|
||||
void CopySamples(constSamplePtr src, sampleFormat srcFormat,
|
||||
samplePtr dst, sampleFormat dstFormat,
|
||||
unsigned int len,
|
||||
bool highQuality, /* = true */
|
||||
unsigned int srcStride /* = 1 */,
|
||||
unsigned int dstStride /* = 1 */)
|
||||
samplePtr dst, sampleFormat dstFormat, size_t len,
|
||||
DitherType ditherType, /* = gHighQualityDither */
|
||||
unsigned int srcStride /* = 1 */,
|
||||
unsigned int dstStride /* = 1 */)
|
||||
{
|
||||
gDitherAlgorithm.Apply(
|
||||
highQuality ? gHighQualityDither : gLowQualityDither,
|
||||
src, srcFormat, dst, dstFormat, len, srcStride, dstStride);
|
||||
}
|
||||
|
||||
void CopySamplesNoDither(samplePtr src, sampleFormat srcFormat,
|
||||
samplePtr dst, sampleFormat dstFormat,
|
||||
unsigned int len,
|
||||
unsigned int srcStride /* = 1 */,
|
||||
unsigned int dstStride /* = 1 */)
|
||||
{
|
||||
gDitherAlgorithm.Apply(
|
||||
DitherType::none,
|
||||
ditherType,
|
||||
src, srcFormat, dst, dstFormat, len, srcStride, dstStride);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
SampleFormat.h
|
||||
@file SampleFormat.h
|
||||
|
||||
Dominic Mazzoni
|
||||
|
||||
|
@ -17,11 +17,15 @@
|
|||
#include <wx/defs.h>
|
||||
|
||||
#include "audacity/Types.h"
|
||||
#include "Dither.h"
|
||||
|
||||
//
|
||||
// Definitions / Meta-Information
|
||||
//
|
||||
|
||||
//! These global variables are assigned at application startup or after change of preferences.
|
||||
extern AUDACITY_DLL_API DitherType gLowQualityDither, gHighQualityDither;
|
||||
|
||||
#if 0
|
||||
// Moved to audacity/types.h
|
||||
typedef enum {
|
||||
|
@ -138,18 +142,16 @@ void SamplesToFloats(constSamplePtr src, sampleFormat srcFormat,
|
|||
float *dst, size_t len, size_t srcStride = 1, size_t dstStride = 1);
|
||||
|
||||
AUDACITY_DLL_API
|
||||
void CopySamples(constSamplePtr src, sampleFormat srcFormat,
|
||||
samplePtr dst, sampleFormat dstFormat,
|
||||
unsigned int len, bool highQuality=true,
|
||||
unsigned int srcStride=1,
|
||||
unsigned int dstStride=1);
|
||||
|
||||
AUDACITY_DLL_API
|
||||
void CopySamplesNoDither(samplePtr src, sampleFormat srcFormat,
|
||||
samplePtr dst, sampleFormat dstFormat,
|
||||
unsigned int len,
|
||||
unsigned int srcStride=1,
|
||||
unsigned int dstStride=1);
|
||||
//! Copy samples from any format to any other format; apply dithering only if narrowing the format
|
||||
/*!
|
||||
@copydetails SamplesToFloats()
|
||||
@param dstFormat format of destination samples, determines sizeof each one
|
||||
@param ditherType choice of dithering algorithm to use if narrowing the format
|
||||
*/
|
||||
void CopySamples(constSamplePtr src, sampleFormat srcFormat,
|
||||
samplePtr dst, sampleFormat dstFormat, size_t len,
|
||||
DitherType ditherType = gHighQualityDither, //!< default is loaded from a global variable
|
||||
unsigned int srcStride=1, unsigned int dstStride=1);
|
||||
|
||||
AUDACITY_DLL_API
|
||||
void ClearSamples(samplePtr buffer, sampleFormat format,
|
||||
|
|
|
@ -1248,7 +1248,7 @@ bool WaveClip::Append(constSamplePtr buffer, sampleFormat format,
|
|||
mAppendBuffer.ptr() + mAppendBufferLen * SAMPLE_SIZE(seqFormat),
|
||||
seqFormat,
|
||||
toCopy,
|
||||
true, // high quality
|
||||
gHighQualityDither,
|
||||
stride);
|
||||
|
||||
mAppendBufferLen += toCopy;
|
||||
|
|
|
@ -643,12 +643,13 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
|||
CopySamples(
|
||||
mixed + (c * SAMPLE_SIZE(format)), format,
|
||||
dither.data() + (c * SAMPLE_SIZE(int24Sample)), int24Sample,
|
||||
numSamples, true, info.channels, info.channels
|
||||
numSamples, gHighQualityDither, info.channels, info.channels
|
||||
);
|
||||
CopySamplesNoDither(
|
||||
// Copy back without dither
|
||||
CopySamples(
|
||||
dither.data() + (c * SAMPLE_SIZE(int24Sample)), int24Sample,
|
||||
mixed + (c * SAMPLE_SIZE(format)), format,
|
||||
numSamples, info.channels, info.channels);
|
||||
numSamples, DitherType::none, info.channels, info.channels);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1640,7 +1640,7 @@ bool AUPImportFileHandle::AddSamples(const FilePath &blockFilename,
|
|||
bufptr,
|
||||
format,
|
||||
framesRead,
|
||||
true /* high quality by default */,
|
||||
gHighQualityDither /* high quality by default */,
|
||||
channels /* source stride */);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue