Sha256: 8794b197ea6a1c832ecafa01841ddc1d308d0c71ffff3d727a98126bfb7c8ee0

Contents?: true

Size: 839 Bytes

Versions: 9

Compression:

Stored size: 839 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::StepOutOfUnison < HeadMusic::Style::Annotation
  MESSAGE = "Exit a unison by step."

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

  private

  def skips_following_unisons
    melodic_intervals_following_unisons.select(&:skip?)
  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(voice, note1, note2) if note1 && note2
      end.compact
  end

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

Version data entries

9 entries across 9 versions & 1 rubygems

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