Sha256: 0c1b9b6a55ac07ecc80823e633900777734f0af2c5c3933a26762e89bf5bf991

Contents?: true

Size: 677 Bytes

Versions: 9

Compression:

Stored size: 677 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::MostlyConjunct < HeadMusic::Style::Annotation
  def message
    "Use mostly conjunct motion."
  end

  def marks
    marks_for_skips_and_leaps if conjunct_ratio <= 0.5
  end

  private

  def marks_for_skips_and_leaps
    melodic_intervals.map.with_index do |interval, i|
      HeadMusic::Style::Mark.for_all(notes[i..i+1], fitness: HeadMusic::SMALL_PENALTY_FACTOR) unless interval.step?
    end.reject(&:nil?)
  end

  def conjunct_ratio
    return 1 if melodic_intervals.empty?
    steps = melodic_intervals.count { |interval| interval.step? }
    steps.to_f / melodic_intervals.length
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
head_music-0.11.9 lib/head_music/style/annotations/mostly_conjunct.rb
head_music-0.11.8 lib/head_music/style/annotations/mostly_conjunct.rb
head_music-0.11.7 lib/head_music/style/annotations/mostly_conjunct.rb
head_music-0.11.6 lib/head_music/style/annotations/mostly_conjunct.rb
head_music-0.11.5 lib/head_music/style/annotations/mostly_conjunct.rb
head_music-0.11.4 lib/head_music/style/annotations/mostly_conjunct.rb
head_music-0.11.3 lib/head_music/style/annotations/mostly_conjunct.rb
head_music-0.11.2 lib/head_music/style/annotations/mostly_conjunct.rb
head_music-0.11.1 lib/head_music/style/annotations/mostly_conjunct.rb