Qmmp
dithering_p.h
1 /***************************************************************************
2  * Based on madplay project *
3  * *
4  * Copyright (C) 2000-2004 Robert Leslie <rob@mars.org> *
5  * Copyright (C) 2016 Ilya Kotov forkotov02@ya.ru *
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
21  ***************************************************************************/
22 
23 
24 #ifndef DITHERING_P_H
25 #define DITHERING_P_H
26 
27 #include "effect.h"
28 
32 class Dithering : public Effect
33 {
34 public:
35  Dithering();
36 
37  void configure(quint32 srate, ChannelMap map) override;
38  void setFormats(Qmmp::AudioFormat in, Qmmp::AudioFormat out);
39  void applyEffect(Buffer *b) override;
40  void setEnabled(bool enabled);
41 
42 private:
43  void clearHistory();
44  int m_chan;
45 
46  typedef struct
47  {
48  float error[3];
49  quint32 random;
50 
51  } AudioDither;
52 
53  AudioDither m_dither[9];
54  float m_lsb;
55  bool m_required, m_enabled;
56 
57 
58  quint32 prng(quint32 state);
59  float audioLinearDither(float sample, AudioDither *dither);
60 };
61 
62 #endif // DITHERING_P_H
The Effect class provides the base interface class of audio effects.
Definition: effect.h:35
This class represents audio channel mapping.
Definition: channelmap.h:30
virtual void applyEffect(Buffer *b)=0
Audio buffer class.
Definition: buffer.h:20
virtual void configure(quint32 srate, ChannelMap map)
AudioFormat
Definition: qmmp.h:114
static void setEnabled(EffectFactory *factory, bool enable=true)