head_music 0.14.5 → 0.14.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0b7d00507a0468cb5947e49f0dc1847f7ca1c0b
4
- data.tar.gz: c24126e1c7dbee18ab8f7f2571a95502fa0346c8
3
+ metadata.gz: 6ee796cb3bb39a7c883ef5fecff41ead56379c3a
4
+ data.tar.gz: 35bc35b0515ea35214ee16b8a6375db44ad87ed2
5
5
  SHA512:
6
- metadata.gz: 7720a64094550760f3f70be5f1bc4eadd7adb8c7c454107f1b9f0e3eb81782b9db8a470cb832819512c02e1ca82e9bb659ae729c90181ce04fe99a0d1a1d3823
7
- data.tar.gz: 42cc3e0ec4c1e149c504f020a82beb794ff6e4f0b6f33fb33f5ac476098fd215d5ca6ab4ec60d0191afb918aac69887cf3dde45fbe9c72a0fba471bbdea8cea3
6
+ metadata.gz: f95982b86a3367e79908aba86aa4b718d57fe29be9ddd101bd5cf718be0d12d34b746050e57286258e4f2894188e0741615f48af96b90fba974ce5f8c4bd9ee7
7
+ data.tar.gz: def4f16467102b4d9b8e3cf8a1dbdd8e36af1d3e76a8c5410d9ac331ece35e06083fbddd6543cf8cab7f7f19b11183d06374ea5f915f49ad090e20101fd57f6a
@@ -191,8 +191,12 @@ class HeadMusic::FunctionalInterval
191
191
  self.semitones <=> other.semitones
192
192
  end
193
193
 
194
- NUMBER_NAMES.each do |method_name|
195
- define_method(:"#{method_name}?") { number_name == method_name }
194
+ NUMBER_NAMES.each do |interval_name|
195
+ define_method(:"#{interval_name}?") { number_name == interval_name }
196
+ end
197
+
198
+ NUMBER_NAMES.first(8).each do |method_name|
199
+ define_method(:"#{method_name}_or_compound?") { simple_number_name == method_name }
196
200
  end
197
201
 
198
202
  private
@@ -202,10 +206,10 @@ class HeadMusic::FunctionalInterval
202
206
  end
203
207
 
204
208
  def consonance_for_major_and_minor
205
- HeadMusic::Consonance.get((third? || sixth?) ? :imperfect : :dissonant) if (major? || minor?)
209
+ HeadMusic::Consonance.get((third_or_compound? || sixth_or_compound?) ? :imperfect : :dissonant) if (major? || minor?)
206
210
  end
207
211
 
208
212
  def dissonant_fourth?(style = :standard_practice)
209
- fourth? && style == :two_part_harmony
213
+ fourth_or_compound? && style == :two_part_harmony
210
214
  end
211
215
  end
@@ -15,6 +15,10 @@ class HeadMusic::Note
15
15
  @placement ||= HeadMusic::Placement.new(voice, position, rhythmic_value, pitch)
16
16
  end
17
17
 
18
+ def to_s
19
+ "#{pitch} at #{position}"
20
+ end
21
+
18
22
  def method_missing(method_name, *args, &block)
19
23
  placement.send(method_name, *args, &block)
20
24
  end
@@ -31,6 +31,10 @@ class HeadMusic::Placement
31
31
  (other_placement.position <= position && other_placement.next_position >= next_position)
32
32
  end
33
33
 
34
+ def to_s
35
+ "#{pitch ? pitch : 'rest'} at #{position}"
36
+ end
37
+
34
38
  private
35
39
 
36
40
  def ensure_attributes(voice, position, rhythmic_value, pitch)
@@ -21,7 +21,7 @@ class HeadMusic::ScaleDegree
21
21
  scale_degree_usual_spelling.accidental
22
22
  accidental_semitones = spelling.accidental && spelling.accidental.semitones || 0
23
23
  usual_accidental_semitones = scale_degree_usual_spelling.accidental && scale_degree_usual_spelling.accidental.semitones || 0
24
- Accidental.for_interval(accidental_semitones - usual_accidental_semitones)
24
+ HeadMusic::Accidental.for_interval(accidental_semitones - usual_accidental_semitones)
25
25
  end
26
26
 
27
27
  def to_s
@@ -84,7 +84,11 @@ class HeadMusic::Style::Annotation
84
84
  end
85
85
 
86
86
  def functional_interval_from_tonic(note)
87
- HeadMusic::FunctionalInterval.new(tonic_spelling, note.spelling)
87
+ tonic_to_use = tonic_pitch
88
+ while tonic_to_use > note.pitch
89
+ tonic_to_use -= Interval.named(:perfect_octave)
90
+ end
91
+ HeadMusic::FunctionalInterval.new(tonic_to_use, note.pitch)
88
92
  end
89
93
 
90
94
  def bass_voice?
@@ -128,4 +132,8 @@ class HeadMusic::Style::Annotation
128
132
  def unsorted_lower_voices
129
133
  other_voices.select { |part| part.lowest_pitch && lowest_pitch && part.lowest_pitch < lowest_pitch }
130
134
  end
135
+
136
+ def tonic_pitch
137
+ @tonic_pitch ||= HeadMusic::Pitch.get(tonic_spelling)
138
+ end
131
139
  end
@@ -24,10 +24,6 @@ class HeadMusic::Style::Annotations::ConsonantClimax < HeadMusic::Style::Annotat
24
24
  HeadMusic::FunctionalInterval.new(tonic_pitch, highest_pitch)
25
25
  end
26
26
 
27
- def tonic_pitch
28
- @tonic_pitch ||= HeadMusic::Pitch.get(tonic_spelling)
29
- end
30
-
31
27
  def highest_pitch_appears_once?
32
28
  highest_notes.length == 1
33
29
  end
@@ -43,7 +39,7 @@ class HeadMusic::Style::Annotations::ConsonantClimax < HeadMusic::Style::Annotat
43
39
  end
44
40
 
45
41
  def step_between_highest_notes?
46
- MelodicInterval.new(voice, highest_notes.first, notes_between_highest_notes.first).step?
42
+ HeadMusic::MelodicInterval.new(voice, highest_notes.first, notes_between_highest_notes.first).step?
47
43
  end
48
44
 
49
45
  def single_note_between_highest_notes?
@@ -3,7 +3,7 @@ end
3
3
 
4
4
  # marks the voice if the first note is not the first or fifth scale degree of the key.
5
5
  class HeadMusic::Style::Annotations::StartOnPerfectConsonance < HeadMusic::Style::Annotation
6
- MESSAGE = 'Start on the tonic or a perfect consonance above the tonic.'
6
+ MESSAGE = 'Start on the tonic or a perfect consonance above the tonic (unless bass voice).'
7
7
 
8
8
  def marks
9
9
  if first_note && ((bass_voice? && !starts_on_tonic?) || !starts_on_perfect_consonance?)
@@ -1,3 +1,3 @@
1
1
  module HeadMusic
2
- VERSION = "0.14.5"
2
+ VERSION = "0.14.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: head_music
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.5
4
+ version: 0.14.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Head