class Diapason::Scale

Attributes

notes[RW]

Public Class Methods

build(notes, intervals, tonic) click to toggle source
# File lib/diapason/scale.rb, line 8
def self.build(notes, intervals, tonic)
  scale_notes = [tonic]

  intervals.each do |interval|
    index = notes.index(scale_notes.last) + interval

    if index >= notes.size
      index = notes.size - index
    end

    scale_notes << notes[index]
  end

  new(scale_notes)
end
new(notes) click to toggle source
# File lib/diapason/scale.rb, line 4
def initialize(notes)
  @notes = notes
end