head_music 7.0.5 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/lib/head_music/{diatonic_interval → analysis/diatonic_interval}/category.rb +1 -1
- data/lib/head_music/{diatonic_interval → analysis/diatonic_interval}/naming.rb +6 -6
- data/lib/head_music/{diatonic_interval → analysis/diatonic_interval}/parser.rb +4 -4
- data/lib/head_music/{diatonic_interval → analysis/diatonic_interval}/semitones.rb +4 -4
- data/lib/head_music/{diatonic_interval → analysis/diatonic_interval}/size.rb +1 -1
- data/lib/head_music/{diatonic_interval.rb → analysis/diatonic_interval.rb} +19 -16
- data/lib/head_music/{harmonic_interval.rb → analysis/harmonic_interval.rb} +5 -2
- data/lib/head_music/{melodic_interval.rb → analysis/melodic_interval.rb} +6 -3
- data/lib/head_music/{motion.rb → analysis/motion.rb} +6 -3
- data/lib/head_music/content/bar.rb +2 -2
- data/lib/head_music/content/composition.rb +3 -3
- data/lib/head_music/content/note.rb +1 -1
- data/lib/head_music/content/placement.rb +1 -1
- data/lib/head_music/content/position.rb +1 -1
- data/lib/head_music/content/rhythmic_value.rb +3 -3
- data/lib/head_music/{staff.rb → content/staff.rb} +6 -3
- data/lib/head_music/content/voice.rb +2 -2
- data/lib/head_music/{instrument.rb → instruments/instrument.rb} +10 -7
- data/lib/head_music/{data → instruments}/instrument_families.yml +49 -0
- data/lib/head_music/{instrument_family.rb → instruments/instrument_family.rb} +5 -2
- data/lib/head_music/{data → instruments}/instruments.yml +116 -0
- data/lib/head_music/{instrument → instruments}/staff.rb +5 -2
- data/lib/head_music/{instrument → instruments}/staff_scheme.rb +7 -2
- data/lib/head_music/{instrument → instruments}/variant.rb +6 -3
- data/lib/head_music/locales/en.yml +22 -0
- data/lib/head_music/{alteration.rb → rudiment/alteration.rb} +9 -6
- data/lib/head_music/{chromatic_interval.rb → rudiment/chromatic_interval.rb} +7 -4
- data/lib/head_music/{circle.rb → rudiment/circle.rb} +9 -6
- data/lib/head_music/{clef.rb → rudiment/clef.rb} +7 -4
- data/lib/head_music/{consonance.rb → rudiment/consonance.rb} +4 -1
- data/lib/head_music/{interval_cycle.rb → rudiment/interval_cycle.rb} +12 -9
- data/lib/head_music/{key_signature → rudiment/key_signature}/enharmonic_equivalence.rb +4 -4
- data/lib/head_music/{key_signature.rb → rudiment/key_signature.rb} +10 -7
- data/lib/head_music/{letter_name.rb → rudiment/letter_name.rb} +9 -6
- data/lib/head_music/{meter.rb → rudiment/meter.rb} +6 -3
- data/lib/head_music/{musical_symbol.rb → rudiment/musical_symbol.rb} +4 -1
- data/lib/head_music/{pitch → rudiment/pitch}/enharmonic_equivalence.rb +4 -4
- data/lib/head_music/{pitch → rudiment/pitch}/octave_equivalence.rb +2 -2
- data/lib/head_music/{pitch.rb → rudiment/pitch.rb} +30 -27
- data/lib/head_music/{pitch_class.rb → rudiment/pitch_class.rb} +14 -11
- data/lib/head_music/{pitch_class_set.rb → rudiment/pitch_class_set.rb} +5 -2
- data/lib/head_music/{pitch_set.rb → rudiment/pitch_set.rb} +14 -11
- data/lib/head_music/{quality.rb → rudiment/quality.rb} +4 -1
- data/lib/head_music/{reference_pitch.rb → rudiment/reference_pitch.rb} +5 -2
- data/lib/head_music/{register.rb → rudiment/register.rb} +6 -3
- data/lib/head_music/rudiment/rhythm.rb +6 -0
- data/lib/head_music/{rhythmic_unit.rb → rudiment/rhythmic_unit.rb} +5 -2
- data/lib/head_music/{scale.rb → rudiment/scale.rb} +12 -9
- data/lib/head_music/{scale_degree.rb → rudiment/scale_degree.rb} +8 -5
- data/lib/head_music/{scale_type.rb → rudiment/scale_type.rb} +4 -1
- data/lib/head_music/{solmization.rb → rudiment/solmization.rb} +4 -1
- data/lib/head_music/{sonority.rb → rudiment/sonority.rb} +7 -4
- data/lib/head_music/{spelling.rb → rudiment/spelling.rb} +20 -17
- data/lib/head_music/{tuning.rb → rudiment/tuning.rb} +6 -3
- data/lib/head_music/style/annotation.rb +6 -6
- data/lib/head_music/style/guidelines/consonant_climax.rb +4 -4
- data/lib/head_music/style/guidelines/diatonic.rb +1 -1
- data/lib/head_music/style/guidelines/step_out_of_unison.rb +1 -1
- data/lib/head_music/version.rb +1 -1
- data/lib/head_music.rb +50 -46
- metadata +51 -51
- data/lib/head_music/rhythm.rb +0 -3
- /data/lib/head_music/{data → rudiment}/clefs.yml +0 -0
- /data/lib/head_music/{solmizations.yml → rudiment/solmizations.yml} +0 -0
@@ -458,6 +458,13 @@ cymbal:
|
|
458
458
|
staff_schemes:
|
459
459
|
default:
|
460
460
|
- clef: neutral_clef
|
461
|
+
didgeridoo:
|
462
|
+
family_key: didgeridoo
|
463
|
+
variants:
|
464
|
+
default:
|
465
|
+
staff_schemes:
|
466
|
+
default:
|
467
|
+
- clef: neutral_clef
|
461
468
|
double_bass:
|
462
469
|
alias_name_keys:
|
463
470
|
- contrabass
|
@@ -561,6 +568,15 @@ hammered_dulcimer:
|
|
561
568
|
default:
|
562
569
|
- clef: treble_clef
|
563
570
|
orchestra_section_key: percussion
|
571
|
+
harmonica:
|
572
|
+
alias_name_keys:
|
573
|
+
- mouth_organ
|
574
|
+
family_key: harmonica
|
575
|
+
variants:
|
576
|
+
default:
|
577
|
+
staff_schemes:
|
578
|
+
default:
|
579
|
+
- clef: treble_clef
|
564
580
|
harp:
|
565
581
|
family_key: harp
|
566
582
|
variants:
|
@@ -963,6 +979,13 @@ subcontrabass_saxophone:
|
|
963
979
|
sounding_transposition: -38
|
964
980
|
range_categories:
|
965
981
|
- subcontrabass
|
982
|
+
sitar:
|
983
|
+
family_key: sitar
|
984
|
+
variants:
|
985
|
+
default:
|
986
|
+
staff_schemes:
|
987
|
+
default:
|
988
|
+
- clef: treble_clef
|
966
989
|
snare_drum:
|
967
990
|
alias_name_keys:
|
968
991
|
- side_drum
|
@@ -997,6 +1020,15 @@ sousaphone:
|
|
997
1020
|
sounding_transposition: 0
|
998
1021
|
range_categories:
|
999
1022
|
- bass
|
1023
|
+
steelpan:
|
1024
|
+
alias_name_keys:
|
1025
|
+
- steel_drum
|
1026
|
+
family_key: steelpan
|
1027
|
+
variants:
|
1028
|
+
default:
|
1029
|
+
staff_schemes:
|
1030
|
+
default:
|
1031
|
+
- clef: treble_clef
|
1000
1032
|
suspended_cymbal:
|
1001
1033
|
family_key: cymbal
|
1002
1034
|
variants:
|
@@ -1005,6 +1037,8 @@ suspended_cymbal:
|
|
1005
1037
|
default:
|
1006
1038
|
- clef: neutral_clef
|
1007
1039
|
synthesizer:
|
1040
|
+
alias_name_keys:
|
1041
|
+
- electronic_keyboard
|
1008
1042
|
family_key: synthesizer
|
1009
1043
|
variants:
|
1010
1044
|
default:
|
@@ -1014,6 +1048,13 @@ synthesizer:
|
|
1014
1048
|
name_key: right_hand
|
1015
1049
|
- clef: bass_clef
|
1016
1050
|
name_key: left_hand
|
1051
|
+
tabla:
|
1052
|
+
family_key: tabla
|
1053
|
+
variants:
|
1054
|
+
default:
|
1055
|
+
staff_schemes:
|
1056
|
+
default:
|
1057
|
+
- clef: neutral_clef
|
1017
1058
|
tam_tam:
|
1018
1059
|
alias_name_keys:
|
1019
1060
|
- gong
|
@@ -1069,6 +1110,13 @@ tenor_voice:
|
|
1069
1110
|
sounding_transposition: -12
|
1070
1111
|
range_categories:
|
1071
1112
|
- tenor
|
1113
|
+
theremin:
|
1114
|
+
family_key: theremin
|
1115
|
+
variants:
|
1116
|
+
default:
|
1117
|
+
staff_schemes:
|
1118
|
+
default:
|
1119
|
+
- clef: treble_clef
|
1072
1120
|
timpani:
|
1073
1121
|
alias_name_keys:
|
1074
1122
|
- kettledrum
|
@@ -1148,6 +1196,74 @@ tuba:
|
|
1148
1196
|
staff_schemes:
|
1149
1197
|
default:
|
1150
1198
|
- clef: bass_clef
|
1199
|
+
ukulele:
|
1200
|
+
alias_name_keys:
|
1201
|
+
- soprano_ukulele
|
1202
|
+
family_key: ukulele
|
1203
|
+
variants:
|
1204
|
+
default:
|
1205
|
+
staff_schemes:
|
1206
|
+
default:
|
1207
|
+
- clef: treble_clef
|
1208
|
+
range_categories:
|
1209
|
+
- soprano
|
1210
|
+
- alto
|
1211
|
+
pocket_ukulele:
|
1212
|
+
alias_name_keys:
|
1213
|
+
- sopranino_ukulele
|
1214
|
+
- piccolo_ukulele
|
1215
|
+
family_key: ukulele
|
1216
|
+
variants:
|
1217
|
+
default:
|
1218
|
+
staff_schemes:
|
1219
|
+
default:
|
1220
|
+
- clef: treble_clef
|
1221
|
+
range_categories:
|
1222
|
+
- sopranino
|
1223
|
+
- soprano
|
1224
|
+
concert_ukulele:
|
1225
|
+
alias_name_keys:
|
1226
|
+
- alto_ukulele
|
1227
|
+
family_key: ukulele
|
1228
|
+
variants:
|
1229
|
+
default:
|
1230
|
+
staff_schemes:
|
1231
|
+
default:
|
1232
|
+
- clef: treble_clef
|
1233
|
+
range_categories:
|
1234
|
+
- soprano
|
1235
|
+
- alto
|
1236
|
+
tenor_ukulele:
|
1237
|
+
family_key: ukulele
|
1238
|
+
variants:
|
1239
|
+
default:
|
1240
|
+
staff_schemes:
|
1241
|
+
default:
|
1242
|
+
- clef: treble_clef
|
1243
|
+
range_categories:
|
1244
|
+
- tenor
|
1245
|
+
baritone_ukulele:
|
1246
|
+
family_key: ukulele
|
1247
|
+
variants:
|
1248
|
+
default:
|
1249
|
+
staff_schemes:
|
1250
|
+
default:
|
1251
|
+
- clef: treble_clef
|
1252
|
+
range_categories:
|
1253
|
+
- alto
|
1254
|
+
- tenor
|
1255
|
+
- baritone
|
1256
|
+
bass_ukulele:
|
1257
|
+
family_key: ukulele
|
1258
|
+
variants:
|
1259
|
+
default:
|
1260
|
+
staff_schemes:
|
1261
|
+
default:
|
1262
|
+
- clef: bass_clef
|
1263
|
+
range_categories:
|
1264
|
+
- bass
|
1265
|
+
- baritone
|
1266
|
+
- tenor
|
1151
1267
|
vibraphone:
|
1152
1268
|
alias_name_keys:
|
1153
1269
|
- vibes
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Namespace for instrument definitions, categorization, and configuration
|
2
|
+
module HeadMusic::Instruments; end
|
3
|
+
|
4
|
+
class HeadMusic::Instruments::Staff
|
2
5
|
DEFAULT_CLEF = "treble_clef"
|
3
6
|
|
4
7
|
attr_reader :staff_scheme, :attributes
|
@@ -9,7 +12,7 @@ class HeadMusic::Instrument::Staff
|
|
9
12
|
end
|
10
13
|
|
11
14
|
def clef
|
12
|
-
HeadMusic::Clef.get(smart_clef_key)
|
15
|
+
HeadMusic::Rudiment::Clef.get(smart_clef_key)
|
13
16
|
end
|
14
17
|
|
15
18
|
def smart_clef_key
|
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
require_relative "staff"
|
2
|
+
|
3
|
+
# Namespace for instrument definitions, categorization, and configuration
|
4
|
+
module HeadMusic::Instruments; end
|
5
|
+
|
6
|
+
class HeadMusic::Instruments::StaffScheme
|
2
7
|
attr_reader :variant, :key, :list
|
3
8
|
|
4
9
|
def initialize(variant:, key:, list:)
|
@@ -13,7 +18,7 @@ class HeadMusic::Instrument::StaffScheme
|
|
13
18
|
|
14
19
|
def staves
|
15
20
|
@staves ||= list.map do |attributes|
|
16
|
-
HeadMusic::
|
21
|
+
HeadMusic::Instruments::Staff.new(self, attributes)
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Namespace for instrument definitions, categorization, and configuration
|
2
|
+
module HeadMusic::Instruments; end
|
3
|
+
|
4
|
+
class HeadMusic::Instruments::Variant
|
2
5
|
attr_reader :key, :attributes
|
3
6
|
|
4
7
|
def initialize(key, attributes = {})
|
@@ -10,13 +13,13 @@ class HeadMusic::Instrument::Variant
|
|
10
13
|
return unless attributes["pitch_designation"].to_s != ""
|
11
14
|
|
12
15
|
@pitch_designation ||=
|
13
|
-
HeadMusic::Spelling.get(attributes["pitch_designation"])
|
16
|
+
HeadMusic::Rudiment::Spelling.get(attributes["pitch_designation"])
|
14
17
|
end
|
15
18
|
|
16
19
|
def staff_schemes
|
17
20
|
@staff_schemes ||=
|
18
21
|
(attributes["staff_schemes"] || {}).map do |key, list|
|
19
|
-
HeadMusic::
|
22
|
+
HeadMusic::Instruments::StaffScheme.new(
|
20
23
|
key: key,
|
21
24
|
variant: self,
|
22
25
|
list: list
|
@@ -86,6 +86,7 @@ en:
|
|
86
86
|
mezzo_soprano_voice: mezzo-soprano
|
87
87
|
percussion: percussion
|
88
88
|
percussion_instrument: percussion instrument
|
89
|
+
pitched: pitched
|
89
90
|
plucked: plucked
|
90
91
|
plucked_instrument: plucked instrument
|
91
92
|
reed: reed
|
@@ -95,6 +96,7 @@ en:
|
|
95
96
|
stringed_instrument: stringed instrument
|
96
97
|
strings: strings
|
97
98
|
struck: struck
|
99
|
+
unpitched: unpitched
|
98
100
|
voice: voice
|
99
101
|
wind: wind
|
100
102
|
wind_instrument: wind instrument
|
@@ -119,6 +121,7 @@ en:
|
|
119
121
|
alto_flute: alto flute
|
120
122
|
alto_recorder: alto recorder
|
121
123
|
alto_saxophone: alto saxophone
|
124
|
+
alto_ukulele: alto ukulele
|
122
125
|
alto_voice: alto
|
123
126
|
arpeggione: arpeggione
|
124
127
|
bagpipe: bagpipe
|
@@ -126,6 +129,7 @@ en:
|
|
126
129
|
baritone_horn: baritone horn
|
127
130
|
baritone_oboe: baritone oboe
|
128
131
|
baritone_saxophone: baritone saxophone
|
132
|
+
baritone_ukulele: baritone ukulele
|
129
133
|
baritone_voice: baritone
|
130
134
|
bass: bass
|
131
135
|
bass_clarinet: bass clarinet
|
@@ -137,6 +141,7 @@ en:
|
|
137
141
|
bass_trombone: bass trombone
|
138
142
|
bass_trumpet: bass trumpet
|
139
143
|
bass_tuba: bass tuba
|
144
|
+
bass_ukulele: bass ukulele
|
140
145
|
bass_voice: bass
|
141
146
|
basset_horn: basset horn
|
142
147
|
basset_recorder: basset recorder
|
@@ -154,6 +159,7 @@ en:
|
|
154
159
|
clavichord: clavichord
|
155
160
|
concert_bells: concert bells
|
156
161
|
concert_cymbals: concert cymbals
|
162
|
+
concert_ukulele: concert ukulele
|
157
163
|
contra_great_bass_recorder: contra-great bass recorder
|
158
164
|
contrabass: contrabass
|
159
165
|
contrabass_clarinet: contrabass clarinet
|
@@ -171,8 +177,10 @@ en:
|
|
171
177
|
crotales: crotales
|
172
178
|
cymbal: cymbal
|
173
179
|
descant: descant
|
180
|
+
didgeridoo: didgeridoo
|
174
181
|
double_bass: double bass
|
175
182
|
double_contrabass_recorder: double-contrabass recorder
|
183
|
+
electronic_keyboard: electronic keyboard
|
176
184
|
english_horn: English horn
|
177
185
|
euphonium: euphonium
|
178
186
|
fiddle: fiddle
|
@@ -188,6 +196,7 @@ en:
|
|
188
196
|
great_highland_bagpipe: great highland bagpipe
|
189
197
|
guitar: guitar
|
190
198
|
hammered_dulcimer: hammered dulcimer
|
199
|
+
harmonica: harmonica
|
191
200
|
harp: harp
|
192
201
|
harpsichord: harpsichord
|
193
202
|
hautbois_d_amour: hautbois d'amour
|
@@ -204,6 +213,7 @@ en:
|
|
204
213
|
mezzo_soprano: mezzo-soprano
|
205
214
|
mezzo_soprano_voice: mezzo-soprano
|
206
215
|
military_drum: military drum
|
216
|
+
mouth_organ: mouth_organ
|
207
217
|
natural_horn: natural horn
|
208
218
|
oboe: oboe
|
209
219
|
oboe_d_amore: oboe d'amore
|
@@ -219,25 +229,33 @@ en:
|
|
219
229
|
piccolo_recorder: piccolo recorder
|
220
230
|
piccolo_saxophone: piccolo saxophone
|
221
231
|
piccolo_trumpet: piccolo trumpet
|
232
|
+
piccolo_ukulele: piccolo ukulele
|
222
233
|
pipe_organ: pipe organ
|
234
|
+
pocket_trumpet: pocket trumpet
|
235
|
+
pocket_ukulele: pocket ukulele
|
223
236
|
quart_bass_recorder: quart bass recorder
|
224
237
|
recorder: recorder
|
225
238
|
ride_cymbal: ride cymbal
|
226
239
|
saxophone: saxophone
|
227
240
|
side_drum: side drum
|
241
|
+
sitar: sitar
|
228
242
|
snare_drum: snare drum
|
229
243
|
sopranino_clarinet: sopranino clarinet
|
230
244
|
sopranino_recorder: sopranino recorder
|
231
245
|
sopranino_saxophone: sopranino saxophone
|
246
|
+
sopranino_ukulele: sopranino ukulele
|
232
247
|
sopranissimo_recorder: sopranissimo recorder
|
233
248
|
sopranissimo_saxophone: sopranissimo saxophone
|
234
249
|
soprano: soprano
|
235
250
|
soprano_clarinet: soprano clarinet
|
236
251
|
soprano_recorder: soprano recorder
|
237
252
|
soprano_saxophone: soprano saxophone
|
253
|
+
soprano_ukulele: soprano ukulele
|
238
254
|
soprano_voice: soprano
|
239
255
|
soprillo: soprillo
|
240
256
|
sousaphone: sousaphone
|
257
|
+
steelpan: steelpan
|
258
|
+
steel_drum: steel drum
|
241
259
|
string_bass: string bass
|
242
260
|
sub_bass_recorder: sub-bass recorder
|
243
261
|
sub_contrabass_recorder: sub-contrabass recorder
|
@@ -245,6 +263,7 @@ en:
|
|
245
263
|
subcontrabass_saxophone: subcontrabass saxophone
|
246
264
|
suspended_cymbal: suspended cymbal
|
247
265
|
synthesizer: synthesizer
|
266
|
+
tabla: tabla
|
248
267
|
tabor: tabor
|
249
268
|
tam_tam: tam-tam
|
250
269
|
tambourine: tambourine
|
@@ -255,7 +274,9 @@ en:
|
|
255
274
|
tenor_saxophone: tenor saxophone
|
256
275
|
tenor_trombone: tenor trombone
|
257
276
|
tenor_tuba: tenor tuba
|
277
|
+
tenor_ukulele: tenor ukulele
|
258
278
|
tenor_voice: tenor
|
279
|
+
theremin: theremin
|
259
280
|
timpani: timpani
|
260
281
|
timpanum: timpanum
|
261
282
|
tom_drum: tom drum
|
@@ -266,6 +287,7 @@ en:
|
|
266
287
|
trumpet: trumpet
|
267
288
|
tuba: tuba
|
268
289
|
tubular_bells: tubular bells
|
290
|
+
ukulele: ukulele
|
269
291
|
vibes: vibes
|
270
292
|
vibraphone: vibraphone
|
271
293
|
viola: viola
|
@@ -1,8 +1,11 @@
|
|
1
|
-
require "head_music/musical_symbol"
|
1
|
+
require "head_music/rudiment/musical_symbol"
|
2
2
|
|
3
|
-
# A
|
3
|
+
# A module for music rudiments
|
4
|
+
module HeadMusic::Rudiment; end
|
5
|
+
|
6
|
+
# An Alteration is a symbol that modifies pitch, such as a sharp, flat, or natural.
|
4
7
|
# In French, sharps and flats in the key signature are called "altérations".
|
5
|
-
class HeadMusic::Alteration
|
8
|
+
class HeadMusic::Rudiment::Alteration
|
6
9
|
include Comparable
|
7
10
|
|
8
11
|
attr_reader :identifier, :cents, :musical_symbols
|
@@ -51,7 +54,7 @@ class HeadMusic::Alteration
|
|
51
54
|
end
|
52
55
|
|
53
56
|
def self.get(identifier)
|
54
|
-
return identifier if identifier.is_a?(HeadMusic::Alteration)
|
57
|
+
return identifier if identifier.is_a?(HeadMusic::Rudiment::Alteration)
|
55
58
|
|
56
59
|
all.detect do |alteration|
|
57
60
|
alteration.representions.include?(identifier)
|
@@ -86,7 +89,7 @@ class HeadMusic::Alteration
|
|
86
89
|
end
|
87
90
|
|
88
91
|
def <=>(other)
|
89
|
-
other = HeadMusic::Alteration.get(other)
|
92
|
+
other = HeadMusic::Rudiment::Alteration.get(other)
|
90
93
|
cents <=> other.cents
|
91
94
|
end
|
92
95
|
|
@@ -104,7 +107,7 @@ class HeadMusic::Alteration
|
|
104
107
|
|
105
108
|
def initialize_musical_symbols(list)
|
106
109
|
@musical_symbols = (list || []).map do |record|
|
107
|
-
HeadMusic::MusicalSymbol.new(
|
110
|
+
HeadMusic::Rudiment::MusicalSymbol.new(
|
108
111
|
unicode: record[:unicode],
|
109
112
|
ascii: record[:ascii],
|
110
113
|
html_entity: record[:html_entity]
|
@@ -1,5 +1,8 @@
|
|
1
|
+
# A module for music rudiments
|
2
|
+
module HeadMusic::Rudiment; end
|
3
|
+
|
1
4
|
# A chromatic interval is the distance between two pitches measured in half-steps.
|
2
|
-
class HeadMusic::ChromaticInterval
|
5
|
+
class HeadMusic::Rudiment::ChromaticInterval
|
3
6
|
include Comparable
|
4
7
|
include HeadMusic::Named
|
5
8
|
|
@@ -37,7 +40,7 @@ class HeadMusic::ChromaticInterval
|
|
37
40
|
end
|
38
41
|
|
39
42
|
def simple
|
40
|
-
HeadMusic::ChromaticInterval.get(semitones % 12)
|
43
|
+
HeadMusic::Rudiment::ChromaticInterval.get(semitones % 12)
|
41
44
|
end
|
42
45
|
|
43
46
|
def simple?
|
@@ -60,11 +63,11 @@ class HeadMusic::ChromaticInterval
|
|
60
63
|
alias_method :specific_interval, :semitones
|
61
64
|
|
62
65
|
def +(other)
|
63
|
-
HeadMusic::ChromaticInterval.get(to_i + other.to_i)
|
66
|
+
HeadMusic::Rudiment::ChromaticInterval.get(to_i + other.to_i)
|
64
67
|
end
|
65
68
|
|
66
69
|
def -(other)
|
67
|
-
HeadMusic::ChromaticInterval.get((to_i - other.to_i).abs)
|
70
|
+
HeadMusic::Rudiment::ChromaticInterval.get((to_i - other.to_i).abs)
|
68
71
|
end
|
69
72
|
|
70
73
|
def <=>(other)
|
@@ -1,7 +1,10 @@
|
|
1
|
-
require "head_music/interval_cycle"
|
1
|
+
require "head_music/rudiment/interval_cycle"
|
2
|
+
|
3
|
+
# A module for music rudiments
|
4
|
+
module HeadMusic::Rudiment; end
|
2
5
|
|
3
6
|
# A Circle of Fifths or Fourths shows relationships between pitch classes
|
4
|
-
class HeadMusic::Circle < HeadMusic::IntervalCycle
|
7
|
+
class HeadMusic::Rudiment::Circle < HeadMusic::Rudiment::IntervalCycle
|
5
8
|
def self.of_fifths
|
6
9
|
get(:perfect_fifth)
|
7
10
|
end
|
@@ -12,20 +15,20 @@ class HeadMusic::Circle < HeadMusic::IntervalCycle
|
|
12
15
|
|
13
16
|
def self.get(interval = :perfect_fifth)
|
14
17
|
@circles ||= {}
|
15
|
-
diatonic_interval = HeadMusic::DiatonicInterval.get(interval)
|
18
|
+
diatonic_interval = HeadMusic::Analysis::DiatonicInterval.get(interval)
|
16
19
|
@circles[interval] ||= new(interval: diatonic_interval, starting_pitch: "C4")
|
17
20
|
end
|
18
21
|
|
19
22
|
def index(pitch_class)
|
20
|
-
pitch_classes.index(HeadMusic::Spelling.get(pitch_class).pitch_class)
|
23
|
+
pitch_classes.index(HeadMusic::Rudiment::Spelling.get(pitch_class).pitch_class)
|
21
24
|
end
|
22
25
|
|
23
26
|
def key_signatures_up
|
24
|
-
spellings_up.map { |spelling| HeadMusic::KeySignature.new(spelling) }
|
27
|
+
spellings_up.map { |spelling| HeadMusic::Rudiment::KeySignature.new(spelling) }
|
25
28
|
end
|
26
29
|
|
27
30
|
def key_signatures_down
|
28
|
-
spellings_down.map { |spelling| HeadMusic::KeySignature.new(spelling) }
|
31
|
+
spellings_down.map { |spelling| HeadMusic::Rudiment::KeySignature.new(spelling) }
|
29
32
|
end
|
30
33
|
|
31
34
|
def spellings_up
|
@@ -1,10 +1,13 @@
|
|
1
1
|
require "yaml"
|
2
2
|
|
3
|
+
# A module for music rudiments
|
4
|
+
module HeadMusic::Rudiment; end
|
5
|
+
|
3
6
|
# A clef assigns pitches to the lines and spaces of a staff.
|
4
|
-
class HeadMusic::Clef
|
7
|
+
class HeadMusic::Rudiment::Clef
|
5
8
|
include HeadMusic::Named
|
6
9
|
|
7
|
-
RECORDS = YAML.load_file(File.expand_path("
|
10
|
+
RECORDS = YAML.load_file(File.expand_path("clefs.yml", __dir__)).freeze
|
8
11
|
|
9
12
|
def self.get(name)
|
10
13
|
get_by_name(name)
|
@@ -82,7 +85,7 @@ class HeadMusic::Clef
|
|
82
85
|
|
83
86
|
def initialize_data_from_record(record)
|
84
87
|
initialize_keys_from_record(record)
|
85
|
-
@pitch = HeadMusic::Pitch.get(record[:pitch])
|
88
|
+
@pitch = HeadMusic::Rudiment::Pitch.get(record[:pitch])
|
86
89
|
@line = record[:line]
|
87
90
|
@modern = record[:modern]
|
88
91
|
initialize_musical_symbols(record[:symbols])
|
@@ -95,7 +98,7 @@ class HeadMusic::Clef
|
|
95
98
|
|
96
99
|
def initialize_musical_symbols(list)
|
97
100
|
@musical_symbols = (list || []).map do |symbol_data|
|
98
|
-
HeadMusic::MusicalSymbol.new(**symbol_data.slice(:ascii, :html_entity, :unicode))
|
101
|
+
HeadMusic::Rudiment::MusicalSymbol.new(**symbol_data.slice(:ascii, :html_entity, :unicode))
|
99
102
|
end
|
100
103
|
end
|
101
104
|
end
|
@@ -1,5 +1,8 @@
|
|
1
|
+
# A module for music rudiments
|
2
|
+
module HeadMusic::Rudiment; end
|
3
|
+
|
1
4
|
# Consonance describes a category or degree of harmonic pleasantness: perfect, imperfect, or dissonant
|
2
|
-
class HeadMusic::Consonance
|
5
|
+
class HeadMusic::Rudiment::Consonance
|
3
6
|
LEVELS = %w[perfect imperfect dissonant].freeze
|
4
7
|
|
5
8
|
def self.get(name)
|
@@ -1,20 +1,23 @@
|
|
1
|
+
# A module for music rudiments
|
2
|
+
module HeadMusic::Rudiment; end
|
3
|
+
|
1
4
|
# An Interval Cycle is a collection of pitch classes created from a sequence of the same interval class.
|
2
|
-
class HeadMusic::IntervalCycle
|
5
|
+
class HeadMusic::Rudiment::IntervalCycle
|
3
6
|
attr_reader :interval, :starting_pitch
|
4
7
|
|
5
8
|
def self.get(interval = 7)
|
6
9
|
@interval_cycles ||= {}
|
7
10
|
interval = interval.to_s.gsub(/^C/i, "").to_i
|
8
|
-
interval = HeadMusic::ChromaticInterval.get(interval)
|
11
|
+
interval = HeadMusic::Rudiment::ChromaticInterval.get(interval)
|
9
12
|
@interval_cycles[interval.to_i] ||= new(interval: interval, starting_pitch: "C4")
|
10
13
|
end
|
11
14
|
|
12
15
|
def initialize(interval:, starting_pitch: "C4")
|
13
|
-
@interval = interval if interval.is_a?(HeadMusic::DiatonicInterval)
|
14
|
-
@interval ||= interval if interval.is_a?(HeadMusic::ChromaticInterval)
|
15
|
-
@interval ||= HeadMusic::ChromaticInterval.get(interval) if interval.to_s.match?(/\d/)
|
16
|
-
@interval ||= HeadMusic::DiatonicInterval.get(interval)
|
17
|
-
@starting_pitch = HeadMusic::Pitch.get(starting_pitch)
|
16
|
+
@interval = interval if interval.is_a?(HeadMusic::Analysis::DiatonicInterval)
|
17
|
+
@interval ||= interval if interval.is_a?(HeadMusic::Rudiment::ChromaticInterval)
|
18
|
+
@interval ||= HeadMusic::Rudiment::ChromaticInterval.get(interval) if interval.to_s.match?(/\d/)
|
19
|
+
@interval ||= HeadMusic::Analysis::DiatonicInterval.get(interval)
|
20
|
+
@starting_pitch = HeadMusic::Rudiment::Pitch.get(starting_pitch)
|
18
21
|
end
|
19
22
|
|
20
23
|
def pitches
|
@@ -26,7 +29,7 @@ class HeadMusic::IntervalCycle
|
|
26
29
|
end
|
27
30
|
|
28
31
|
def pitch_class_set
|
29
|
-
@pitch_class_set ||= HeadMusic::PitchClassSet.new(pitches)
|
32
|
+
@pitch_class_set ||= HeadMusic::Rudiment::PitchClassSet.new(pitches)
|
30
33
|
end
|
31
34
|
|
32
35
|
def spellings
|
@@ -48,6 +51,6 @@ class HeadMusic::IntervalCycle
|
|
48
51
|
end
|
49
52
|
|
50
53
|
def octave
|
51
|
-
@octave ||= HeadMusic::DiatonicInterval.get(:perfect_octave)
|
54
|
+
@octave ||= HeadMusic::Analysis::DiatonicInterval.get(:perfect_octave)
|
52
55
|
end
|
53
56
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# Key signatures are enharmonic when all pitch classes in one are respellings of the pitch classes in the other.
|
2
|
-
class HeadMusic::KeySignature::EnharmonicEquivalence
|
2
|
+
class HeadMusic::Rudiment::KeySignature::EnharmonicEquivalence
|
3
3
|
attr_reader :key_signature
|
4
4
|
|
5
5
|
def self.get(key_signature)
|
6
|
-
key_signature = HeadMusic::KeySignature.get(key_signature)
|
6
|
+
key_signature = HeadMusic::Rudiment::KeySignature.get(key_signature)
|
7
7
|
@enharmonic_equivalences ||= {}
|
8
8
|
@enharmonic_equivalences[key_signature.to_s] ||= new(key_signature)
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize(key_signature)
|
12
|
-
@key_signature = HeadMusic::KeySignature.get(key_signature)
|
12
|
+
@key_signature = HeadMusic::Rudiment::KeySignature.get(key_signature)
|
13
13
|
end
|
14
14
|
|
15
15
|
def enharmonic_equivalent?(other)
|
16
|
-
other = HeadMusic::KeySignature.get(other)
|
16
|
+
other = HeadMusic::Rudiment::KeySignature.get(other)
|
17
17
|
|
18
18
|
key_signature.pitch_classes.map(&:to_i).sort == other.pitch_classes.map(&:to_i).sort &&
|
19
19
|
key_signature.alterations.map(&:to_s).sort != other.alterations.map(&:to_s).sort
|
@@ -1,5 +1,8 @@
|
|
1
|
+
# A module for music rudiments
|
2
|
+
module HeadMusic::Rudiment; end
|
3
|
+
|
1
4
|
# Represents a key signature.
|
2
|
-
class HeadMusic::KeySignature
|
5
|
+
class HeadMusic::Rudiment::KeySignature
|
3
6
|
attr_reader :tonic_spelling, :scale_type, :scale
|
4
7
|
|
5
8
|
ORDERED_LETTER_NAMES_OF_SHARPS = %w[F C G D A E B].freeze
|
@@ -10,7 +13,7 @@ class HeadMusic::KeySignature
|
|
10
13
|
end
|
11
14
|
|
12
15
|
def self.get(identifier)
|
13
|
-
return identifier if identifier.is_a?(HeadMusic::KeySignature)
|
16
|
+
return identifier if identifier.is_a?(HeadMusic::Rudiment::KeySignature)
|
14
17
|
|
15
18
|
@key_signatures ||= {}
|
16
19
|
tonic_spelling, scale_type_name = identifier.strip.split(/\s/)
|
@@ -23,11 +26,11 @@ class HeadMusic::KeySignature
|
|
23
26
|
delegate :pitches, :pitch_classes, to: :scale
|
24
27
|
|
25
28
|
def initialize(tonic_spelling, scale_type = nil)
|
26
|
-
@tonic_spelling = HeadMusic::Spelling.get(tonic_spelling)
|
27
|
-
@scale_type = HeadMusic::ScaleType.get(scale_type) if scale_type
|
28
|
-
@scale_type ||= HeadMusic::ScaleType.default
|
29
|
+
@tonic_spelling = HeadMusic::Rudiment::Spelling.get(tonic_spelling)
|
30
|
+
@scale_type = HeadMusic::Rudiment::ScaleType.get(scale_type) if scale_type
|
31
|
+
@scale_type ||= HeadMusic::Rudiment::ScaleType.default
|
29
32
|
@scale_type = @scale_type.parent || @scale_type
|
30
|
-
@scale = HeadMusic::Scale.get(@tonic_spelling, @scale_type)
|
33
|
+
@scale = HeadMusic::Rudiment::Scale.get(@tonic_spelling, @scale_type)
|
31
34
|
end
|
32
35
|
|
33
36
|
def spellings
|
@@ -102,6 +105,6 @@ class HeadMusic::KeySignature
|
|
102
105
|
private
|
103
106
|
|
104
107
|
def enharmonic_equivalence
|
105
|
-
@enharmonic_equivalence ||= HeadMusic::KeySignature::EnharmonicEquivalence.get(self)
|
108
|
+
@enharmonic_equivalence ||= HeadMusic::Rudiment::KeySignature::EnharmonicEquivalence.get(self)
|
106
109
|
end
|
107
110
|
end
|
@@ -1,5 +1,8 @@
|
|
1
|
+
# A module for music rudiments
|
2
|
+
module HeadMusic::Rudiment; end
|
3
|
+
|
1
4
|
# Music has seven lette names that are used to identify pitches and pitch classes.
|
2
|
-
class HeadMusic::LetterName
|
5
|
+
class HeadMusic::Rudiment::LetterName
|
3
6
|
NAMES = %w[C D E F G A B].freeze
|
4
7
|
|
5
8
|
NATURAL_PITCH_CLASS_NUMBERS = {
|
@@ -32,7 +35,7 @@ class HeadMusic::LetterName
|
|
32
35
|
|
33
36
|
pitch_class = pitch_class.to_i % 12
|
34
37
|
name = NAMES.detect { |candidate| pitch_class == NATURAL_PITCH_CLASS_NUMBERS[candidate] }
|
35
|
-
name ||= HeadMusic::PitchClass::SHARP_SPELLINGS[pitch_class].first
|
38
|
+
name ||= HeadMusic::Rudiment::PitchClass::SHARP_SPELLINGS[pitch_class].first
|
36
39
|
@letter_names[name] ||= new(name) if NAMES.include?(name)
|
37
40
|
end
|
38
41
|
|
@@ -47,7 +50,7 @@ class HeadMusic::LetterName
|
|
47
50
|
end
|
48
51
|
|
49
52
|
def pitch_class
|
50
|
-
HeadMusic::PitchClass.get(NATURAL_PITCH_CLASS_NUMBERS[name])
|
53
|
+
HeadMusic::Rudiment::PitchClass.get(NATURAL_PITCH_CLASS_NUMBERS[name])
|
51
54
|
end
|
52
55
|
|
53
56
|
def ==(other)
|
@@ -59,15 +62,15 @@ class HeadMusic::LetterName
|
|
59
62
|
end
|
60
63
|
|
61
64
|
def steps_up(num)
|
62
|
-
HeadMusic::LetterName.get(series_ascending[num % NAMES.length])
|
65
|
+
HeadMusic::Rudiment::LetterName.get(series_ascending[num % NAMES.length])
|
63
66
|
end
|
64
67
|
|
65
68
|
def steps_down(num)
|
66
|
-
HeadMusic::LetterName.get(series_descending[num % NAMES.length])
|
69
|
+
HeadMusic::Rudiment::LetterName.get(series_descending[num % NAMES.length])
|
67
70
|
end
|
68
71
|
|
69
72
|
def steps_to(other, direction = :ascending)
|
70
|
-
other = HeadMusic::LetterName.get(other)
|
73
|
+
other = HeadMusic::Rudiment::LetterName.get(other)
|
71
74
|
other_position = other.position
|
72
75
|
if direction == :descending
|
73
76
|
other_position -= NAMES.length if other_position > position
|