Sha256: 2b74489d65beeff9b547dcedd400e482451a42dcb2c2c7d1df1388d26cd8f052
Contents?: true
Size: 778 Bytes
Versions: 22
Compression:
Stored size: 778 Bytes
Contents
# frozen_string_literal: true module Coltrane module Theory class DiatonicScale < Scale def initialize(tone, major: true) @major = major tone = Note[tone] notes = CircleOfFifths.new(tone - (major? ? 0 : 9), 7).notes.sort super notes: notes.rotate(notes.index(tone)) end def name major? ? 'Major' : 'Natural Minor' end def relative_minor minor? ? self : self.class.new(@tone + 9, major: false) end def relative_major major? ? self : self.class.new(@tone - 9, major: true) end def relative major? ? relative_minor : relative_major end def major? !!@major end def minor? !@major end end end end
Version data entries
22 entries across 22 versions & 1 rubygems