Sha256: 66d039b3ffdcc31d9d6292bf43465ab2bb1331a8fdf67470cd661a12af8eea6c

Contents?: true

Size: 897 Bytes

Versions: 9

Compression:

Stored size: 897 Bytes

Contents

# 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

9 entries across 9 versions & 1 rubygems

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