Sha256: a6053941c28deb6a2812ba61af69e99637f08c0a43c7bc41b6f7c2aa98db5fda

Contents?: true

Size: 678 Bytes

Versions: 2

Compression:

Stored size: 678 Bytes

Contents

# frozen_string_literal: true

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

# A counterpoint guideline
class HeadMusic::Style::Annotations::OneToOne < HeadMusic::Style::Annotation
  MESSAGE = 'Place a note for each note in the other voice.'

  def marks
    return unless cantus_firmus&.notes
    return if cantus_firmus.notes.empty?
    HeadMusic::Style::Mark.for_each(
      notes_without_match(voice, cantus_firmus) + notes_without_match(cantus_firmus, voice)
    )
  end

  private

  def notes_without_match(voice1, voice2)
    voice1.notes.reject do |voice1_note|
      voice2.notes.map(&:position).include?(voice1_note.position)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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