class Coltrane::Theory::CircleOfFifths
Constants
- LETTER_SEQUENCE
Attributes
notes[R]
Public Class Methods
new(start_note = Note['C'], size = Float::INFINITY)
click to toggle source
# File lib/coltrane/theory/circle_of_fifths.rb, line 10 def initialize(start_note = Note['C'], size = Float::INFINITY) index = letters.index(start_note.name[0]) @notes = fifths(note: start_note - Interval.perfect_fifth, size: size, index: (index - 1) % LETTER_SEQUENCE.size) end
Private Instance Methods
fifths(note:, index: nil, notes: [], size:)
click to toggle source
# File lib/coltrane/theory/circle_of_fifths.rb, line 19 def fifths(note:, index: nil, notes: [], size:) return notes if size == 0 return notes if notes.any? && note.as(letters(index)).name == notes.first.name fifths note: note + Interval.perfect_fifth, notes: notes + [note.as(letters(index))], index: index + 1, size: size - 1 end
letters(i = nil)
click to toggle source
# File lib/coltrane/theory/circle_of_fifths.rb, line 28 def letters(i = nil) i.nil? ? LETTER_SEQUENCE : LETTER_SEQUENCE[i % LETTER_SEQUENCE.size] end