Sha256: 3265b5b68a19dc006046b9f9f1b5da35060ead721bae3b22ae77aeddbb9f6846

Contents?: true

Size: 796 Bytes

Versions: 3

Compression:

Stored size: 796 Bytes

Contents

module HeadMusic::Style::Annotations
end

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

  MESSAGE = "Use only m2, M2, m3, M3, P4, P5, m6 (ascending), P8."

  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

3 entries across 3 versions & 1 rubygems

Version Path
head_music-0.14.2 lib/head_music/style/annotations/singable_intervals.rb
head_music-0.14.1 lib/head_music/style/annotations/singable_intervals.rb
head_music-0.13.2 lib/head_music/style/annotations/singable_intervals.rb