mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-26 17:38:10 +02:00
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)),
|
mBuffer[0].ptr() + (c * SAMPLE_SIZE(mFormat)),
|
||||||
mFormat,
|
mFormat,
|
||||||
maxOut,
|
maxOut,
|
||||||
mHighQuality,
|
mHighQuality ? gHighQualityDither : gLowQualityDither,
|
||||||
mNumChannels,
|
mNumChannels,
|
||||||
mNumChannels);
|
mNumChannels);
|
||||||
}
|
}
|
||||||
@ -703,7 +703,7 @@ size_t Mixer::Process(size_t maxToProcess)
|
|||||||
mBuffer[c].ptr(),
|
mBuffer[c].ptr(),
|
||||||
mFormat,
|
mFormat,
|
||||||
maxOut,
|
maxOut,
|
||||||
mHighQuality);
|
mHighQuality ? gHighQualityDither : gLowQualityDither);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// MB: this doesn't take warping into account, replaced with code based on mSamplePos
|
// MB: this doesn't take warping into account, replaced with code based on mSamplePos
|
||||||
|
@ -43,11 +43,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "Prefs.h"
|
#include "Prefs.h"
|
||||||
#include "Dither.h"
|
|
||||||
#include "Internat.h"
|
#include "Internat.h"
|
||||||
|
|
||||||
static DitherType gLowQualityDither = DitherType::none;
|
DitherType gLowQualityDither = DitherType::none;
|
||||||
static DitherType gHighQualityDither = DitherType::none;
|
DitherType gHighQualityDither = DitherType::shaped;
|
||||||
static Dither gDitherAlgorithm;
|
static Dither gDitherAlgorithm;
|
||||||
|
|
||||||
void InitDitherers()
|
void InitDitherers()
|
||||||
@ -104,29 +103,17 @@ void SamplesToFloats(constSamplePtr src, sampleFormat srcFormat,
|
|||||||
{
|
{
|
||||||
CopySamples( src, srcFormat,
|
CopySamples( src, srcFormat,
|
||||||
reinterpret_cast<samplePtr>(dst), floatSample, len,
|
reinterpret_cast<samplePtr>(dst), floatSample, len,
|
||||||
true, // doesn't matter, no dither happens when destination is float
|
DitherType::none,
|
||||||
srcStride, dstStride);
|
srcStride, dstStride);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CopySamples(constSamplePtr src, sampleFormat srcFormat,
|
void CopySamples(constSamplePtr src, sampleFormat srcFormat,
|
||||||
samplePtr dst, sampleFormat dstFormat,
|
samplePtr dst, sampleFormat dstFormat, size_t len,
|
||||||
unsigned int len,
|
DitherType ditherType, /* = gHighQualityDither */
|
||||||
bool highQuality, /* = true */
|
|
||||||
unsigned int srcStride /* = 1 */,
|
unsigned int srcStride /* = 1 */,
|
||||||
unsigned int dstStride /* = 1 */)
|
unsigned int dstStride /* = 1 */)
|
||||||
{
|
{
|
||||||
gDitherAlgorithm.Apply(
|
gDitherAlgorithm.Apply(
|
||||||
highQuality ? gHighQualityDither : gLowQualityDither,
|
ditherType,
|
||||||
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,
|
|
||||||
src, srcFormat, dst, dstFormat, len, srcStride, dstStride);
|
src, srcFormat, dst, dstFormat, len, srcStride, dstStride);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Audacity: A Digital Audio Editor
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
SampleFormat.h
|
@file SampleFormat.h
|
||||||
|
|
||||||
Dominic Mazzoni
|
Dominic Mazzoni
|
||||||
|
|
||||||
@ -17,11 +17,15 @@
|
|||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
|
|
||||||
#include "audacity/Types.h"
|
#include "audacity/Types.h"
|
||||||
|
#include "Dither.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Definitions / Meta-Information
|
// 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
|
#if 0
|
||||||
// Moved to audacity/types.h
|
// Moved to audacity/types.h
|
||||||
typedef enum {
|
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);
|
float *dst, size_t len, size_t srcStride = 1, size_t dstStride = 1);
|
||||||
|
|
||||||
AUDACITY_DLL_API
|
AUDACITY_DLL_API
|
||||||
|
//! 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,
|
void CopySamples(constSamplePtr src, sampleFormat srcFormat,
|
||||||
samplePtr dst, sampleFormat dstFormat,
|
samplePtr dst, sampleFormat dstFormat, size_t len,
|
||||||
unsigned int len, bool highQuality=true,
|
DitherType ditherType = gHighQualityDither, //!< default is loaded from a global variable
|
||||||
unsigned int srcStride=1,
|
unsigned int srcStride=1, unsigned int dstStride=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);
|
|
||||||
|
|
||||||
AUDACITY_DLL_API
|
AUDACITY_DLL_API
|
||||||
void ClearSamples(samplePtr buffer, sampleFormat format,
|
void ClearSamples(samplePtr buffer, sampleFormat format,
|
||||||
|
@ -1248,7 +1248,7 @@ bool WaveClip::Append(constSamplePtr buffer, sampleFormat format,
|
|||||||
mAppendBuffer.ptr() + mAppendBufferLen * SAMPLE_SIZE(seqFormat),
|
mAppendBuffer.ptr() + mAppendBufferLen * SAMPLE_SIZE(seqFormat),
|
||||||
seqFormat,
|
seqFormat,
|
||||||
toCopy,
|
toCopy,
|
||||||
true, // high quality
|
gHighQualityDither,
|
||||||
stride);
|
stride);
|
||||||
|
|
||||||
mAppendBufferLen += toCopy;
|
mAppendBufferLen += toCopy;
|
||||||
|
@ -643,12 +643,13 @@ ProgressResult ExportPCM::Export(AudacityProject *project,
|
|||||||
CopySamples(
|
CopySamples(
|
||||||
mixed + (c * SAMPLE_SIZE(format)), format,
|
mixed + (c * SAMPLE_SIZE(format)), format,
|
||||||
dither.data() + (c * SAMPLE_SIZE(int24Sample)), int24Sample,
|
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,
|
dither.data() + (c * SAMPLE_SIZE(int24Sample)), int24Sample,
|
||||||
mixed + (c * SAMPLE_SIZE(format)), format,
|
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,
|
bufptr,
|
||||||
format,
|
format,
|
||||||
framesRead,
|
framesRead,
|
||||||
true /* high quality by default */,
|
gHighQualityDither /* high quality by default */,
|
||||||
channels /* source stride */);
|
channels /* source stride */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user