Sha256: 9584d53aa7a0d7968afe54cb975da950aba0314464a15aa6126e4aa4788f2dc4

Contents?: true

Size: 588 Bytes

Versions: 9

Compression:

Stored size: 588 Bytes

Contents

# frozen_string_literal: true

# Module for style guidelines.
module HeadMusic::Style::Guidelines; end

# A voice shouldn't expend the range of a 10th.
class HeadMusic::Style::Guidelines::SingableRange < HeadMusic::Style::Annotation
  MAXIMUM_RANGE = 10

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

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

  private

  def overage
    notes.any? ? [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-4.0.1 lib/head_music/style/guidelines/singable_range.rb
head_music-4.0.0 lib/head_music/style/guidelines/singable_range.rb
head_music-3.0.1 lib/head_music/style/guidelines/singable_range.rb
head_music-3.0.0 lib/head_music/style/guidelines/singable_range.rb
head_music-2.0.1 lib/head_music/style/guidelines/singable_range.rb
head_music-2.0.0 lib/head_music/style/guidelines/singable_range.rb
head_music-1.0.0 lib/head_music/style/guidelines/singable_range.rb
head_music-0.29.0 lib/head_music/style/guidelines/singable_range.rb
head_music-0.28.0 lib/head_music/style/guidelines/singable_range.rb