head_music 0.24.2 → 0.24.3
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/data/instruments.yml +69 -22
- data/lib/head_music/grand_staff.rb +6 -9
- data/lib/head_music/instrument.rb +23 -11
- data/lib/head_music/locales/en.yml +1 -1
- 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: 282655f6692a3065a0f4e8faf6b2e6938b53ab36c5d229183cfa4c747906414e
|
4
|
+
data.tar.gz: ac59b613c452d5ec06981b19c94da581f9474aeb8923f5040409c8b47668670e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e4d3d051057115e4b5751eb5113722dd50716daff6b73da4d21ae6a180b9eeb3ff42afe54be3b6a6b73e6c791b57cb58f0748349877966f487026ece28a79a7
|
7
|
+
data.tar.gz: a80791c1504b9ab101ef8ffd82efcd80e17686e09a7761c40ade3d310ca0c6b10f3387138e2ce73a83bf9a9b6550d5f10039de31bac389020033e01a62e7f00e
|
@@ -1,36 +1,83 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
- name_key: guitar
|
2
|
+
guitar:
|
4
3
|
family: string
|
5
4
|
classifications:
|
6
|
-
|
7
|
-
|
5
|
+
- string
|
6
|
+
- chordophone
|
8
7
|
default_clefs:
|
9
|
-
|
10
|
-
|
8
|
+
- treble_clef
|
9
|
+
voice: tenor
|
10
|
+
piano:
|
11
11
|
family: string
|
12
12
|
classifications:
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
- string
|
14
|
+
- chordophone
|
15
|
+
- keyboard
|
16
16
|
default_clefs:
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
- treble_clef
|
18
|
+
- bass_clef
|
19
|
+
violin:
|
20
|
+
family: string
|
20
21
|
alias_name_keys:
|
21
|
-
|
22
|
+
- fiddle
|
23
|
+
classifications:
|
24
|
+
- string
|
25
|
+
- chordophone
|
26
|
+
- bowed
|
27
|
+
default_clefs:
|
28
|
+
- treble_clef
|
29
|
+
voice: soprano
|
30
|
+
viola:
|
22
31
|
family: string
|
23
32
|
classifications:
|
24
|
-
|
25
|
-
|
26
|
-
|
33
|
+
- string
|
34
|
+
- chordophone
|
35
|
+
- bowed
|
27
36
|
default_clefs:
|
28
|
-
|
29
|
-
|
37
|
+
- alto_clef
|
38
|
+
voice: alto
|
39
|
+
cello:
|
30
40
|
family: string
|
31
41
|
classifications:
|
32
|
-
|
33
|
-
|
34
|
-
|
42
|
+
- string
|
43
|
+
- chordophone
|
44
|
+
- bowed
|
45
|
+
default_clefs:
|
46
|
+
- bass_clef
|
47
|
+
voice: tenor
|
48
|
+
double_bass:
|
49
|
+
family: string
|
50
|
+
classifications:
|
51
|
+
- string
|
52
|
+
- chordophone
|
53
|
+
- bowed
|
54
|
+
default_clefs:
|
55
|
+
- bass_clef
|
56
|
+
voice: bass
|
57
|
+
harp:
|
58
|
+
family: string
|
59
|
+
classifications:
|
60
|
+
- string
|
61
|
+
- chordophone
|
62
|
+
- plucked
|
63
|
+
default_clefs:
|
64
|
+
- treble_clef
|
65
|
+
- bass_clef
|
66
|
+
flute:
|
67
|
+
family: woodwind
|
68
|
+
classifications:
|
69
|
+
- woodwind
|
70
|
+
- wind
|
71
|
+
- aerophone
|
72
|
+
- edge-blown aerophone
|
73
|
+
default_clefs:
|
74
|
+
- treble_clef
|
75
|
+
voice: soprano
|
76
|
+
organ:
|
77
|
+
classifications:
|
78
|
+
- aerophone
|
79
|
+
- keyboard
|
35
80
|
default_clefs:
|
36
|
-
|
81
|
+
- treble_clef
|
82
|
+
- bass_clef
|
83
|
+
- bass_clef
|
@@ -6,16 +6,16 @@ class HeadMusic::GrandStaff
|
|
6
6
|
piano: {
|
7
7
|
instrument: :piano,
|
8
8
|
staves: [
|
9
|
-
{ clef: :treble_clef,
|
10
|
-
{ clef: :bass_clef,
|
9
|
+
{ clef: :treble_clef, for: :right_hand },
|
10
|
+
{ clef: :bass_clef, for: :left_hand },
|
11
11
|
],
|
12
12
|
},
|
13
13
|
organ: {
|
14
14
|
instrument: :organ,
|
15
15
|
staves: [
|
16
|
-
{ clef: :treble_clef,
|
17
|
-
{ clef: :bass_clef,
|
18
|
-
{ clef: :bass_clef,
|
16
|
+
{ clef: :treble_clef, for: :right_hand },
|
17
|
+
{ clef: :bass_clef, for: :left_hand },
|
18
|
+
{ clef: :bass_clef, for: :pedals },
|
19
19
|
],
|
20
20
|
},
|
21
21
|
}.freeze
|
@@ -42,10 +42,7 @@ class HeadMusic::GrandStaff
|
|
42
42
|
def staves
|
43
43
|
@staves ||=
|
44
44
|
data[:staves].map do |staff|
|
45
|
-
HeadMusic::Staff.new(
|
46
|
-
staff[:clef],
|
47
|
-
instrument: staff[:instrument] || instrument
|
48
|
-
)
|
45
|
+
HeadMusic::Staff.new(staff[:clef], instrument: instrument)
|
49
46
|
end
|
50
47
|
end
|
51
48
|
|
@@ -13,7 +13,11 @@ class HeadMusic::Instrument
|
|
13
13
|
new(name)
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
def self.all
|
17
|
+
INSTRUMENTS.map { |key, _data| get(key) }.sort_by(&:name)
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :name_key, :family, :default_clefs, :classifications, :voice
|
17
21
|
|
18
22
|
def ==(other)
|
19
23
|
to_s == other.to_s
|
@@ -28,33 +32,41 @@ class HeadMusic::Instrument
|
|
28
32
|
if record
|
29
33
|
initialize_data_from_record(record)
|
30
34
|
else
|
31
|
-
self.name = name
|
35
|
+
self.name = name.to_s
|
32
36
|
end
|
33
37
|
end
|
34
38
|
|
35
39
|
def record_for_name(name)
|
36
|
-
|
37
|
-
|
40
|
+
record_for_key(HeadMusic::Utilities::HashKey.for(name)) ||
|
41
|
+
record_for_key(key_for_name(name))
|
38
42
|
end
|
39
43
|
|
40
44
|
def key_for_name(name)
|
41
|
-
INSTRUMENTS.each do |
|
45
|
+
INSTRUMENTS.each do |key, _data|
|
42
46
|
I18n.config.available_locales.each do |locale|
|
43
|
-
translation = I18n.t("instruments.#{
|
44
|
-
return
|
47
|
+
translation = I18n.t("instruments.#{key}", locale: locale)
|
48
|
+
return key if translation.downcase == name.downcase
|
45
49
|
end
|
46
50
|
end
|
47
51
|
nil
|
48
52
|
end
|
49
53
|
|
50
54
|
def record_for_key(key)
|
51
|
-
INSTRUMENTS.
|
55
|
+
INSTRUMENTS.each do |name_key, data|
|
56
|
+
return data.merge!('name_key' => name_key) if name_key.to_s == key.to_s
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
60
|
def initialize_data_from_record(record)
|
55
|
-
@family = record['family']
|
56
|
-
@default_clefs = record['default_clefs']
|
57
61
|
@name_key = record['name_key'].to_sym
|
58
|
-
|
62
|
+
@family = record['family']
|
63
|
+
@default_clefs = record['default_clefs'] || []
|
64
|
+
@classifications = record['classifications'] || []
|
65
|
+
@voice = record['voice'].to_s
|
66
|
+
self.name = I18n.translate(name_key, scope: 'instruments', locale: 'en', default: inferred_name)
|
67
|
+
end
|
68
|
+
|
69
|
+
def inferred_name
|
70
|
+
name_key.to_s.gsub(/_/, ' ')
|
59
71
|
end
|
60
72
|
end
|
@@ -114,6 +114,7 @@ en:
|
|
114
114
|
bass_voice: bass
|
115
115
|
bassoon: bassoon
|
116
116
|
castanets: castanets
|
117
|
+
cello: cello
|
117
118
|
chimes: chimes
|
118
119
|
clarinet: clarinet
|
119
120
|
clash_cymbals: clash cymbals
|
@@ -158,7 +159,6 @@ en:
|
|
158
159
|
vibraphone: vibraphone
|
159
160
|
viola: viola
|
160
161
|
violin: violin
|
161
|
-
violincello: cello
|
162
162
|
woodblock: woodblock
|
163
163
|
xylophone: xylophone
|
164
164
|
instrument_abbreviations:
|
data/lib/head_music/version.rb
CHANGED