Sha256: 3750c6a3abf8a0ed0987966499fa0ae670193c4a720ea95e49524ba5af91324f

Contents?: true

Size: 670 Bytes

Versions: 2

Compression:

Stored size: 670 Bytes

Contents

# frozen_string_literal: true

# Module for Annotations.
module HeadMusic::Style::Annotations; end

# A counterpoint guideline
class HeadMusic::Style::Annotations::NoUnisonsInMiddle < HeadMusic::Style::Annotation
  MESSAGE = 'Unisons may only be used in the first and last note.'

  def marks
    unison_pairs.map do |notes|
      HeadMusic::Style::Mark.for_all(notes)
    end.flatten
  end

  private

  def unison_pairs
    middle_unisons.map(&:notes).compact
  end

  def middle_unisons
    middle_intervals.select { |interval| interval.perfect_consonance? && interval.unison? }
  end

  def middle_intervals
    [harmonic_intervals[1..-2]].flatten.compact
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
head_music-0.19.0 lib/head_music/style/annotations/no_unisons_in_middle.rb
head_music-0.18.0 lib/head_music/style/annotations/no_unisons_in_middle.rb