Sha256: 90604c7fcbfcacc38a5077d852aa2228017668ccf4b12deaaf25f4c4899ac02b

Contents?: true

Size: 826 Bytes

Versions: 7

Compression:

Stored size: 826 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::SingableIntervals < HeadMusic::Style::Annotation
  PERMITTED_ASCENDING = %w[PU m2 M2 m3 M3 P4 P5 m6 P8]
  PERMITTED_DESCENDING = %w[PU m2 M2 m3 M3 P4 P5 P8]

  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

7 entries across 7 versions & 1 rubygems

Version Path
head_music-0.17.0 lib/head_music/style/annotations/singable_intervals.rb
head_music-0.16.2 lib/head_music/style/annotations/singable_intervals.rb
head_music-0.16.0 lib/head_music/style/annotations/singable_intervals.rb
head_music-0.14.8 lib/head_music/style/annotations/singable_intervals.rb
head_music-0.14.7 lib/head_music/style/annotations/singable_intervals.rb
head_music-0.14.5 lib/head_music/style/annotations/singable_intervals.rb
head_music-0.14.4 lib/head_music/style/annotations/singable_intervals.rb