-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
dlgprefmodplug.cpp
213 lines (194 loc) · 8.71 KB
/
dlgprefmodplug.cpp
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include "preferences/dialog/dlgprefmodplug.h"
#include <QtDebug>
#include "defs_urls.h"
#include "moc_dlgprefmodplug.cpp"
#include "preferences/dialog/ui_dlgprefmodplugdlg.h"
#include "preferences/usersettings.h"
#include "sources/soundsourcemodplug.h"
#define kConfigKey "[Modplug]"
DlgPrefModplug::DlgPrefModplug(QWidget *parent,
UserSettingsPointer _config)
: DlgPreferencePage(parent),
m_pUi(new Ui::DlgPrefModplug),
m_pConfig(_config) {
m_pUi->setupUi(this);
// Create text color for the OpenMTP manual link
createLinkColor();
m_pUi->advancedSettings->setVisible(m_pUi->showAdvanced->isChecked());
connect(m_pUi->memoryLimit,
&QAbstractSlider::valueChanged,
m_pUi->memoryLimitSpin,
&QSpinBox::setValue);
connect(m_pUi->memoryLimitSpin,
QOverload<int>::of(&QSpinBox::valueChanged),
m_pUi->memoryLimit,
&QAbstractSlider::setValue);
connect(m_pUi->showAdvanced,
&QAbstractButton::toggled,
m_pUi->advancedSettings,
&QWidget::setVisible);
m_pUi->modplugSettingsHint->setText(
tr("All settings take effect on next track load. Currently loaded tracks "
"are not affected. For an explanation of these settings, see the %1")
.arg(coloredLinkString(
m_pLinkColor,
"OpenMPT manual",
"http://wiki.openmpt.org/Manual:_Setup/Player")));
}
DlgPrefModplug::~DlgPrefModplug() {
delete m_pUi;
}
void DlgPrefModplug::slotApply() {
applySettings();
saveSettings();
}
void DlgPrefModplug::slotUpdate() {
loadSettings();
}
void DlgPrefModplug::slotResetToDefaults() {
m_pUi->memoryLimit->setValue(256);
m_pUi->oversampling->setChecked(true);
m_pUi->noiseReduction->setChecked(false);
m_pUi->stereoSeparation->setValue(1);
m_pUi->maxMixChannels->setValue(128);
m_pUi->resampleMode->setCurrentIndex(1);
m_pUi->reverb->setChecked(false);
m_pUi->reverbDepth->setValue(50);
m_pUi->reverbDelay->setValue(50);
m_pUi->megabass->setChecked(false);
m_pUi->bassDepth->setValue(50);
m_pUi->bassCutoff->setValue(50);
m_pUi->surround->setChecked(false);
m_pUi->surroundDepth->setValue(50);
m_pUi->surroundDelay->setValue(50);
}
void DlgPrefModplug::loadSettings() {
m_pUi->memoryLimit->setValue(m_pConfig->getValue(
ConfigKey(kConfigKey,"PerTrackMemoryLimitMB"), 256));
m_pUi->oversampling->setChecked(m_pConfig->getValue(
ConfigKey(kConfigKey,"OversamplingEnabled"), true));
m_pUi->noiseReduction->setChecked(m_pConfig->getValue(
ConfigKey(kConfigKey,"NoiseReductionEnabled"), false));
m_pUi->stereoSeparation->setValue(m_pConfig->getValue(
ConfigKey(kConfigKey,"StereoSeparation"), 1));
m_pUi->maxMixChannels->setValue(m_pConfig->getValue(
ConfigKey(kConfigKey,"MaxMixChannels"), 128));
m_pUi->resampleMode->setCurrentIndex(m_pConfig->getValue(
ConfigKey(kConfigKey,"ResamplingMode"), 1));
m_pUi->reverb->setChecked(m_pConfig->getValue(
ConfigKey(kConfigKey,"ReverbEnabled"), false));
m_pUi->reverbDepth->setValue(m_pConfig->getValue(
ConfigKey(kConfigKey,"ReverbLevel"), 50));
m_pUi->reverbDelay->setValue(m_pConfig->getValue(
ConfigKey(kConfigKey,"ReverbDelay"), 50));
m_pUi->megabass->setChecked(m_pConfig->getValue(
ConfigKey(kConfigKey,"MegabassEnabled"), false));
m_pUi->bassDepth->setValue(m_pConfig->getValue(
ConfigKey(kConfigKey,"MegabassLevel"), 50));
m_pUi->bassCutoff->setValue(m_pConfig->getValue(
ConfigKey(kConfigKey,"MegabassCutoff"), 50));
m_pUi->surround->setChecked(m_pConfig->getValue(
ConfigKey(kConfigKey,"SurroundEnabled"), false));
m_pUi->surroundDepth->setValue(m_pConfig->getValue(
ConfigKey(kConfigKey,"SurroundLevel"), 50));
m_pUi->surroundDelay->setValue(m_pConfig->getValue(
ConfigKey(kConfigKey,"SurroundDelay"), 50));
}
void DlgPrefModplug::saveSettings() {
m_pConfig->set(ConfigKey(kConfigKey,"PerTrackMemoryLimitMB"),
ConfigValue(m_pUi->memoryLimit->value()));
m_pConfig->set(ConfigKey(kConfigKey,"OversamplingEnabled"),
ConfigValue(m_pUi->oversampling->isChecked()));
m_pConfig->set(ConfigKey(kConfigKey,"NoiseReductionEnabled"),
ConfigValue(m_pUi->noiseReduction->isChecked()));
m_pConfig->set(ConfigKey(kConfigKey,"StereoSeparation"),
ConfigValue(m_pUi->stereoSeparation->value()));
m_pConfig->set(ConfigKey(kConfigKey,"MaxMixChannels"),
ConfigValue(m_pUi->maxMixChannels->value()));
m_pConfig->set(ConfigKey(kConfigKey,"ResamplingMode"),
ConfigValue(m_pUi->resampleMode->currentIndex()));
m_pConfig->set(ConfigKey(kConfigKey,"ReverbEnabled"),
ConfigValue(m_pUi->reverb->isChecked()));
m_pConfig->set(ConfigKey(kConfigKey,"ReverbLevel"),
ConfigValue(m_pUi->reverbDepth->value()));
m_pConfig->set(ConfigKey(kConfigKey,"ReverbDelay"),
ConfigValue(m_pUi->reverbDelay->value()));
m_pConfig->set(ConfigKey(kConfigKey,"MegabassEnabled"),
ConfigValue(m_pUi->megabass->isChecked()));
m_pConfig->set(ConfigKey(kConfigKey,"MegabassLevel"),
ConfigValue(m_pUi->bassDepth->value()));
m_pConfig->set(ConfigKey(kConfigKey,"MegabassCutoff"),
ConfigValue(m_pUi->bassCutoff->value()));
m_pConfig->set(ConfigKey(kConfigKey,"SurroundEnabled"),
ConfigValue(m_pUi->surround->isChecked()));
m_pConfig->set(ConfigKey(kConfigKey,"SurroundLevel"),
ConfigValue(m_pUi->surroundDepth->value()));
m_pConfig->set(ConfigKey(kConfigKey,"SurroundDelay"),
ConfigValue(m_pUi->surroundDelay->value()));
}
void DlgPrefModplug::applySettings() {
// read ui parameters and configure soundsource
unsigned int bufferSizeLimit = m_pUi->memoryLimit->value() << 20;
ModPlug::ModPlug_Settings settings;
// Note that ModPlug always decodes sound at 44.1kHz, 32 bit, stereo
// and then down-mixes to the settings you choose.
// Currently this is fixed to 16bit 44.1kHz stereo
// Number of channels - 1 for mono or 2 for stereo
settings.mChannels = mixxx::SoundSourceModPlug::kChannelCount;
// Bits per sample - 8, 16, or 32
settings.mBits = mixxx::SoundSourceModPlug::kBitsPerSample;
// Sample rate - 11025, 22050, or 44100
settings.mFrequency = mixxx::SoundSourceModPlug::kSampleRate;
// enabled features flags
settings.mFlags = 0;
if (m_pUi->oversampling->isChecked()) {
settings.mFlags |= ModPlug::MODPLUG_ENABLE_OVERSAMPLING;
}
if (m_pUi->noiseReduction->isChecked()) {
settings.mFlags |= ModPlug::MODPLUG_ENABLE_NOISE_REDUCTION;
}
if (m_pUi->reverb->isChecked()) {
settings.mFlags |= ModPlug::MODPLUG_ENABLE_REVERB;
}
if (m_pUi->megabass->isChecked()) {
settings.mFlags |= ModPlug::MODPLUG_ENABLE_MEGABASS;
}
if (m_pUi->surround->isChecked()) {
settings.mFlags |= ModPlug::MODPLUG_ENABLE_SURROUND;
}
switch (m_pUi->resampleMode->currentIndex()) {
case 0: // nearest neighbor
settings.mResamplingMode = ModPlug::MODPLUG_RESAMPLE_NEAREST;
break;
case 1: // linear
settings.mResamplingMode = ModPlug::MODPLUG_RESAMPLE_LINEAR;
break;
case 2: // cubic spline
settings.mResamplingMode = ModPlug::MODPLUG_RESAMPLE_SPLINE;
break;
case 3: // 8 tap FIR (also default)
default:
settings.mResamplingMode = ModPlug::MODPLUG_RESAMPLE_FIR;
break;
}
// stereo separation 1(joint)-256(fully separated channels)
settings.mStereoSeparation = m_pUi->stereoSeparation->value();
// maximum number of mix channels (16-256)
settings.mMaxMixChannels = m_pUi->maxMixChannels->value();
// Reverb level 0(quiet)-100(loud)
settings.mReverbDepth = m_pUi->reverbDepth->value();
// Reverb delay in ms, usually 40-200ms
settings.mReverbDelay = m_pUi->reverbDelay->value();
// XBass level 0(quiet)-100(loud)
settings.mBassAmount = m_pUi->bassDepth->value();
// XBass cutoff in Hz 10-100
settings.mBassRange = m_pUi->bassCutoff->value();
// Surround level 0(quiet)-100(heavy)
settings.mSurroundDepth = m_pUi->surroundDepth->value();
// Surround front-rear delay in ms, usually 5-40ms
settings.mSurroundDelay = m_pUi->surroundDelay->value();
// Number of times to loop. Zero prevents looping. -1 loops forever.
settings.mLoopCount = 0;
// apply modplug settings
mixxx::SoundSourceModPlug::configure(bufferSizeLimit, settings);
}