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
275
276
277
278
|
/*
* SampleEditorDialogs.h
* ---------------------
* Purpose: Code for various dialogs that are used in the sample editor.
* 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 "../common/FileReaderFwd.h"
#include "../soundlib/SampleIO.h"
#include "../tracklib/FadeLaws.h"
#include "CDecimalSupport.h"
OPENMPT_NAMESPACE_BEGIN
//////////////////////////////////////////////////////////////////////////
// Sample amplification dialog
class CAmpDlg: public CDialog
{
public:
struct AmpSettings
{
Fade::Law fadeLaw;
int fadeInStart, fadeOutEnd;
int16 factor;
bool fadeIn, fadeOut;
};
AmpSettings &m_settings;
int16 m_nFactorMin, m_nFactorMax;
protected:
CComboBoxEx m_fadeBox;
CImageList m_list;
CNumberEdit m_edit, m_editFadeIn, m_editFadeOut;
bool m_locked = true;
public:
CAmpDlg(CWnd *parent, AmpSettings &settings, int16 factorMin = int16_min, int16 factorMax = int16_max);
protected:
void DoDataExchange(CDataExchange* pDX) override;
BOOL OnInitDialog() override;
void OnOK() override;
void OnDestroy();
afx_msg void EnableFadeIn() { if(!m_locked) CheckDlgButton(IDC_CHECK1, BST_CHECKED); }
afx_msg void EnableFadeOut() { if(!m_locked) CheckDlgButton(IDC_CHECK2, BST_CHECKED); }
DECLARE_MESSAGE_MAP()
};
//////////////////////////////////////////////////////////////////////////
// Sample import dialog
class CRawSampleDlg: public CDialog
{
friend class AutodetectFormatDlg;
protected:
static SampleIO m_format;
static SmpLength m_offset;
CSpinButtonCtrl m_SpinOffset;
FileReader &m_file;
bool m_rememberFormat = false;
public:
SampleIO GetSampleFormat() const { return m_format; }
void SetSampleFormat(SampleIO nFormat) { m_format = nFormat; }
bool GetRemeberFormat() const { return m_rememberFormat; };
void SetRememberFormat(bool remember) { m_rememberFormat = remember; };
SmpLength GetOffset() const { return m_offset; }
void SetOffset(SmpLength offset) { m_offset = offset; }
public:
CRawSampleDlg(FileReader &file, CWnd *parent = nullptr)
: CDialog(IDD_LOADRAWSAMPLE, parent)
, m_file(file) {}
protected:
void DoDataExchange(CDataExchange *pDX) override;
BOOL OnInitDialog() override;
void OnOK() override;
void UpdateDialog();
void OnBitDepthChanged(UINT id);
void OnEncodingChanged(UINT id);
void OnAutodetectFormat();
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////
// Add silence dialog - add silence to a sample
class AddSilenceDlg: public CDialog
{
public:
enum AddSilenceOptions
{
kSilenceAtBeginning, // Add at beginning of sample
kSilenceAtEnd, // Add at end of sample
kResize, // Resize sample
kOPLInstrument, // Initialize as OPL instrument
};
enum Unit
{
kSamples = 0,
kMilliseconds,
};
SmpLength m_numSamples; // Add x samples (also containes the return value in all cases)
SmpLength m_length; // Set size to x samples (init value: current sample size)
AddSilenceOptions m_editOption; // See above
protected:
static SmpLength m_addSamples;
static SmpLength m_createSamples;
uint32 m_sampleRate;
Unit m_unit = kSamples;
bool m_allowOPL;
public:
AddSilenceDlg(CWnd *parent, SmpLength origLength, uint32 sampleRate, bool allowOPL);
BOOL OnInitDialog() override;
void OnOK() override;
protected:
AddSilenceOptions GetEditMode() const;
afx_msg void OnEditModeChanged();
afx_msg void OnUnitChanged();
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////
// Sample grid dialog
class CSampleGridDlg: public CDialog
{
public:
SmpLength m_nSegments, m_nMaxSegments;
protected:
CEdit m_EditSegments;
CSpinButtonCtrl m_SpinSegments;
public:
CSampleGridDlg(CWnd *parent, SmpLength nSegments, SmpLength nMaxSegments) : CDialog(IDD_SAMPLE_GRID_SIZE, parent) { m_nSegments = nSegments; m_nMaxSegments = nMaxSegments; };
protected:
void DoDataExchange(CDataExchange* pDX) override;
BOOL OnInitDialog() override;
void OnOK() override;
};
/////////////////////////////////////////////////////////////////////////
// Sample cross-fade dialog
class CSampleXFadeDlg: public CDialog
{
public:
static uint32 m_fadeLength;
static uint32 m_fadeLaw;
static bool m_afterloopFade;
static bool m_useSustainLoop;
SmpLength m_loopLength = 0, m_maxLength = 0;
protected:
CSliderCtrl m_SliderLength, m_SliderFadeLaw;
CEdit m_EditSamples;
CSpinButtonCtrl m_SpinSamples;
CButton m_RadioNormalLoop, m_RadioSustainLoop;
ModSample &m_sample;
bool m_editLocked = true;
public:
CSampleXFadeDlg(CWnd *parent, ModSample &sample)
: CDialog(IDD_SAMPLE_XFADE, parent)
, m_sample(sample) {}
SmpLength PercentToSamples(uint32 percent) const { return Util::muldivr_unsigned(percent, m_loopLength, 100000); }
uint32 SamplesToPercent(SmpLength samples) const { return Util::muldivr_unsigned(samples, 100000, m_loopLength); }
protected:
void DoDataExchange(CDataExchange* pDX) override;
BOOL OnInitDialog() override;
void OnOK() override;
afx_msg void OnLoopTypeChanged();
afx_msg void OnFadeLengthChanged();
afx_msg void OnHScroll(UINT, UINT, CScrollBar *);
afx_msg BOOL OnToolTipText(UINT, NMHDR *pNMHDR, LRESULT *pResult);
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////
// Resampling dialog
class CResamplingDlg: public CDialog
{
public:
enum ResamplingOption
{
Upsample,
Downsample,
Custom
};
protected:
ResamplingMode m_srcMode;
uint32 m_frequency;
bool m_resampleAll;
static uint32 m_lastFrequency;
static ResamplingOption m_lastChoice;
static bool m_updatePatterns;
public:
CResamplingDlg(CWnd *parent, uint32 frequency, ResamplingMode srcMode, bool resampleAll) : CDialog(IDD_RESAMPLE, parent), m_srcMode(srcMode), m_frequency(frequency), m_resampleAll(resampleAll) { };
uint32 GetFrequency() const { return m_frequency; }
ResamplingMode GetFilter() const { return m_srcMode; }
static ResamplingOption GetResamplingOption() { return m_lastChoice; }
static bool UpdatePatternCommands() { return m_updatePatterns; }
protected:
BOOL OnInitDialog() override;
void OnOK() override;
afx_msg void OnFocusEdit() { CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO3); }
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////
// Sample mix dialog
class CMixSampleDlg: public CDialog
{
protected:
// Dialog controls
CEdit m_EditOffset;
CNumberEdit m_EditVolOriginal, m_EditVolMix;
CSpinButtonCtrl m_SpinOffset, m_SpinVolOriginal, m_SpinVolMix;
public:
static SmpLength sampleOffset;
static int amplifyOriginal;
static int amplifyMix;
public:
CMixSampleDlg(CWnd *parent);
protected:
void DoDataExchange(CDataExchange* pDX) override;
BOOL OnInitDialog() override;
void OnOK() override;
};
OPENMPT_NAMESPACE_END
|