Sha256: 4ca960315fc672aa8fe8e918dd2c1f65ee0dae44b81718d0e2dfaed0a50ef7de

Contents?: true

Size: 928 Bytes

Versions: 9

Compression:

Stored size: 928 Bytes

Contents

# frozen_string_literal: true

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

# A counterpoint guideline
class HeadMusic::Style::Guidelines::SingableIntervals < HeadMusic::Style::Annotation
  PERMITTED_ASCENDING = %w[PU m2 M2 m3 M3 P4 P5 m6 P8].freeze
  PERMITTED_DESCENDING = %w[PU m2 M2 m3 M3 P4 P5 P8].freeze

  MESSAGE = "Use only PU, m2, M2, m3, M3, P4, P5, m6 (ascending), P8 in the melodic line."

  def marks
    melodic_intervals.reject { |interval| permitted?(interval) }.map do |unpermitted_interval|
      HeadMusic::Style::Mark.for_all([unpermitted_interval.first_note, unpermitted_interval.second_note])
    end
  end

  private

  def permitted?(melodic_interval)
    whitelist_for_interval(melodic_interval).include?(melodic_interval.shorthand)
  end

  def whitelist_for_interval(melodic_interval)
    melodic_interval.ascending? ? PERMITTED_ASCENDING : PERMITTED_DESCENDING
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
head_music-4.0.1 lib/head_music/style/guidelines/singable_intervals.rb
head_music-4.0.0 lib/head_music/style/guidelines/singable_intervals.rb
head_music-3.0.1 lib/head_music/style/guidelines/singable_intervals.rb
head_music-3.0.0 lib/head_music/style/guidelines/singable_intervals.rb
head_music-2.0.1 lib/head_music/style/guidelines/singable_intervals.rb
head_music-2.0.0 lib/head_music/style/guidelines/singable_intervals.rb
head_music-1.0.0 lib/head_music/style/guidelines/singable_intervals.rb
head_music-0.29.0 lib/head_music/style/guidelines/singable_intervals.rb
head_music-0.28.0 lib/head_music/style/guidelines/singable_intervals.rb