1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*
* Dither.h
* --------
* Purpose: Dithering when converting to lower resolution sample formats.
* Notes : (currently none)
* Authors: Olivier Lapicque
* OpenMPT Devs
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
#pragma once
#include "openmpt/all/BuildSettings.hpp"
#include "mpt/base/macros.hpp"
#include "mpt/string/types.hpp"
#include "openmpt/soundbase/Dither.hpp"
#include "openmpt/soundbase/DitherModPlug.hpp"
#include "openmpt/soundbase/DitherNone.hpp"
#include "openmpt/soundbase/DitherSimple.hpp"
#include "mptRandom.h"
#include <vector>
#include <variant>
#include <cstddef>
OPENMPT_NAMESPACE_BEGIN
using Dither_Default = Dither_Simple;
class DitherNamesOpenMPT
{
public:
static mpt::ustring GetModeName(std::size_t mode)
{
mpt::ustring result;
switch(mode)
{
case 0:
// no dither
result = MPT_USTRING("no");
break;
case 1:
// chosen by OpenMPT code, might change
result = MPT_USTRING("default");
break;
case 2:
// rectangular, 0.5 bit depth, no noise shaping (original ModPlug Tracker)
result = MPT_USTRING("0.5 bit");
break;
case 3:
// rectangular, 1 bit depth, simple 1st order noise shaping
result = MPT_USTRING("1 bit");
break;
default:
result = MPT_USTRING("");
break;
}
return result;
}
};
using DithersOpenMPT =
Dithers<std::variant<MultiChannelDither<Dither_None>, MultiChannelDither<Dither_Default>, MultiChannelDither<Dither_ModPlug>, MultiChannelDither<Dither_Simple>>, DitherNamesOpenMPT, 4, 1, 0, mpt::good_prng>;
struct DithersWrapperOpenMPT
: DithersOpenMPT
{
template <typename Trd>
DithersWrapperOpenMPT(Trd &rd, std::size_t mode = DithersOpenMPT::DefaultDither, std::size_t channels = DithersOpenMPT::DefaultChannels)
: DithersOpenMPT(rd, mode, channels)
{
return;
}
};
OPENMPT_NAMESPACE_END
|