Sha256: 8e58b239c2b0b9f824fc891adabb77653aca2e336977dabe5d20124ee9eac529

Contents?: true

Size: 502 Bytes

Versions: 9

Compression:

Stored size: 502 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::LimitRange < HeadMusic::Style::Annotation
  MAXIMUM_RANGE = 10

  def message
    'Limit melodic range to a 10th.'
  end

  def marks
    if overage > 0
      HeadMusic::Style::Mark.for_each(extremes, fitness: HeadMusic::PENALTY_FACTOR**overage)
    end
  end

  private

  def overage
    notes.length > 0 ? [range.number - MAXIMUM_RANGE, 0].max : 0
  end

  def extremes
    (highest_notes + lowest_notes).sort
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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