Class: HeadMusic::Style::Guidelines::PreferContraryMotion
- Inherits:
-
Annotation
- Object
- Annotation
- HeadMusic::Style::Guidelines::PreferContraryMotion
show all
- Defined in:
- lib/head_music/style/guidelines/prefer_contrary_motion.rb
Overview
Constant Summary
collapse
- MESSAGE =
"Prefer contrary motion. Move voices in different melodic directions."
Instance Method Summary
collapse
Instance Method Details
#direct_motion_ratio ⇒ Object
21
22
23
24
25
|
# File 'lib/head_music/style/guidelines/prefer_contrary_motion.rb', line 21
def direct_motion_ratio
return 0 if motions.empty?
direct_motions.count / motions.count.to_f
end
|
#direct_motions ⇒ Object
17
18
19
|
# File 'lib/head_music/style/guidelines/prefer_contrary_motion.rb', line 17
def direct_motions
motions.select(&:direct?)
end
|
#marks ⇒ Object
8
9
10
11
12
13
|
# File 'lib/head_music/style/guidelines/prefer_contrary_motion.rb', line 8
def marks
return nil if notes.length < 2
return nil if direct_motion_ratio <= 0.5
direct_motions.map { |motion| HeadMusic::Style::Mark.for_all(motion.notes) }
end
|