-
Notifications
You must be signed in to change notification settings - Fork 1
/
dynamic.h
210 lines (189 loc) · 8.65 KB
/
dynamic.h
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
/////////////////////////////////////////////////////////////////////////////
// Name: dynamic.h
// Purpose: Stores and renders a dynamic
// Author: Brad Larsen
// Modified by:
// Created: Jan 13, 2005
// RCS-ID:
// Copyright: (c) Brad Larsen
// License: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __DYNAMIC_H__
#define __DYNAMIC_H__
/// Stores and renders a dynamic
class Dynamic : public PowerTabObject
{
friend class DynamicTestSuite;
// Constants
public:
// Default constants
static const wxWord DEFAULT_SYSTEM; ///< Default value for the system member variable
static const wxByte DEFAULT_STAFF; ///< Default value for the staff member variable
static const wxByte DEFAULT_POSITION; ///< Default value for the position member variable
static const wxWord DEFAULT_DATA; ///< Default value for the data member variable
static const wxByte DEFAULT_STAFF_VOLUME; ///< Default value for the staff volume
static const wxByte DEFAULT_RHYTHM_SLASH_VOLUME; ///< Default value for the dynamic volume
// System Constants
static const wxUint32 MIN_SYSTEM; ///< Minimum allowed value for the system member variable
static const wxUint32 MAX_SYSTEM; ///< Maximum allowed value for the system member variable
// Staff Constants
static const wxUint32 MIN_STAFF; ///< Minimum allowed value for the staff member variable
static const wxUint32 MAX_STAFF; ///< Maximum allowed value for the staff member variable
// Position Constants
static const wxUint32 MIN_POSITION; ///< Minimum allowed value for the position member variable
static const wxUint32 MAX_POSITION; ///< Maximum allowed value for the position member variable
// Volume constants
enum volumeLevels
{
notSet = (wxByte)0xff,
fff = (wxByte)104,
ff = (wxByte)91,
f = (wxByte)78,
mf = (wxByte)65,
mp = (wxByte)52,
p = (wxByte)39,
pp = (wxByte)26,
ppp = (wxByte)13,
off = (wxByte)0
};
// Member Variables
protected:
wxWord m_system; ///< Zero-based index of the system where the dynamic is anchored
wxByte m_staff; ///< Zero-based index of the staff within the system where the dynamic is anchored
wxByte m_position; ///< Zero-based index of the position within the system where the dynamic is anchored
wxWord m_data; ///< Volume level (see volumeLevels enum for values; top byte = staff volume, bottom byte = dynamic volume)
// Constructors/Destructors
public:
Dynamic();
Dynamic(wxUint32 system, wxUint32 staff, wxUint32 position,
wxByte staffVolume, wxByte rhythmSlashVolume);
Dynamic(const Dynamic& dynamic);
~Dynamic();
// Creation Functions
/// Creates an exact duplicate of the object
/// @return The duplicate object
PowerTabObject* CloneObject() const
{return (new Dynamic(*this));}
// Operators
const Dynamic& operator=(const Dynamic& dynamic);
bool operator==(const Dynamic& dynamic) const;
bool operator!=(const Dynamic& dynamic) const;
// Serialization functions
protected:
bool DoSerialize(PowerTabOutputStream& stream);
bool DoDeserialize(PowerTabInputStream& stream, wxWord version);
// MFC Class Functions
public:
/// Gets the MFC Class Name for the object
/// @return The MFC Class Name
wxString GetMFCClassName() const
{return (wxT("CDynamic"));}
/// Gets the MFC Class Schema for the object
/// @return The MFC Class Schema
wxWord GetMFCClassSchema() const
{return ((wxWord)1);}
// System Functions
/// Determines whether a system is valid
/// @param system System to validate
/// @return True if the system is valid, false if not
static bool IsValidSystem(wxUint32 system)
{return ((system >= MIN_SYSTEM) && (system <= MAX_SYSTEM));}
/// Sets the system within the system where the dynamic is anchored
/// @param system Zero-based index of the system where the dynamic is
/// anchored
/// @return True if the system was set, false if not
bool SetSystem(wxUint32 system)
{
wxCHECK(IsValidSystem(system), false);
m_system = (wxWord)system;
return (true);
}
/// Gets the system within the system where the dynamic is anchored
/// @return The system within the system where the dynamic is anchored
wxUint32 GetSystem() const
{return (m_system);}
// Staff Functions
/// Determines whether a staff is valid
/// @param staff Staff to validate
/// @return True if the staff is valid, false if not
static bool IsValidStaff(wxUint32 staff)
{return ((staff >= MIN_STAFF) && (staff <= MAX_STAFF));}
/// Sets the staff within the system where the dynamic is anchored
/// @param staff Zero-based index of the staff where the dynamic is anchored
/// @return True if the staff was set, false if not
bool SetStaff(wxUint32 staff)
{
wxCHECK(IsValidStaff(staff), false);
m_staff = (wxByte)staff;
return (true);
}
/// Gets the staff within the system where the dynamic is anchored
/// @return The staff within the system where the dynamic is anchored
wxUint32 GetStaff() const
{return (m_staff);}
// Position Functions
/// Determines whether a position is valid
/// @param position Position to validate
/// @return True if the position is valid, false if not
static bool IsValidPosition(wxUint32 position)
{return ((position >= MIN_POSITION) && (position <= MAX_POSITION));}
/// Sets the position within the system where the dynamic is anchored
/// @param position Zero-based index of the position within the system where
/// the dynamic is anchored
/// @return True if the position was set, false if not
bool SetPosition(wxUint32 position)
{
wxCHECK(IsValidPosition(position), false);
m_position = (wxByte)position;
return (true);
}
/// Gets the position within the system where the dynamic is anchored
/// @return The position within the system where the dynamic is anchored
wxUint32 GetPosition() const
{return (m_position);}
// Volume Functions
/// Determines if a volume is valid
/// @param volume Volume to validate
/// @return True if the volume is valid, false if not
static bool IsValidVolume(wxByte volume)
{
return ((volume == notSet) || (volume == fff) || (volume == ff) ||
(volume == f) || (volume == mf) || (volume == mp) ||
(volume == p) || (volume == pp) || (volume == ppp) ||
(volume == off));
}
// Staff Volume Functions
/// Sets the staff volume
/// @param volume Volume to set
/// @return True if the volume was set, false if not
bool SetStaffVolume(wxByte volume)
{return (SetVolume(false, volume));}
/// Gets the staff volume
/// @return The staff volume
wxByte GetStaffVolume() const
{return (GetVolume(false));}
/// Determines if the staff volume is set
/// @return True if the staff volume is set, false if not
bool IsStaffVolumeSet() const
{return (IsVolumeSet(false));}
// Rhythm Slash Functions
bool SetRhythmSlashVolume(wxByte volume)
{return (SetVolume(true, volume));}
/// Gets the dynamic volume
/// @return The dynamic volume
wxByte GetRhythmSlashVolume() const
{return (GetVolume(true));}
/// Determines if the dynamic volume is set
/// @return True if the dynamic volume is set, false if not
bool IsRhythmSlashVolumeSet() const
{return (IsVolumeSet(true));}
protected:
bool SetVolume(bool rhythmSlashes, wxByte volume);
wxByte GetVolume(bool rhythmSlashes) const;
bool IsVolumeSet(bool rhythmSlashes) const;
// Operations
public:
wxString GetText(bool rhythmSlashes) const;
};
WX_DEFINE_POWERTABARRAY(Dynamic*, DynamicArray);
#endif