-
Notifications
You must be signed in to change notification settings - Fork 9
/
GUIDialogFreeSurround.cpp
274 lines (249 loc) · 9.34 KB
/
GUIDialogFreeSurround.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*
* Copyright (C) 2014-2015 Team KODI
* http://kodi.tv
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
#include "util/XMLUtils.h"
#include "p8-platform/util/util.h"
#include "GUIDialogFreeSurround.h"
#include "DSPProcessFreeSurround.h"
#include <kodi/ActionIDs.h>
#define BUTTON_OK 1
#define BUTTON_CANCEL 2
#define BUTTON_DEFAULT 5
#define DSP_SETTING_FREESURROUND_CIRCULAR_WRAP 41
#define DSP_SETTING_FREESURROUND_SHIFT 42
#define DSP_SETTING_FREESURROUND_DEPTH 43
#define DSP_SETTING_FREESURROUND_FOCUS 44
#define DSP_SETTING_FREESURROUND_FRONT_SEPARATION 45
#define DSP_SETTING_FREESURROUND_REAR_SEPARATION 46
#define DSP_SETTING_FREESURROUND_CENTER_IMAGE 47
#define DSP_SETTING_FREESURROUND_LFE 48
#define DSP_SETTING_FREESURROUND_LFE_LOW_CUTOFF 49
#define DSP_SETTING_FREESURROUND_LFE_HIGH_CUTOFF 50
CGUIDialogFreeSurround::CGUIDialogFreeSurround(unsigned int streamId)
: CWindow("DialogMasterModeFreeSurround.xml", "skin.estuary", true),
m_StreamId(streamId),
m_CircularWrap(nullptr),
m_Shift(nullptr),
m_Depth(nullptr),
m_Focus(nullptr),
m_CenterImage(nullptr),
m_FrontSeparation(nullptr),
m_RearSeparation(nullptr),
m_LFE(nullptr),
m_LFE_LowCutoff(nullptr),
m_LFE_HighCutoff(nullptr)
{
}
CGUIDialogFreeSurround::~CGUIDialogFreeSurround()
{
delete m_CircularWrap;
delete m_Shift;
delete m_Depth;
delete m_Focus;
delete m_CenterImage;
delete m_FrontSeparation;
delete m_RearSeparation;
delete m_LFE;
delete m_LFE_LowCutoff;
delete m_LFE_HighCutoff;
}
bool CGUIDialogFreeSurround::OnInit()
{
LoadSettingsData();
m_CircularWrap = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_CIRCULAR_WRAP);
m_CircularWrap->SetIntRange(0, 360);
m_CircularWrap->SetIntInterval(5);
m_CircularWrap->SetIntValue((int)m_Settings.fCircularWrap);
m_Shift = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_SHIFT);
m_Shift->SetFloatRange(-1.0, +1.0);
m_Shift->SetFloatValue(m_Settings.fShift);
m_Depth = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_DEPTH);
m_Depth->SetFloatRange(0, 4.0);
m_Depth->SetFloatInterval(0.25);
m_Depth->SetFloatValue(m_Settings.fDepth);
m_Focus = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_FOCUS);
m_Focus->SetFloatRange(-1.0, +1.0);
m_Focus->SetFloatValue(m_Settings.fFocus);
m_CenterImage = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_CENTER_IMAGE);
m_CenterImage->SetFloatValue(m_Settings.fCenterImage);
m_FrontSeparation = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_FRONT_SEPARATION);
m_FrontSeparation->SetFloatValue(m_Settings.fFrontSeparation);
m_RearSeparation = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_REAR_SEPARATION);
m_RearSeparation->SetFloatValue(m_Settings.fRearSeparation);
m_LFE = new kodi::gui::controls::CRadioButton(this, DSP_SETTING_FREESURROUND_LFE);
m_LFE->SetSelected(m_Settings.bLFE);
m_LFE_LowCutoff = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_LFE_LOW_CUTOFF);
m_LFE_LowCutoff->SetIntRange(40.0f, 400.0f);
m_LFE_LowCutoff->SetIntInterval(10.0f);
m_LFE_LowCutoff->SetIntValue(m_Settings.fLowCutoff);
m_LFE_HighCutoff = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_LFE_HIGH_CUTOFF);
m_LFE_HighCutoff->SetIntRange(60.0f, 1000.0f);
m_LFE_HighCutoff->SetIntInterval(10.0f);
m_LFE_HighCutoff->SetIntValue(m_Settings.fHighCutoff);
return true;
}
bool CGUIDialogFreeSurround::OnClick(int controlId)
{
CDSPProcess_FreeSurround *process = NULL;
switch (controlId)
{
case DSP_SETTING_FREESURROUND_CIRCULAR_WRAP:
{
m_Settings.fCircularWrap = m_CircularWrap->GetFloatValue();
process = g_usedDSPs[m_StreamId];
if (process)
process->SetCircularWrap(m_Settings.fCircularWrap);
break;
}
case DSP_SETTING_FREESURROUND_SHIFT:
{
m_Settings.fShift = m_Shift->GetFloatValue();
process = g_usedDSPs[m_StreamId];
if (process)
process->SetShift(m_Settings.fShift);
break;
}
case DSP_SETTING_FREESURROUND_DEPTH:
{
m_Settings.fDepth = m_Depth->GetFloatValue();
process = g_usedDSPs[m_StreamId];
if (process)
process->SetDepth(m_Settings.fDepth);
break;
}
case DSP_SETTING_FREESURROUND_FOCUS:
{
m_Settings.fFocus = m_Focus->GetFloatValue();
process = g_usedDSPs[m_StreamId];
if (process)
process->SetFocus(m_Settings.fFocus);
break;
}
case DSP_SETTING_FREESURROUND_CENTER_IMAGE:
{
m_Settings.fCenterImage = m_CenterImage->GetFloatValue();
process = g_usedDSPs[m_StreamId];
if (process)
process->SetCenterImage(m_Settings.fCenterImage);
break;
}
case DSP_SETTING_FREESURROUND_FRONT_SEPARATION:
{
m_Settings.fFrontSeparation = m_FrontSeparation->GetFloatValue();
process = g_usedDSPs[m_StreamId];
if (process)
process->SetFrontSeparation(m_Settings.fFrontSeparation);
break;
}
case DSP_SETTING_FREESURROUND_REAR_SEPARATION:
{
m_Settings.fRearSeparation = m_RearSeparation->GetFloatValue();
process = g_usedDSPs[m_StreamId];
if (process)
process->SetRearSeparation(m_Settings.fRearSeparation);
break;
}
case DSP_SETTING_FREESURROUND_LFE:
{
m_Settings.bLFE = m_LFE->IsSelected();
process = g_usedDSPs[m_StreamId];
if (process)
process->SetBassRedirection(m_Settings.bLFE);
break;
}
case DSP_SETTING_FREESURROUND_LFE_LOW_CUTOFF:
{
m_Settings.fLowCutoff = m_LFE_LowCutoff->GetIntValue();
process = g_usedDSPs[m_StreamId];
if (process)
process->SetLowCutoff(m_Settings.fLowCutoff);
break;
}
case DSP_SETTING_FREESURROUND_LFE_HIGH_CUTOFF:
{
m_Settings.fHighCutoff = m_LFE_HighCutoff->GetIntValue();
process = g_usedDSPs[m_StreamId];
if (process)
process->SetHighCutoff(m_Settings.fHighCutoff);
break;
}
case BUTTON_OK:
SaveSettingsData();
case BUTTON_CANCEL:
{
if (controlId == BUTTON_CANCEL)
{
process = g_usedDSPs[m_StreamId];
if (process)
process->ResetSettings();
}
Close();
break;
}
case BUTTON_DEFAULT:
{
CDSPSettings defaultSettings;
m_Settings.fCircularWrap = defaultSettings.m_Settings.fCircularWrap;
m_Settings.fShift = defaultSettings.m_Settings.fShift;
m_Settings.fDepth = defaultSettings.m_Settings.fDepth;
m_Settings.fFocus = defaultSettings.m_Settings.fFocus;
m_Settings.fCenterImage = defaultSettings.m_Settings.fCenterImage;
m_Settings.fFrontSeparation = defaultSettings.m_Settings.fFrontSeparation;
m_Settings.fRearSeparation = defaultSettings.m_Settings.fRearSeparation;
m_Settings.bLFE = defaultSettings.m_Settings.bLFE;
m_Settings.fLowCutoff = defaultSettings.m_Settings.fLowCutoff;
m_Settings.fHighCutoff = defaultSettings.m_Settings.fHighCutoff;
m_CircularWrap->SetIntValue((int)m_Settings.fCircularWrap);
m_Shift->SetFloatValue(m_Settings.fShift);
m_Depth->SetFloatValue(m_Settings.fDepth);
m_Focus->SetFloatValue(m_Settings.fFocus);
m_CenterImage->SetFloatValue(m_Settings.fCenterImage);
m_FrontSeparation->SetFloatValue(m_Settings.fFrontSeparation);
m_RearSeparation->SetFloatValue(m_Settings.fRearSeparation);
m_LFE->SetSelected(m_Settings.bLFE);
m_LFE_LowCutoff->SetIntValue(m_Settings.fLowCutoff);
m_LFE_HighCutoff->SetIntValue(m_Settings.fHighCutoff);
process = g_usedDSPs[m_StreamId];
if (process)
{
process->SetCircularWrap(m_Settings.fCircularWrap);
process->SetShift(m_Settings.fShift);
process->SetDepth(m_Settings.fDepth);
process->SetFocus(m_Settings.fFocus);
process->SetCenterImage(m_Settings.fCenterImage);
process->SetFrontSeparation(m_Settings.fFrontSeparation);
process->SetRearSeparation(m_Settings.fRearSeparation);
process->SetBassRedirection(m_Settings.bLFE);
process->SetLowCutoff(m_Settings.fLowCutoff);
process->SetHighCutoff(m_Settings.fHighCutoff);
}
break;
}
default:
break;
}
return true;
}
bool CGUIDialogFreeSurround::OnAction(int actionId)
{
if (actionId == ACTION_PREVIOUS_MENU ||
actionId == ACTION_NAV_BACK)
return OnClick(BUTTON_CANCEL);
else
return false;
}