-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPlayNote.cs
51 lines (45 loc) · 1.21 KB
/
PlayNote.cs
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
namespace PlayString
{
class PlayNote : Command
{
public char Note;
public int Length;
public bool Dotted;
public bool DoubleDotted;
public bool Sharp;
public bool Flat;
public PlayNote(char note)
{
Note = note;
Length = -1; // Note length is set by the Ln command
}
public PlayNote(char note, int length)
{
Note = note;
Length = length;
}
public PlayNote()
{
}
public int getNumber()
{
// C, C#, D, D#, E,F, F#, G, G#, A, A#, H
int number = 0;
switch (Note)
{
case 'C': number = 0; break;
case 'D': number = 2; break;
case 'E': number = 4; break;
case 'F': number = 5; break;
case 'G': number = 7; break;
case 'A': number = 9; break;
case 'B': number = 11; break;
}
if (Sharp)
number++;
if (Flat)
number--;
return number;
}
}
}