Sha256: dbe8294bf67abf432cd54a9e45c35eb870c85c905b3374762f00daba5cf52f47

Contents?: true

Size: 588 Bytes

Versions: 21

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

21 entries across 21 versions & 1 rubygems

Version Path
head_music-0.27.0 lib/head_music/style/guidelines/singable_range.rb
head_music-0.26.3 lib/head_music/style/guidelines/singable_range.rb
head_music-0.26.2 lib/head_music/style/guidelines/singable_range.rb
head_music-0.26.1 lib/head_music/style/guidelines/singable_range.rb
head_music-0.26.0 lib/head_music/style/guidelines/singable_range.rb
head_music-0.25.0 lib/head_music/style/guidelines/singable_range.rb
head_music-0.24.5 lib/head_music/style/guidelines/singable_range.rb
head_music-0.24.4 lib/head_music/style/guidelines/singable_range.rb
head_music-0.24.3 lib/head_music/style/guidelines/singable_range.rb
head_music-0.24.2 lib/head_music/style/guidelines/singable_range.rb
head_music-0.24.1 lib/head_music/style/guidelines/singable_range.rb
head_music-0.24.0 lib/head_music/style/guidelines/singable_range.rb
head_music-0.23.4 lib/head_music/style/guidelines/singable_range.rb
head_music-0.23.3 lib/head_music/style/guidelines/singable_range.rb
head_music-0.23.2 lib/head_music/style/guidelines/singable_range.rb
head_music-0.23.1 lib/head_music/style/guidelines/singable_range.rb
head_music-0.23.0 lib/head_music/style/guidelines/singable_range.rb
head_music-0.22.0 lib/head_music/style/guidelines/singable_range.rb
head_music-0.20.0 lib/head_music/style/guidelines/singable_range.rb
head_music-0.19.2 lib/head_music/style/guidelines/singable_range.rb