Sha256: d51235368a54fb9639b1b0f0f2794926d112a6c1cbafc95665dbed35e67fd8d8

Contents?: true

Size: 817 Bytes

Versions: 18

Compression:

Stored size: 817 Bytes

Contents

# frozen_string_literal: true

# Module for style guidelines.
module HeadMusic::Style::Guidelines; end

# A counterpoint guideline
class HeadMusic::Style::Guidelines::MostlyConjunct < HeadMusic::Style::Annotation
  MESSAGE = 'Use mostly conjunct motion.'

  MINIMUM_CONJUNCT_PORTION = HeadMusic::GOLDEN_RATIO_INVERSE**2
  # ~38%
  # Fux is 5/13 for lydian cantus firmus

  def marks
    marks_for_skips_and_leaps if conjunct_ratio < MINIMUM_CONJUNCT_PORTION
  end

  private

  def marks_for_skips_and_leaps
    melodic_intervals.
      reject(&:step?).
      map { |interval| HeadMusic::Style::Mark.for_all(interval.notes, fitness: HeadMusic::SMALL_PENALTY_FACTOR) }
  end

  def conjunct_ratio
    return 1 if melodic_intervals.empty?

    melodic_intervals.count(&:step?).to_f / melodic_intervals.length
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
head_music-0.27.0 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.26.3 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.26.2 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.26.1 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.26.0 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.25.0 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.24.5 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.24.4 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.24.3 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.24.2 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.24.1 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.24.0 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.23.4 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.23.3 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.23.2 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.23.1 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.23.0 lib/head_music/style/guidelines/mostly_conjunct.rb
head_music-0.22.0 lib/head_music/style/guidelines/mostly_conjunct.rb