Class: HeadMusic::Style::Guidelines::SingableRange

Inherits:
Annotation
  • Object
show all
Defined in:
lib/head_music/style/guidelines/singable_range.rb

Overview

A voice shouldn't expend the range of a 10th.

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from HeadMusic::Style::Annotation

Instance Method Details

#extremesObject (private)



20
21
22
# File 'lib/head_music/style/guidelines/singable_range.rb', line 20

def extremes
  (highest_notes + lowest_notes).sort
end

#marksObject



10
11
12
# File 'lib/head_music/style/guidelines/singable_range.rb', line 10

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

#overageObject (private)



16
17
18
# File 'lib/head_music/style/guidelines/singable_range.rb', line 16

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