Audacity  2.2.2
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 
17 enum DitherType : unsigned {
18  none = 0, rectangle = 1, triangle = 2, shaped = 3 };
19 
20 class Dither
21 {
22 public:
24  Dither();
25 
27  void Reset();
28 
33  void Apply(DitherType ditherType,
34  const samplePtr source, sampleFormat sourceFormat,
35  samplePtr dest, sampleFormat destFormat,
36  unsigned int len,
37  unsigned int sourceStride = 1,
38  unsigned int destStride = 1);
39 
40 private:
41  // Dither methods
42  float NoDither(float sample);
43  float RectangleDither(float sample);
44  float TriangleDither(float sample);
45  float ShapedDither(float sample);
46 
47  // Dither constants
48  static const int BUF_SIZE; /* = 8 */
49  static const int BUF_MASK; /* = 7 */
50  static const float SHAPED_BS[];
51 
52  // Dither state
53  int mPhase;
55  float mBuffer[8 /* = BUF_SIZE */];
56 };
57 
58 #endif /* __AUDACITY_DITHER_H__ */
Definition: Dither.h:18
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:48
float TriangleDither(float sample)
Definition: Dither.cpp:363
float NoDither(float sample)
Definition: Dither.cpp:351
static const int BUF_MASK
Definition: Dither.h:49
float mBuffer[8]
Definition: Dither.h:55
Definition: Dither.h:18
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:20
int mPhase
Definition: Dither.h:53
sampleFormat
Definition: Types.h:188
char * samplePtr
Definition: Types.h:203
float ShapedDither(float sample)
Definition: Dither.cpp:373
float mTriangleState
Definition: Dither.h:54
Dither()
Default constructor.
Definition: Dither.cpp:207
DitherType
These ditherers are currently available:
Definition: Dither.h:17
void Reset()
Reset state of the dither.
Definition: Dither.cpp:213
static const float SHAPED_BS[]
Definition: Dither.h:50