Sha256: 72ef80957860776a8f39e4f3e56bf8a5d1bb59e734d0c1fd06c68c648ca6510c

Contents?: true

Size: 731 Bytes

Versions: 10

Compression:

Stored size: 731 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::StepUpToFinalNote < HeadMusic::Style::Annotation
  MESSAGE = 'Step up to final note.'

  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

10 entries across 10 versions & 1 rubygems

Version Path
head_music-0.17.0 lib/head_music/style/annotations/step_up_to_final_note.rb
head_music-0.16.2 lib/head_music/style/annotations/step_up_to_final_note.rb
head_music-0.16.0 lib/head_music/style/annotations/step_up_to_final_note.rb
head_music-0.14.8 lib/head_music/style/annotations/step_up_to_final_note.rb
head_music-0.14.7 lib/head_music/style/annotations/step_up_to_final_note.rb
head_music-0.14.5 lib/head_music/style/annotations/step_up_to_final_note.rb
head_music-0.14.4 lib/head_music/style/annotations/step_up_to_final_note.rb
head_music-0.14.2 lib/head_music/style/annotations/step_up_to_final_note.rb
head_music-0.14.1 lib/head_music/style/annotations/step_up_to_final_note.rb
head_music-0.13.2 lib/head_music/style/annotations/step_up_to_final_note.rb