Sha256: 2e62e70eee410ce701bc5d3e0c2f978ef2cf23f0b9c4c071f3d4be7709555f3d

Contents?: true

Size: 493 Bytes

Versions: 10

Compression:

Stored size: 493 Bytes

Contents

module HeadMusic::Style::Annotations
end

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

  MESSAGE = 'Limit melodic range to a 10th.'

  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

10 entries across 10 versions & 1 rubygems

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