Sha256: 83b84f74134c722832305ac114e6ee89a4e4c5565c3806660702f3ffc55967bd

Contents?: true

Size: 723 Bytes

Versions: 2

Compression:

Stored size: 723 Bytes

Contents

# frozen_string_literal: true

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

# A counterpoint guideline
class HeadMusic::Style::Annotations::Diatonic < HeadMusic::Style::Annotation
  MESSAGE = 'Use only notes in the key signature.'

  def marks
    HeadMusic::Style::Mark.for_each(notes_not_in_key_excluding_penultimate_leading_tone)
  end

  private

  def notes_not_in_key_excluding_penultimate_leading_tone
    notes_not_in_key.reject do |note|
      penultimate_note &&
        note == penultimate_note &&
        HeadMusic::ScaleDegree.new(key_signature, note.pitch.spelling).sign == '#'
    end
  end

  def penultimate_note
    voice.note_preceding(positions.last) if positions.last
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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