Sha256: 8980618f90bfded8f4df66b20eb7aea778d328211ae5c41cba4b64a9f5436fcd
Contents?: true
Size: 811 Bytes
Versions: 2
Compression:
Stored size: 811 Bytes
Contents
# frozen_string_literal: true # Module for Annotations. module HeadMusic::Style::Annotations; end # A counterpoint guideline class HeadMusic::Style::Annotations::PreferImperfect < HeadMusic::Style::Annotation MESSAGE = 'Prefer imperfect harmonic intervals.' def marks HeadMusic::Style::Mark.for_all(perfect_intervals.map(&:notes).flatten) if ratio_of_perfect_intervals >= 0.5 end private def ratio_of_perfect_intervals return 0 if downbeat_harmonic_intervals_in_middle.nil? perfect_intervals.length.to_f / downbeat_harmonic_intervals.length end def perfect_intervals downbeat_harmonic_intervals_in_middle.select { |interval| interval.perfect_consonance?(:two_part_harmony) } end def downbeat_harmonic_intervals_in_middle downbeat_harmonic_intervals[1..-2] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
head_music-0.19.0 | lib/head_music/style/annotations/prefer_imperfect.rb |
head_music-0.18.0 | lib/head_music/style/annotations/prefer_imperfect.rb |