Sha256: ff550137be10050bbb7a63150a51ca6db1b0e302d841bbbc7bf000c5b44f7e17

Contents?: true

Size: 780 Bytes

Versions: 1

Compression:

Stored size: 780 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::OneToOne < HeadMusic::Style::Annotation
  def message
    'Place a note for each note in the other voice.'
  end

  def marks
    if other_voice && other_voice.notes.length > 0
      HeadMusic::Style::Mark.for_each(
        notes_without_match(voice, other_voice) + notes_without_match(other_voice, voice)
      )
    end
  end

  private

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

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

  def other_voices
    @other_voices ||= voice.composition.voices.select { |part| part != voice }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
head_music-0.11.9 lib/head_music/style/annotations/one_to_one.rb