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

Version Path
coltrane-4.1.2 lib/coltrane/theory/diatonic_scale.rb
coltrane-4.1.1 lib/coltrane/theory/diatonic_scale.rb
coltrane-4.1.0 lib/coltrane/theory/diatonic_scale.rb
coltrane-4.0.6 lib/coltrane/theory/diatonic_scale.rb
coltrane-4.0.5 lib/coltrane/theory/diatonic_scale.rb
coltrane-4.0.4 lib/coltrane/theory/diatonic_scale.rb
coltrane-4.0.3 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.4.2 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.4.1 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.4.0 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.3.3 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.3.2 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.3.1 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.3.0 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.2.0 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.1.3 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.1.2 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.1.1 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.1.0 lib/coltrane/theory/diatonic_scale.rb
coltrane-3.0.0 lib/coltrane/theory/diatonic_scale.rb