Sha256: 52a51c6bf4dad8c68b1a56d18e9141905d77b36fa5f63eb6aa65c947901fc768

Contents?: true

Size: 984 Bytes

Versions: 9

Compression:

Stored size: 984 Bytes

Contents

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

# A counterpoint guideline
class HeadMusic::Style::Guidelines::PrepareOctaveLeaps < HeadMusic::Style::Annotation
  MESSAGE = "Enter and exit an octave leap from within."

  def marks
    (external_entries + external_exits + octave_ending).map do |trouble_spot|
      HeadMusic::Style::Mark.for_all(trouble_spot)
    end
  end

  private

  def external_entries
    melodic_intervals.each_cons(2).map do |pair|
      first, second = *pair
      pair.map(&:notes).uniq if second.octave? && !second.spans?(first.first_note.pitch)
    end.compact
  end

  def external_exits
    melodic_intervals.each_cons(2).map do |pair|
      first, second = *pair
      pair.map(&:notes).uniq if first.octave? && !first.spans?(second.second_note.pitch)
    end.compact
  end

  def octave_ending
    octave_ending? ? [melodic_intervals.last.notes] : []
  end

  def octave_ending?
    melodic_intervals.last&.octave?
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
head_music-7.0.5 lib/head_music/style/guidelines/prepare_octave_leaps.rb
head_music-7.0.4 lib/head_music/style/guidelines/prepare_octave_leaps.rb
head_music-7.0.3 lib/head_music/style/guidelines/prepare_octave_leaps.rb
head_music-7.0.2 lib/head_music/style/guidelines/prepare_octave_leaps.rb
head_music-7.0.1 lib/head_music/style/guidelines/prepare_octave_leaps.rb
head_music-7.0.0 lib/head_music/style/guidelines/prepare_octave_leaps.rb
head_music-6.0.1 lib/head_music/style/guidelines/prepare_octave_leaps.rb
head_music-6.0.0 lib/head_music/style/guidelines/prepare_octave_leaps.rb
head_music-5.0.0 lib/head_music/style/guidelines/prepare_octave_leaps.rb