Sha256: 2e500e543df3f42d48b1da5956e1b6e44a96be4717c644219500179fc5a76cc2

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::StepUpToFinalNote < HeadMusic::Style::Annotation
  def message
    'Step up to final note.'
  end

  def marks
    if !last_melodic_interval.nil?
      fitness = 1
      fitness *= HeadMusic::PENALTY_FACTOR unless step?
      fitness *= HeadMusic::PENALTY_FACTOR unless ascending?
      if fitness < 1
        HeadMusic::Style::Mark.for_all(notes[-2..-1], fitness: fitness)
      end
    end
  end

  private

  def ascending?
    last_melodic_interval && last_melodic_interval.ascending?
  end

  def step?
    last_melodic_interval && last_melodic_interval.step?
  end

  def last_melodic_interval
    @last_melodic_interval ||= melodic_intervals.last
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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