Class: HeadMusic::Style::Guidelines::DirectionChanges
- Inherits:
-
Annotation
- Object
- Annotation
- HeadMusic::Style::Guidelines::DirectionChanges
show all
- Defined in:
- lib/head_music/style/guidelines/direction_changes.rb
Overview
A melodic line should have direction changes.
Instance Method Summary
collapse
Instance Method Details
#marks ⇒ Object
6
7
8
9
10
11
|
# File 'lib/head_music/style/guidelines/direction_changes.rb', line 6
def marks
return unless overage.positive?
penalty_exponent = overage**0.5
HeadMusic::Style::Mark.for_all(notes, fitness: HeadMusic::PENALTY_FACTOR**penalty_exponent)
end
|
#melodic_intervals_changing_direction ⇒ Object
25
26
27
28
29
|
# File 'lib/head_music/style/guidelines/direction_changes.rb', line 25
def melodic_intervals_changing_direction
melodic_intervals.each_cons(2).reject do |interval_pair|
interval_pair[0].direction == interval_pair[1].direction
end
end
|
#notes_per_direction ⇒ Object
21
22
23
|
# File 'lib/head_music/style/guidelines/direction_changes.rb', line 21
def notes_per_direction
notes.length.to_f / (melodic_intervals_changing_direction.length + 1)
end
|
#overage ⇒ Object
15
16
17
18
19
|
# File 'lib/head_music/style/guidelines/direction_changes.rb', line 15
def overage
return 0 if notes.length < 2
[notes_per_direction - self.class.maximum_notes_per_direction, 0].max
end
|