Sha256: b609b19cf3c2fdd5958c507a323914c62af645525406742c0fc4c07c1dd17955

Contents?: true

Size: 750 Bytes

Versions: 9

Compression:

Stored size: 750 Bytes

Contents

module HeadMusic::Style::Annotations
end

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

  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

9 entries across 9 versions & 1 rubygems

Version Path
head_music-0.11.9 lib/head_music/style/annotations/step_down_to_final_note.rb
head_music-0.11.8 lib/head_music/style/annotations/step_down_to_final_note.rb
head_music-0.11.7 lib/head_music/style/annotations/step_down_to_final_note.rb
head_music-0.11.6 lib/head_music/style/annotations/step_down_to_final_note.rb
head_music-0.11.5 lib/head_music/style/annotations/step_down_to_final_note.rb
head_music-0.11.4 lib/head_music/style/annotations/step_down_to_final_note.rb
head_music-0.11.3 lib/head_music/style/annotations/step_down_to_final_note.rb
head_music-0.11.2 lib/head_music/style/annotations/step_down_to_final_note.rb
head_music-0.11.1 lib/head_music/style/annotations/step_down_to_final_note.rb