Sha256: 456591d3ec6b6c80a5dd97bb461e44a8b85656c5dc10cbe0f5f0d81e5dea345b

Contents?: true

Size: 883 Bytes

Versions: 9

Compression:

Stored size: 883 Bytes

Contents

# Module for style guidelines.
module HeadMusic::Style::Guidelines; end

# A counterpoint guideline
class HeadMusic::Style::Guidelines::AvoidCrossingVoices < HeadMusic::Style::Annotation
  MESSAGE = "Avoid crossing voices. Maintain the high-low relationship between voices."

  def marks
    crossings.map do |crossing|
      HeadMusic::Style::Mark.for_all(crossing.notes)
    end
  end

  private

  def crossings
    harmonic_intervals.select do |harmonic_interval|
      harmonic_interval.pitch_orientation && harmonic_interval.pitch_orientation != predominant_pitch_orientation
    end
  end

  def predominant_pitch_orientation
    pitch_orientations
      .compact
      .group_by { |orientation| orientation }
      .max { |a, b| a[1].length <=> b[1].length }
      .first
  end

  def pitch_orientations
    harmonic_intervals.map(&:pitch_orientation).compact.uniq
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
head_music-7.0.5 lib/head_music/style/guidelines/avoid_crossing_voices.rb
head_music-7.0.4 lib/head_music/style/guidelines/avoid_crossing_voices.rb
head_music-7.0.3 lib/head_music/style/guidelines/avoid_crossing_voices.rb
head_music-7.0.2 lib/head_music/style/guidelines/avoid_crossing_voices.rb
head_music-7.0.1 lib/head_music/style/guidelines/avoid_crossing_voices.rb
head_music-7.0.0 lib/head_music/style/guidelines/avoid_crossing_voices.rb
head_music-6.0.1 lib/head_music/style/guidelines/avoid_crossing_voices.rb
head_music-6.0.0 lib/head_music/style/guidelines/avoid_crossing_voices.rb
head_music-5.0.0 lib/head_music/style/guidelines/avoid_crossing_voices.rb