-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapple_metadata.go
66 lines (63 loc) · 1.27 KB
/
apple_metadata.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package aiff
// AppleMetadata is a list of custom fields sometimes set by Apple specific
// progams such as Logic.
type AppleMetadata struct {
// Beats is the number of beats in the sample
Beats uint32
// Note is the root key of the sample (48 = C)
Note uint16
// Scale is the musical scale; 0 = neither, 1 = minor, 2 = major, 4 = both
Scale uint16
// Numerator of the time signature
Numerator uint16
// Denominator of the time signature
Denominator uint16
// IsLooping indicates if the sample is a loop or not
IsLooping bool
// Tags are tags related to the content of the file
Tags []string
}
// AppleScaleToString converts the scale information into a string representation.
func AppleScaleToString(scale uint16) string {
switch scale {
case 1:
return "minor"
case 2:
return "major"
case 4:
return "minor + major"
default:
return ""
}
}
// AppleNoteToPitch returns the pitch for the stored note.
func AppleNoteToPitch(note uint16) string {
switch note {
case 48:
return "C"
case 49:
return "C#"
case 50:
return "D"
case 51:
return "D#"
case 52:
return "E"
case 53:
return "F"
case 54:
return "F#"
case 55:
return "G"
case 56:
return "G#"
case 57:
return "A"
case 58:
return "A#"
case 59:
return "B"
default:
return ""
}
}