Browse code

Make the NCSF Sound View dialog always available.

(Before it was only available under Debug builds.)

Naram Qashat authored on 2021/04/06 22:29:00
Showing 6 changed files
... ...
@@ -31,10 +31,8 @@
31 31
 
32 32
 XSFConfigDialog_NCSF::XSFConfigDialog_NCSF(XSFConfig &newConfig, wxWindow *parent, const wxString &title) : XSFConfigDialog(newConfig, parent, title)
33 33
 {
34
-#ifndef NDEBUG
35 34
 	auto useSoundViewCheckBox = new wxCheckBox(this->generalPanel, wxID_ANY, "Use Sound View Window", wxDefaultPosition, wxDefaultSize, 0, wxGenericValidator{ &this->useSoundView });
36 35
 	this->generalSizer->Add(useSoundViewCheckBox, { 5, 0 }, { 1, 2 }, wxALL, 5);
37
-#endif
38 36
 
39 37
 	auto interpolationLabel = new wxStaticText(this->outputPanel, wxID_ANY, "Interpolation");
40 38
 	this->outputSizer->Add(interpolationLabel, { 4, 0 }, { 1, 1 }, wxALIGN_CENTER_VERTICAL | wxALL, 5);
... ...
@@ -31,9 +31,7 @@ class XSFConfigDialog_NCSF : public XSFConfigDialog
31 31
 public:
32 32
 	XSFConfigDialog_NCSF(XSFConfig &newConfig, wxWindow *parent, const wxString &title);
33 33
 
34
-#ifndef NDEBUG
35 34
 	bool useSoundView;
36
-#endif
37 35
 	int interpolation;
38 36
 	wxArrayInt mute;
39 37
 };
... ...
@@ -9,20 +9,18 @@
9 9
 #include <sstream>
10 10
 #include <string>
11 11
 #include <cstddef>
12
+#include <cstdint>
12 13
 #include "windowsh_wrapper.h"
13 14
 #include <windowsx.h>
15
+#include <CommCtrl.h>
16
+#include "SSEQPlayer/common.h"
17
+#include "SSEQPlayer/consts.h"
14 18
 #include "XSFConfig.h"
15 19
 #include "XSFConfig_NCSF.h"
16 20
 #include "XSFConfigDialog_NCSF.h"
17 21
 #include "XSFPlayer_NCSF.h"
18 22
 #include "convert.h"
19
-#ifndef NDEBUG
20
-# include <cstdint>
21
-# include "SSEQPlayer/common.h"
22
-# include "SSEQPlayer/consts.h"
23
-# include "resource.h"
24
-# include <CommCtrl.h>
25
-#endif
23
+#include "resource.h"
26 24
 
27 25
 class wxWindow;
28 26
 class XSFConfigDialog;
... ...
@@ -43,10 +41,7 @@ XSFConfig *XSFConfig::Create()
43 41
 	return new XSFConfig_NCSF();
44 42
 }
45 43
 
46
-XSFConfig_NCSF::XSFConfig_NCSF() : XSFConfig(), interpolation(0), mutes()
47
-#ifndef NDEBUG
48
-	, useSoundViewDialog(false), soundViewData()
49
-#endif
44
+XSFConfig_NCSF::XSFConfig_NCSF() : XSFConfig(), interpolation(0), mutes(), useSoundViewDialog(false), soundViewData()
50 45
 {
51 46
 	this->supportedSampleRates.push_back(8000);
52 47
 	this->supportedSampleRates.push_back(11025);
... ...
@@ -63,9 +58,7 @@ XSFConfig_NCSF::XSFConfig_NCSF() : XSFConfig(), interpolation(0), mutes()
63 58
 
64 59
 void XSFConfig_NCSF::LoadSpecificConfig()
65 60
 {
66
-#ifndef NDEBUG
67 61
 	this->useSoundViewDialog = this->configIO->GetValue("UseSoundViewDialog", XSFConfig_NCSF::initUseSoundViewDialog);
68
-#endif
69 62
 	this->interpolation = this->configIO->GetValue("Interpolation", XSFConfig_NCSF::initInterpolation);
70 63
 	std::stringstream mutesSS(this->configIO->GetValue("Mutes", XSFConfig_NCSF::initMutes));
71 64
 	mutesSS >> this->mutes;
... ...
@@ -73,9 +66,7 @@ void XSFConfig_NCSF::LoadSpecificConfig()
73 66
 
74 67
 void XSFConfig_NCSF::SaveSpecificConfig()
75 68
 {
76
-#ifndef NDEBUG
77 69
 	this->configIO->SetValue("UseSoundViewDialog", this->useSoundViewDialog);
78
-#endif
79 70
 	this->configIO->SetValue("Interpolation", this->interpolation);
80 71
 	this->configIO->SetValue("Mutes", this->mutes.to_string<char>());
81 72
 }
... ...
@@ -83,9 +74,7 @@ void XSFConfig_NCSF::SaveSpecificConfig()
83 74
 void XSFConfig_NCSF::InitializeSpecificConfigDialog(XSFConfigDialog *dialog)
84 75
 {
85 76
 	auto ncsfDialog = static_cast<XSFConfigDialog_NCSF *>(dialog);
86
-#ifndef NDEBUG
87 77
 	ncsfDialog->useSoundView = this->useSoundViewDialog;
88
-#endif
89 78
 	ncsfDialog->interpolation = static_cast<int>(this->interpolation);
90 79
 	for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
91 80
 		if (this->mutes[x])
... ...
@@ -95,9 +84,7 @@ void XSFConfig_NCSF::InitializeSpecificConfigDialog(XSFConfigDialog *dialog)
95 84
 void XSFConfig_NCSF::ResetSpecificConfigDefaults(XSFConfigDialog *dialog)
96 85
 {
97 86
 	auto ncsfDialog = static_cast<XSFConfigDialog_NCSF *>(dialog);
98
-#ifndef NDEBUG
99 87
 	ncsfDialog->useSoundView = XSFConfig_NCSF::initUseSoundViewDialog;
100
-#endif
101 88
 	ncsfDialog->interpolation = XSFConfig_NCSF::initInterpolation;
102 89
 	ncsfDialog->mute.Clear();
103 90
 	auto tmpMutes = std::bitset<16>(XSFConfig_NCSF::initMutes);
... ...
@@ -109,9 +96,7 @@ void XSFConfig_NCSF::ResetSpecificConfigDefaults(XSFConfigDialog *dialog)
109 96
 void XSFConfig_NCSF::SaveSpecificConfigDialog(XSFConfigDialog *dialog)
110 97
 {
111 98
 	auto ncsfDialog = static_cast<XSFConfigDialog_NCSF *>(dialog);
112
-#ifndef NDEBUG
113 99
 	this->useSoundViewDialog = ncsfDialog->useSoundView;
114
-#endif
115 100
 	this->interpolation = ncsfDialog->interpolation;
116 101
 	for (std::size_t x = 0, numMutes = this->mutes.size(); x < numMutes; ++x)
117 102
 		this->mutes[x] = ncsfDialog->mute.Index(x) != wxNOT_FOUND;
... ...
@@ -120,9 +105,7 @@ void XSFConfig_NCSF::SaveSpecificConfigDialog(XSFConfigDialog *dialog)
120 105
 void XSFConfig_NCSF::CopySpecificConfigToMemory(XSFPlayer *xSFPlayer, bool)
121 106
 {
122 107
 	auto NCSFPlayer = static_cast<XSFPlayer_NCSF *>(xSFPlayer);
123
-#ifndef NDEBUG
124 108
 	NCSFPlayer->SetUseSoundViewDialog(this->useSoundViewDialog);
125
-#endif
126 109
 	NCSFPlayer->SetInterpolation(this->interpolation);
127 110
 	NCSFPlayer->SetMutes(this->mutes);
128 111
 }
... ...
@@ -138,7 +121,6 @@ XSFConfigDialog *XSFConfig_NCSF::CreateDialogBox(wxWindow *window, const std::st
138 121
 	return new XSFConfigDialog_NCSF(*this, window, title);
139 122
 }
140 123
 
141
-#ifndef NDEBUG
142 124
 INT_PTR CALLBACK XSFConfig_NCSF::SoundViewDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
143 125
 {
144 126
 	auto data = reinterpret_cast<SoundViewData *>(GetWindowLongW(hwndDlg, DWLP_USER));
... ...
@@ -352,4 +334,3 @@ void XSFConfig_NCSF::CloseSoundView()
352 334
 		this->soundViewData.reset();
353 335
 	}
354 336
 }
355
-#endif
... ...
@@ -7,26 +7,21 @@
7 7
 
8 8
 #pragma once
9 9
 
10
+#include <algorithm>
10 11
 #include <bitset>
12
+#include <memory>
11 13
 #include <string>
12
-#ifndef NDEBUG
13
-# include <algorithm>
14
-# include <memory>
15
-# include <cstdint>
16
-# include "SSEQPlayer/consts.h"
17
-#endif
14
+#include <cstdint>
18 15
 #include "windowsh_wrapper.h"
16
+#include "SSEQPlayer/consts.h"
19 17
 #include "XSFConfig.h"
20 18
 
21 19
 class wxWindow;
22 20
 class XSFConfig_NCSF;
23 21
 class XSFConfigDialog;
24 22
 class XSFPlayer;
25
-#ifndef DEBUG
26 23
 class XSFPlayer_NCSF;
27
-#endif
28 24
 
29
-#ifndef NDEBUG
30 25
 struct SoundViewData
31 26
 {
32 27
 	XSFConfig_NCSF *config;
... ...
@@ -41,14 +36,17 @@ struct SoundViewData
41 36
 		std::fill_n(&this->channelLastStates[0], sizeof(this->channelLastStates), ChannelState::Start);
42 37
 	}
43 38
 };
44
-#endif
45 39
 
46 40
 class XSFConfig_NCSF : public XSFConfig
47 41
 {
48 42
 protected:
49
-#ifndef NDEBUG
50
-	static constexpr bool initUseSoundViewDialog = true;
43
+	static constexpr bool initUseSoundViewDialog =
44
+#ifdef NDEBUG
45
+		false
46
+#else
47
+		true
51 48
 #endif
49
+	;
52 50
 	static constexpr unsigned initInterpolation = 4;
53 51
 	inline static const std::string initMutes = "0000000000000000";
54 52
 
... ...
@@ -65,19 +63,15 @@ protected:
65 63
 	void SaveSpecificConfigDialog(XSFConfigDialog *dialog) override;
66 64
 	void CopySpecificConfigToMemory(XSFPlayer *xSFPlayer, bool preLoad) override;
67 65
 
68
-#ifndef NDEBUG
69 66
 	bool useSoundViewDialog;
70 67
 	std::unique_ptr<SoundViewData> soundViewData;
71 68
 
72 69
 	static INT_PTR CALLBACK SoundViewDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
73
-#endif
74 70
 public:
75 71
 	void About(HWND parent) override;
76 72
 	XSFConfigDialog *CreateDialogBox(wxWindow *window, const std::string &title) override;
77 73
 
78
-#ifndef NDEBUG
79 74
 	void CallSoundView(XSFPlayer *xSFPlayer, HINSTANCE hInstance, HWND hwndParent);
80 75
 	void RefreshSoundView();
81 76
 	void CloseSoundView();
82
-#endif
83 77
 };
... ...
@@ -96,16 +96,12 @@ bool XSFPlayer_NCSF::LoadNCSF()
96 96
 	return this->RecursiveLoadNCSF(this->xSF.get(), 1);
97 97
 }
98 98
 
99
-XSFPlayer_NCSF::XSFPlayer_NCSF(const std::filesystem::path &path) : XSFPlayer(), sseq(0), sdatData(), sdat(), player(), secondsPerSample(0), secondsIntoPlayback(0), secondsUntilNextClock(0), mutes()
100
-#ifndef NDEBUG
101
-	, useSoundViewDialog(false)
102
-#endif
99
+XSFPlayer_NCSF::XSFPlayer_NCSF(const std::filesystem::path &path) : XSFPlayer(), sseq(0), sdatData(), sdat(), player(), secondsPerSample(0), secondsIntoPlayback(0), secondsUntilNextClock(0), mutes(), useSoundViewDialog(false)
103 100
 {
104 101
 	this->uses32BitSamplesClampedTo16Bit = true;
105 102
 	this->xSF.reset(new XSFFile(path, 8, 12));
106 103
 }
107 104
 
108
-#ifndef NDEBUG
109 105
 static HANDLE soundViewThreadHandle = INVALID_HANDLE_VALUE;
110 106
 static bool killSoundViewThread;
111 107
 
... ...
@@ -126,7 +122,6 @@ static DWORD WINAPI soundViewThread(void *b)
126 122
 	xSFConfig_NCSF->CloseSoundView();
127 123
 	return 0;
128 124
 }
129
-#endif
130 125
 
131 126
 XSFPlayer_NCSF::~XSFPlayer_NCSF()
132 127
 {
... ...
@@ -138,13 +133,11 @@ bool XSFPlayer_NCSF::Load()
138 133
 	if (!this->LoadNCSF())
139 134
 		return false;
140 135
 
141
-#ifndef NDEBUG
142 136
 	if (this->useSoundViewDialog)
143 137
 	{
144 138
 		killSoundViewThread = false;
145 139
 		soundViewThreadHandle = CreateThread(nullptr, 0, soundViewThread, this, 0, nullptr);
146 140
 	}
147
-#endif
148 141
 
149 142
 	PseudoFile file;
150 143
 	file.data = &this->sdatData;
... ...
@@ -221,7 +214,6 @@ void XSFPlayer_NCSF::Terminate()
221 214
 {
222 215
 	this->player.Stop(true);
223 216
 
224
-#ifndef NDEBUG
225 217
 	if (soundViewThreadHandle != INVALID_HANDLE_VALUE)
226 218
 	{
227 219
 		killSoundViewThread = true;
... ...
@@ -233,15 +225,12 @@ void XSFPlayer_NCSF::Terminate()
233 225
 		CloseHandle(soundViewThreadHandle);
234 226
 		soundViewThreadHandle = INVALID_HANDLE_VALUE;
235 227
 	}
236
-#endif
237 228
 }
238 229
 
239
-#ifndef NDEBUG
240 230
 void XSFPlayer_NCSF::SetUseSoundViewDialog(bool newUseSoundViewDialog)
241 231
 {
242 232
 	this->useSoundViewDialog = newUseSoundViewDialog;
243 233
 }
244
-#endif
245 234
 
246 235
 void XSFPlayer_NCSF::SetInterpolation(unsigned interpolation)
247 236
 {
... ...
@@ -253,9 +242,7 @@ void XSFPlayer_NCSF::SetMutes(const std::bitset<16> &newMutes)
253 242
 	this->mutes = newMutes;
254 243
 }
255 244
 
256
-#ifndef NDEBUG
257 245
 const Channel &XSFPlayer_NCSF::GetChannel(std::size_t chanNum) const
258 246
 {
259 247
 	return this->player.channels[chanNum];
260 248
 }
261
-#endif
... ...
@@ -15,9 +15,7 @@
15 15
 #include <memory>
16 16
 #include <string>
17 17
 #include <vector>
18
-#ifndef NDEBUG
19
-# include <cstddef>
20
-#endif
18
+#include <cstddef>
21 19
 #include <cstdint>
22 20
 #include "XSFPlayer.h"
23 21
 #include "SSEQPlayer/SDAT.h"
... ...
@@ -33,9 +31,7 @@ class XSFPlayer_NCSF : public XSFPlayer
33 31
 	Player player;
34 32
 	double secondsPerSample, secondsIntoPlayback, secondsUntilNextClock;
35 33
 	std::bitset<16> mutes;
36
-#ifndef NDEBUG
37 34
 	bool useSoundViewDialog;
38
-#endif
39 35
 
40 36
 	void MapNCSFSection(const std::vector<std::uint8_t> &section);
41 37
 	bool MapNCSF(XSFFile *xSFToLoad);
... ...
@@ -48,12 +44,8 @@ public:
48 44
 	void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples) override;
49 45
 	void Terminate() override;
50 46
 
51
-#ifndef NDEBUG
52 47
 	void SetUseSoundViewDialog(bool newUseSoundViewDialog);
53
-#endif
54 48
 	void SetInterpolation(unsigned interpolation);
55 49
 	void SetMutes(const std::bitset<16> &newMutes);
56
-#ifndef NDEBUG
57 50
 	const Channel &GetChannel(std::size_t chanNum) const;
58
-#endif
59 51
 };