head_music 0.26.3 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/head_music/pitch.rb +15 -1
- data/lib/head_music/register.rb +13 -0
- data/lib/head_music/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4274cb71a70fcab6904e99afc282bb1db756e2a1cce0c1e1e50c601e0e848edf
|
4
|
+
data.tar.gz: 47566a6db5b0836686fd789cf2e0b052416a68f8f2ed67b2f6582266a141ea1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b85d9dbd114b70bfea1fa9ce8cb964f6780ad9f64325a75baba02df48e416475f33e26a9dab22309740ff6e7f033fca756906a4fd5935af1f22e6fd325a775d4
|
7
|
+
data.tar.gz: 60a75acc692a1e1014f6042f9b167ecd7a0f6ec8eb98ca5dccb4c16a9bbcc79deff0b56481a713941caad779b7cc17b8487c89f4b4839bb31e3b453cff7558b5
|
data/lib/head_music/pitch.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# A pitch is a named frequency represented by a spelling and
|
3
|
+
# A pitch is a named frequency represented by a spelling and a register.
|
4
4
|
class HeadMusic::Pitch
|
5
5
|
include Comparable
|
6
6
|
|
@@ -108,6 +108,10 @@ class HeadMusic::Pitch
|
|
108
108
|
midi_note_number
|
109
109
|
end
|
110
110
|
|
111
|
+
def helmholtz_notation
|
112
|
+
helmholtz_letter_name + helmholtz_marks
|
113
|
+
end
|
114
|
+
|
111
115
|
def natural
|
112
116
|
HeadMusic::Pitch.get(to_s.gsub(HeadMusic::Sign.matcher, ''))
|
113
117
|
end
|
@@ -211,4 +215,14 @@ class HeadMusic::Pitch
|
|
211
215
|
@target_letter_name ||= {}
|
212
216
|
@target_letter_name[num_steps] ||= letter_name.steps_up(num_steps)
|
213
217
|
end
|
218
|
+
|
219
|
+
def helmholtz_letter_name
|
220
|
+
return spelling.to_s.downcase if HeadMusic::Register.get(register).helmholtz_case == :lower
|
221
|
+
|
222
|
+
spelling.to_s
|
223
|
+
end
|
224
|
+
|
225
|
+
def helmholtz_marks
|
226
|
+
HeadMusic::Register.get(register).helmholtz_marks
|
227
|
+
end
|
214
228
|
end
|
data/lib/head_music/register.rb
CHANGED
@@ -54,5 +54,18 @@ class HeadMusic::Register
|
|
54
54
|
self.class.get(to_i - other.to_i)
|
55
55
|
end
|
56
56
|
|
57
|
+
def helmholtz_case
|
58
|
+
return :upper if number < 3
|
59
|
+
|
60
|
+
:lower
|
61
|
+
end
|
62
|
+
|
63
|
+
def helmholtz_marks
|
64
|
+
return ',' * (2 - number) if number < 2
|
65
|
+
return "'" * (number - 3) if number > 3
|
66
|
+
|
67
|
+
''
|
68
|
+
end
|
69
|
+
|
57
70
|
private_class_method :new
|
58
71
|
end
|
data/lib/head_music/version.rb
CHANGED