Module: HeadMusic::Style::Guideline::VoiceContext

Included in:
HeadMusic::Style::Guideline
Defined in:
lib/head_music/style/guideline/voice_context.rb

Overview

The company the voice keeps: the other parts of the composition, sorted and named the way a counterpoint rule asks after them.

Instance Method Summary collapse

Instance Method Details

#bass_voice?Boolean (protected)

Returns:

  • (Boolean)


29
30
31
# File 'lib/head_music/style/guideline/voice_context.rb', line 29

def bass_voice?
  lower_voices.empty?
end

#cantus_firmusObject (protected)



17
18
19
# File 'lib/head_music/style/guideline/voice_context.rb', line 17

def cantus_firmus
  @cantus_firmus ||= other_voices.detect(&:cantus_firmus?) || other_voices.first
end

#higher_voicesObject (protected)



21
22
23
# File 'lib/head_music/style/guideline/voice_context.rb', line 21

def higher_voices
  @higher_voices ||= unsorted_higher_voices.sort_by(&:highest_pitch).reverse
end

#lower_voicesObject (protected)



25
26
27
# File 'lib/head_music/style/guideline/voice_context.rb', line 25

def lower_voices
  @lower_voices ||= unsorted_lower_voices.sort_by(&:lowest_pitch).reverse
end

#other_voicesObject (protected)



13
14
15
# File 'lib/head_music/style/guideline/voice_context.rb', line 13

def other_voices
  @other_voices ||= voices.reject { |part| part == voice }
end

#unsorted_higher_voicesObject (protected)



33
34
35
# File 'lib/head_music/style/guideline/voice_context.rb', line 33

def unsorted_higher_voices
  other_voices.select { |part| part.highest_pitch && highest_pitch && part.highest_pitch > highest_pitch }
end

#unsorted_lower_voicesObject (protected)



37
38
39
# File 'lib/head_music/style/guideline/voice_context.rb', line 37

def unsorted_lower_voices
  other_voices.select { |part| part.lowest_pitch && lowest_pitch && part.lowest_pitch < lowest_pitch }
end

#voicesObject (protected)



9
10
11
# File 'lib/head_music/style/guideline/voice_context.rb', line 9

def voices
  @voices ||= voice.composition.voices
end