Audacity  2.2.0
Dither.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Steve Harris
6  Markus Meyer
7 
8 **********************************************************************/
9 
10 #ifndef __AUDACITY_DITHER_H__
11 #define __AUDACITY_DITHER_H__
12 
13 #include "SampleFormat.h"
14 
15 
16 class Dither
17 {
18 public:
20  Dither();
21 
23  enum DitherType { none = 0, rectangle = 1, triangle = 2, shaped = 3};
24 
26  void Reset();
27 
32  void Apply(DitherType ditherType,
33  const samplePtr source, sampleFormat sourceFormat,
34  samplePtr dest, sampleFormat destFormat,
35  unsigned int len,
36  unsigned int sourceStride = 1,
37  unsigned int destStride = 1);
38 
39 private:
40  // Dither methods
41  float NoDither(float sample);
42  float RectangleDither(float sample);
43  float TriangleDither(float sample);
44  float ShapedDither(float sample);
45 
46  // Dither constants
47  static const int BUF_SIZE; /* = 8 */
48  static const int BUF_MASK; /* = 7 */
49  static const float SHAPED_BS[];
50 
51  // Dither state
52  int mPhase;
54  float mBuffer[8 /* = BUF_SIZE */];
55 };
56 
57 #endif /* __AUDACITY_DITHER_H__ */
DitherType
These ditherers are currently available:
Definition: Dither.h:23
Definition: Dither.h:23
void Apply(DitherType ditherType, const samplePtr source, sampleFormat sourceFormat, samplePtr dest, sampleFormat destFormat, unsigned int len, unsigned int sourceStride=1, unsigned int destStride=1)
Definition: Dither.cpp:236
static const int BUF_SIZE
Definition: Dither.h:47
float TriangleDither(float sample)
Definition: Dither.cpp:363
float NoDither(float sample)
Definition: Dither.cpp:351
static const int BUF_MASK
Definition: Dither.h:48
float mBuffer[8]
Definition: Dither.h:54
float RectangleDither(float sample)
Definition: Dither.cpp:357
This class implements various functions for dithering and is derived from the dither code in the Ardo...
Definition: Dither.h:16
Definition: Dither.h:23
int mPhase
Definition: Dither.h:52
float ShapedDither(float sample)
Definition: Dither.cpp:373
float mTriangleState
Definition: Dither.h:53
Dither()
Default constructor.
Definition: Dither.cpp:207
Definition: Dither.h:23
void Reset()
Reset state of the dither.
Definition: Dither.cpp:213
static const float SHAPED_BS[]
Definition: Dither.h:49
Definition: Dither.h:23