head_music 6.0.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,6 +100,7 @@ en:
100
100
  wind_instrument: wind instrument
101
101
  wood: wood
102
102
  woodwind: woodwind
103
+ instrument_with_pitch_designation: "%{instrument} in %{pitch_designation}"
103
104
  instrument_voices:
104
105
  piccolo: piccolo
105
106
  soprano: soprano
@@ -126,27 +127,17 @@ en:
126
127
  bass_oboe: bass oboe
127
128
  bass_trombone: bass trombone
128
129
  bass_trumpet: bass trumpet
129
- bass_trumpet_in_b_flat: bass trumpet in B♭
130
- bass_trumpet_in_c: bass trumpet in C
131
- bass_trumpet_in_e_flat: bass trumpet in E♭
132
130
  bass_tuba: bass tuba
133
- bass_tuba_in_e_flat: bass tuba in E♭
134
- bass_tuba_in_f: bass tuba in F
135
131
  bass_voice: bass
136
132
  basset_horn: basset horn
137
133
  bassoon: bassoon
138
134
  bugle: bugle
139
- bugle_in_b_flat: bugle in B♭
140
135
  castanets: castanets
141
136
  celesta: celesta
142
137
  cello: cello
143
138
  chimes: chimes
144
139
  cimbalom: cimbalom
145
140
  clarinet: clarinet
146
- clarinet_in_a: clarinet in A
147
- clarinet_in_c: clarinet in C
148
- clarinet_in_d: clarinet in D
149
- clarinet_in_e_flat: clarinet in E♭
150
141
  clash_cymbals: clash cymbals
151
142
  clavichord: clavichord
152
143
  contrabass_clarinet: contrabass clarinet
@@ -202,11 +193,7 @@ en:
202
193
  triangle: triangle
203
194
  trombone: trombone
204
195
  trumpet: trumpet
205
- trumpet_in_c: trumpet in C
206
- trumpet_in_d: trumpet in D
207
- trumpet_in_e_flat: trumpet in E♭
208
196
  tuba: tuba
209
- tuba_in_c: tuba in C
210
197
  tubular_bells: tubular bells
211
198
  vibraphone: vibraphone
212
199
  viola: viola
@@ -48,7 +48,9 @@ class HeadMusic::Motion
48
48
  end
49
49
 
50
50
  def to_s
51
- "#{contrapuntal_motion} motion from #{first_harmonic_interval} to #{second_harmonic_interval}"
51
+ return "repetition of a #{second_harmonic_interval}" unless contrapuntal_motion != :repetition
52
+
53
+ "#{contrapuntal_motion} motion from a #{first_harmonic_interval} to a #{second_harmonic_interval}"
52
54
  end
53
55
 
54
56
  private
@@ -103,8 +103,4 @@ module HeadMusic::Named
103
103
  def localized_name_in_default_locale
104
104
  localized_names.detect { |name| name.locale_code == Locale::DEFAULT_CODE }
105
105
  end
106
-
107
- def hash_key
108
- HeadMusic::Utilities::HashKey.for(name)
109
- end
110
106
  end
@@ -10,13 +10,10 @@ class HeadMusic::PitchClassSet
10
10
  @pitch_classes = identifiers.map { |identifier| HeadMusic::PitchClass.get(identifier) }.uniq.sort
11
11
  end
12
12
 
13
- def inspect
14
- pitch_classes.map(&:to_s).join(" ")
15
- end
16
-
17
13
  def to_s
18
- pitch_classes.map(&:to_s).join(" ")
14
+ pitch_classes.map(&:to_i).inspect
19
15
  end
16
+ alias_method :inspect, :to_s
20
17
 
21
18
  def ==(other)
22
19
  pitch_classes == other.pitch_classes
@@ -28,6 +28,10 @@ class HeadMusic::Scale
28
28
  @pitches[direction][octaves] ||= determine_scale_pitches(direction, octaves)
29
29
  end
30
30
 
31
+ def pitch_classes
32
+ pitches.map(&:pitch_class).uniq
33
+ end
34
+
31
35
  def spellings(direction: :ascending, octaves: 1)
32
36
  pitches(direction: direction, octaves: octaves).map(&:spelling).map(&:to_s)
33
37
  end
@@ -1,4 +1,4 @@
1
- # A scale degree is a number indicating the ordinality of the spelling in the key signature.
1
+ # A scale degree is a number indicating the ordinality of the spelling in the key.
2
2
  # TODO: Rewrite to accept a tonal_center and a scale type.
3
3
  class HeadMusic::ScaleDegree
4
4
  include Comparable
@@ -20,20 +20,25 @@ class HeadMusic::ScaleDegree
20
20
  end
21
21
 
22
22
  def alteration
23
- alteration_semitones = spelling.alteration&.semitones || 0
23
+ spelling_alteration_semitones = spelling.alteration&.semitones || 0
24
24
  usual_sign_semitones = scale_degree_usual_spelling.alteration&.semitones || 0
25
- delta = alteration_semitones - usual_sign_semitones
25
+ delta = spelling_alteration_semitones - usual_sign_semitones
26
26
  HeadMusic::Alteration.by(:semitones, delta) if delta != 0
27
27
  end
28
28
 
29
+ def alteration_semitones
30
+ alteration&.semitones || 0
31
+ end
32
+
29
33
  def to_s
30
34
  "#{alteration}#{degree}"
31
35
  end
32
36
 
33
37
  def <=>(other)
34
38
  if other.is_a?(HeadMusic::ScaleDegree)
35
- [degree, alteration.semitones] <=> [other.degree, other.alteration.semitones]
39
+ [degree, alteration_semitones] <=> [other.degree, other.alteration_semitones]
36
40
  else
41
+ # TODO: Improve this
37
42
  to_s <=> other.to_s
38
43
  end
39
44
  end
@@ -37,10 +37,6 @@ class HeadMusic::Style::Guidelines::NotesSameLength < HeadMusic::Style::Annotati
37
37
  notes[0..-2]
38
38
  end
39
39
 
40
- def distinct_values
41
- all_but_last_note.map(&:rhythmic_value).uniq.length
42
- end
43
-
44
40
  def first_most_common_rhythmic_value
45
41
  @first_most_common_rhythmic_value ||= begin
46
42
  candidates = most_common_rhythmic_values
@@ -33,8 +33,5 @@ class HeadMusic::Style::Mark
33
33
  def code
34
34
  [start_position, end_position].join(" to ")
35
35
  end
36
-
37
- def to_s
38
- code
39
- end
36
+ alias_method :to_s, :code
40
37
  end
@@ -1,3 +1,3 @@
1
1
  module HeadMusic
2
- VERSION = "6.0.0"
2
+ VERSION = "7.0.0"
3
3
  end
data/lib/head_music.rb CHANGED
@@ -38,14 +38,20 @@ require "head_music/circle"
38
38
  require "head_music/clef"
39
39
  require "head_music/consonance"
40
40
  require "head_music/diatonic_interval"
41
+ require "head_music/diatonic_interval/category"
42
+ require "head_music/diatonic_interval/naming"
43
+ require "head_music/diatonic_interval/parser"
44
+ require "head_music/diatonic_interval/semitones"
45
+ require "head_music/diatonic_interval/size"
41
46
  require "head_music/harmonic_interval"
42
47
  require "head_music/instrument_family"
43
48
  require "head_music/instrument"
44
- require "head_music/instrument/pitch_variant"
45
49
  require "head_music/instrument/staff_scheme"
46
50
  require "head_music/instrument/staff"
51
+ require "head_music/instrument/variant"
47
52
  require "head_music/interval_cycle"
48
53
  require "head_music/key_signature"
54
+ require "head_music/key_signature/enharmonic_equivalence"
49
55
  require "head_music/letter_name"
50
56
  require "head_music/melodic_interval"
51
57
  require "head_music/meter"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: head_music
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Head
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-29 00:00:00.000000000 Z
11
+ date: 2024-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -136,14 +136,20 @@ files:
136
136
  - lib/head_music/data/instrument_families.yml
137
137
  - lib/head_music/data/instruments.yml
138
138
  - lib/head_music/diatonic_interval.rb
139
+ - lib/head_music/diatonic_interval/category.rb
140
+ - lib/head_music/diatonic_interval/naming.rb
141
+ - lib/head_music/diatonic_interval/parser.rb
142
+ - lib/head_music/diatonic_interval/semitones.rb
143
+ - lib/head_music/diatonic_interval/size.rb
139
144
  - lib/head_music/harmonic_interval.rb
140
145
  - lib/head_music/instrument.rb
141
- - lib/head_music/instrument/pitch_variant.rb
142
146
  - lib/head_music/instrument/staff.rb
143
147
  - lib/head_music/instrument/staff_scheme.rb
148
+ - lib/head_music/instrument/variant.rb
144
149
  - lib/head_music/instrument_family.rb
145
150
  - lib/head_music/interval_cycle.rb
146
151
  - lib/head_music/key_signature.rb
152
+ - lib/head_music/key_signature/enharmonic_equivalence.rb
147
153
  - lib/head_music/letter_name.rb
148
154
  - lib/head_music/locales/de.yml
149
155
  - lib/head_music/locales/en.yml