Sha256: bee6a4b33f7717e1404459b07ad870f351bd2aecc5c79ed5e3403c6665ac259c
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
module HeadMusic::Style::Annotations end # Ok, so a rule might be that after the first leap (after previous steps) # one should normally move by step in the opposite direction # unless another leap (in either direction) creates a consonant triad. # - Brian class HeadMusic::Style::Annotations::RecoverLargeLeaps < HeadMusic::Style::Annotation def message "Recover leaps by step in the opposite direction." end def marks melodic_intervals[1..-1].to_a.map.with_index do |interval, i| previous_interval = melodic_intervals[i] if unrecovered_leap?(previous_interval, interval) HeadMusic::Style::Mark.for_all((previous_interval.notes + interval.notes).uniq) end end.reject(&:nil?) end private def unrecovered_leap?(first_interval, second_interval) first_interval.leap? && !spelling_consonant_triad?(first_interval, second_interval) && ( !direction_changed?(first_interval, second_interval) || !second_interval.step? ) end def spelling_consonant_triad?(first_interval, second_interval) return false if first_interval.step? || second_interval.step? pitches = (first_interval.pitches + second_interval.pitches).uniq return false if pitches.length < 3 HeadMusic::Chord.new(pitches).consonant_triad? end def direction_changed?(first_interval, second_interval) first_interval.ascending? && second_interval.descending? || first_interval.descending? && second_interval.ascending? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
head_music-0.11.1 | lib/head_music/style/annotations/recover_large_leaps.rb |