Qmmp
Loading...
Searching...
No Matches
dithering_p.h
1/***************************************************************************
2 * Based on madplay project *
3 * *
4 * Copyright (C) 2000-2004 Robert Leslie <rob@mars.org> *
5 * Copyright (C) 2016-2020 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
32class Dithering : public Effect
33{
34public:
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
42private:
43 void clearHistory();
44 int m_chan = 2;
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 = 0.0f;
55 bool m_required = false, m_enabled;
56
57
58 quint32 prng(quint32 state);
59 float audioLinearDither(float sample, AudioDither *dither);
60};
61
62#endif // DITHERING_P_H
Audio buffer class.
Definition buffer.h:21
This class represents audio channel mapping.
Definition channelmap.h:31
The Effect class provides the base interface class of audio effects.
Definition effect.h:36
AudioFormat
Definition qmmp.h:115