Sha256: a9e402708c5798913fc28f12020471ae16cdca6701b0632039cb3947fff95aa9

Contents?: true

Size: 738 Bytes

Versions: 8

Compression:

Stored size: 738 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::StepDownToFinalNote < HeadMusic::Style::Annotation
  MESSAGE = 'Step down to final note.'

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

  private

  def descending?
    last_melodic_interval && last_melodic_interval.descending?
  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

8 entries across 8 versions & 1 rubygems

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