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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
use super::chord::ChordModificationType;
use crate::context::{generate_id, Dynamic};
use amm_internal::amm_prelude::*;
use amm_macros::{JsonDeserialize, JsonSerialize, ModOrder};
/// Represents a technique used in handbell playing.
#[derive(Copy, Clone, Debug, Eq, PartialEq, ModOrder, JsonDeserialize, JsonSerialize)]
pub enum HandbellTechnique {
/// <span class="smufl"></span>
Belltree,
/// <span class="smufl"></span>
Damp,
/// <span class="smufl"></span>
Echo,
/// <span class="smufl"></span>
Gyro,
/// <span class="smufl"></span>
HandMartellato,
/// <span class="smufl"></span>
MalletLift,
/// <span class="smufl"></span>
MalletTable,
/// <span class="smufl"></span>
Martellato,
/// <span class="smufl"></span>
MartellatoLift,
/// <span class="smufl"></span>
MutedMartellato,
/// <span class="smufl"></span>
PluckLift,
/// <span class="smufl"></span>
Swing,
}
/// Represents a type of modification to a note.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, ModOrder, JsonDeserialize, JsonSerialize)]
pub enum NoteModificationType {
/// 
#[default]
Accent,
/// 
BrassBend,
/// 
DetachedLegato,
/// 
Doit,
/// 
DoubleTongue,
/// 
DownBow,
/// Represents a dynamic change that only affects the current note.
Dynamic { dynamic: Dynamic },
/// 
Falloff,
/// 
Fermata,
/// 
Fingernails,
/// 
Flip,
/// 
Glissando { from_current: bool, going_up: bool },
/// 
Golpe,
/// 
///
/// 
Grace { acciaccatura: bool },
/// 
HalfMuted,
/// Represents a [`HandbellTechnique`] used in handbell playing.
Handbell { technique: HandbellTechnique },
/// Open: <span class="smufl"></span>
///
/// Half: <span class="smufl"></span>
///
/// Closed: <span class="smufl"></span>
HarmonMute { open: bool, half: bool },
/// 
Haydn,
/// 
Heel,
/// Open: <span class="smufl"></span>
///
/// Half: <span class="smufl"></span>
///
/// Closed: <span class="smufl"></span>
Hole { open: bool, half: bool },
/// 
Marcato,
/// 
///
/// 
Mordent { upper: bool },
/// 
Open,
/// 
Pizzicato,
/// 
Plop,
/// 
Portamento { from_current: bool, going_up: bool },
/// 
Schleifer,
/// 
Scoop,
/// 
Sforzando,
/// 
Shake,
/// 
Smear,
/// 
SoftAccent,
/// 
Spiccato,
/// 
Staccato,
/// 
Staccatissimo,
/// 
Stopped,
/// 
Stress,
/// 
Tap,
/// 
Tenuto,
/// 
ThumbPosition,
/// 
Tie,
/// 
Toe,
/// 
Tremolo { relative_speed: u8 },
/// 
Trill { upper: bool },
/// 
TripleTongue,
/// 
///
/// 
///
/// 
Turn { upper: bool, delayed: bool, vertical: bool },
/// 
Unstress,
/// 
UpBow,
}
/// Represents a modification to a note.
#[derive(Debug, Default, Eq, JsonDeserialize, JsonSerialize)]
pub struct NoteModification {
/// The unique identifier for this modification.
id: usize,
/// The type of note modification.
pub r#type: NoteModificationType,
}
impl NoteModification {
/// Creates a new note modification based on the given type.
#[must_use]
pub fn new(r#type: NoteModificationType) -> Self {
Self {
id: generate_id(),
r#type,
}
}
/// Creates a new note modification based on the given
/// chord modification type.
///
/// Many chord modifications have direct corresponding
/// note modifications, and this function provides a
/// convenient way to convert between the two.
///
/// Returns `None` if the chord modification type does
/// not have a corresponding note modification type.
#[must_use]
pub fn from_chord_modification(r#type: &ChordModificationType) -> Option<Self> {
match *r#type {
ChordModificationType::Accent => Some(NoteModificationType::Accent),
ChordModificationType::DetachedLegato => Some(NoteModificationType::DetachedLegato),
ChordModificationType::DownBow => Some(NoteModificationType::DownBow),
ChordModificationType::Dynamic { dynamic } => Some(NoteModificationType::Dynamic { dynamic }),
ChordModificationType::Fermata => Some(NoteModificationType::Fermata),
ChordModificationType::Fingernails => Some(NoteModificationType::Fingernails),
ChordModificationType::HalfMuted => Some(NoteModificationType::HalfMuted),
ChordModificationType::HarmonMute { open, half } => Some(NoteModificationType::HarmonMute { open, half }),
ChordModificationType::Heel => Some(NoteModificationType::Heel),
ChordModificationType::Marcato => Some(NoteModificationType::Marcato),
ChordModificationType::Open => Some(NoteModificationType::Open),
ChordModificationType::Pizzicato => Some(NoteModificationType::Pizzicato),
ChordModificationType::Sforzando => Some(NoteModificationType::Sforzando),
ChordModificationType::Smear => Some(NoteModificationType::Smear),
ChordModificationType::SoftAccent => Some(NoteModificationType::SoftAccent),
ChordModificationType::Spiccato => Some(NoteModificationType::Spiccato),
ChordModificationType::Staccato => Some(NoteModificationType::Staccato),
ChordModificationType::Staccatissimo => Some(NoteModificationType::Staccatissimo),
ChordModificationType::Stress => Some(NoteModificationType::Stress),
ChordModificationType::Tenuto => Some(NoteModificationType::Tenuto),
ChordModificationType::Tie => Some(NoteModificationType::Tie),
ChordModificationType::Toe => Some(NoteModificationType::Toe),
ChordModificationType::Tremolo { relative_speed } => Some(NoteModificationType::Tremolo { relative_speed }),
ChordModificationType::Unstress => Some(NoteModificationType::Unstress),
ChordModificationType::UpBow => Some(NoteModificationType::UpBow),
_ => None,
}
.map(|r#type| Self {
id: generate_id(),
r#type,
})
}
/// Returns the unique identifier for this modification.
#[must_use]
pub fn get_id(&self) -> usize {
self.id
}
}
impl Clone for NoteModification {
fn clone(&self) -> Self {
Self {
id: generate_id(),
r#type: self.r#type,
}
}
}
impl PartialEq for NoteModification {
fn eq(&self, other: &Self) -> bool {
self.r#type == other.r#type
}
}
impl Ord for NoteModification {
fn cmp(&self, other: &Self) -> core::cmp::Ordering {
self.r#type.cmp(&other.r#type)
}
}
impl PartialOrd for NoteModification {
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
Some(self.cmp(other))
}
}
#[cfg(feature = "print")]
impl core::fmt::Display for HandbellTechnique {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(
f,
"{}",
match self {
Self::Belltree => "Belltree",
Self::Damp => "Damp",
Self::Echo => "Echo",
Self::Gyro => "Gyro",
Self::HandMartellato => "Hand Martellato",
Self::MalletLift => "Mallet Lift",
Self::MalletTable => "Mallet Table",
Self::Martellato => "Martellato",
Self::MartellatoLift => "Martellato Lift",
Self::MutedMartellato => "Muted Martellato",
Self::PluckLift => "Pluck Lift",
Self::Swing => "Swing",
}
)
}
}
#[cfg(feature = "print")]
impl core::fmt::Display for NoteModificationType {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
Self::Accent => write!(f, "Accent"),
Self::BrassBend => write!(f, "Brass Bend"),
Self::DetachedLegato => write!(f, "Detached Legato"),
Self::Doit => write!(f, "Doit"),
Self::DoubleTongue => write!(f, "Double Tongue"),
Self::DownBow => write!(f, "Down Bow"),
Self::Dynamic { dynamic } => write!(f, "Dynamic: {dynamic}"),
Self::Falloff => write!(f, "Falloff"),
Self::Fermata => write!(f, "Fermata"),
Self::Fingernails => write!(f, "Fingernails"),
Self::Flip => write!(f, "Flip"),
Self::Glissando { from_current, going_up } => write!(
f,
"Glissando: {} {}",
if *going_up { "Going Up" } else { "Going Down" },
if *from_current { "From Note" } else { "To Note" },
),
Self::Golpe => write!(f, "Golpe"),
Self::Grace { acciaccatura } => write!(
f,
"Grace {}",
if *acciaccatura { "Acciaccatura" } else { "Appoggiatura" },
),
Self::HalfMuted => write!(f, "Half Muted"),
Self::Handbell { technique } => write!(f, "Handbell: {technique}"),
Self::HarmonMute { open, half } => write!(
f,
"Harmon Mute: {}{}",
if *half { "Half-" } else { "Fully " },
if *open { "Open" } else { "Closed" },
),
Self::Haydn => write!(f, "Haydn"),
Self::Heel => write!(f, "Heel"),
Self::Hole { open, half } => write!(
f,
"Hole: {} {}",
if *half { "Half-" } else { "Fully " },
if *open { "Open" } else { "Closed" },
),
Self::Marcato => write!(f, "Marcato"),
Self::Mordent { upper } => write!(f, "Mordent: {}", if *upper { "Upper" } else { "Lower" }),
Self::Open => write!(f, "Open"),
Self::Pizzicato => write!(f, "Pizzicato"),
Self::Plop => write!(f, "Plop"),
Self::Portamento { from_current, going_up } => write!(
f,
"Portamento: {} {}",
if *going_up { "Going Up" } else { "Going Down" },
if *from_current { "From Note" } else { "To Note" },
),
Self::Schleifer => write!(f, "Schleifer"),
Self::Scoop => write!(f, "Scoop"),
Self::Sforzando => write!(f, "Sforzando"),
Self::Shake => write!(f, "Shake"),
Self::Smear => write!(f, "Smear"),
Self::SoftAccent => write!(f, "Soft Accent"),
Self::Spiccato => write!(f, "Spiccato"),
Self::Staccato => write!(f, "Staccato"),
Self::Staccatissimo => write!(f, "Staccatissimo"),
Self::Stopped => write!(f, "Stopped"),
Self::Stress => write!(f, "Stress"),
Self::Tap => write!(f, "Tap"),
Self::Tenuto => write!(f, "Tenuto"),
Self::ThumbPosition => write!(f, "Thumb Position"),
Self::Tie => write!(f, "Tied"),
Self::Toe => write!(f, "Toe"),
Self::Tremolo { relative_speed } => write!(f, "Tremolo: {relative_speed}x speed"),
Self::Trill { upper } => write!(f, "Trill: {}", if *upper { "Upper" } else { "Lower" }),
Self::TripleTongue => write!(f, "Triple Tongue"),
Self::Turn {
upper,
delayed,
vertical,
} => write!(
f,
"Turn: {} {}{}",
if *upper { "Upper" } else { "Lower" },
if *delayed { "Delayed " } else { "" },
if *vertical { "Vertical " } else { "" }
),
Self::Unstress => write!(f, "Unstress"),
Self::UpBow => write!(f, "Up Bow"),
}
}
}
#[cfg(feature = "print")]
impl core::fmt::Display for NoteModification {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "{}", self.r#type)
}
}