Sha256: b733dd8c45abf9fe0f50e39ae21f6c8a5ffa470fdc96f6aa585c864c96d1e50f

Contents?: true

Size: 972 Bytes

Versions: 1

Compression:

Stored size: 972 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
    unisons.map do |unison|
      note1 = voice.note_at(unison.position)
      note2 = voice.note_following(unison.position)
      MelodicInterval.new(voice, note1, note2) if note2
    end.reject(&:nil?)
  end

  def unisons
    harmonic_intervals.select { |interval| interval.perfect_consonance? && interval.unison? }
  end

  def harmonic_intervals
    positions.map { |position| HarmonicInterval.new(cantus_firmus, voice, position) }
  end

  def positions
    voices.map(&:notes).flatten.map(&:position).sort.uniq(&:to_s)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
head_music-0.13.2 lib/head_music/style/annotations/step_out_of_unison.rb