Sha256: 6ca46f8c1449f3973f22cfb0ef814e9dd09c56badeccecb59b3d6dc035ed4c46

Contents?: true

Size: 928 Bytes

Versions: 18

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::StepOutOfUnison < HeadMusic::Style::Annotation
  MESSAGE = 'Exit a unison by step.'

  def marks
    leaps_following_unisons.map do |skip|
      HeadMusic::Style::Mark.for_all(skip.notes)
    end.flatten
  end

  private

  def leaps_following_unisons
    melodic_intervals_following_unisons.select(&:leap?)
  end

  def melodic_intervals_following_unisons
    @melodic_intervals_following_unisons ||=
      perfect_unisons.map do |unison|
        note1 = voice.note_at(unison.position)
        note2 = voice.note_following(unison.position)
        HeadMusic::MelodicInterval.new(note1, note2) if note1 && note2
      end.compact
  end

  def perfect_unisons
    @perfect_unisons ||= harmonic_intervals.select(&:perfect_consonance?).select(&:unison?)
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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