-
Notifications
You must be signed in to change notification settings - Fork 0
/
degree.go
52 lines (48 loc) · 845 Bytes
/
degree.go
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
package degree
// Type is pitch degree type
type Type int
// Pitch degree name enumerations
const (
Invalid Type = iota
Tonic Type = iota
Supertonic Type = iota
Mediant Type = iota
Subdominant Type = iota
Dominant Type = iota
Subtonic Type = iota
LeadingTone Type = iota
)
// String returns string representation of pitch degree
func (d Type) String() string {
return [...]string{
"Invalid",
"Tonic",
"Supertonic",
"Mediant",
"Subdominant",
"Dominant",
"Subtonic",
"LeadingTone",
}[d]
}
// FromInt returns pitch degree from tonic
func FromInt(v int) Type {
switch v {
case 1:
return Tonic
case 2:
return Supertonic
case 3:
return Mediant
case 4:
return Subdominant
case 5:
return Dominant
case 6:
return Subtonic
case 7:
return LeadingTone
default:
return Invalid
}
}