class Mystic::Scale

Overview

Represents a scale

A scale consists of a tonic note, type, and array of Intervals.

To create a scale:

# C major scale
Scale.new(Note.new("C"), "major")

# Can create a custom scale by supplying the intervals
Scale.new(Note.new("C"), "my custom scale", [Interval.new("M2"), Interval.new("M3")])

Defined in:

mystic/scale.cr

Constant Summary

SCALE_ALIASES = {ionian: "major", aeolian: "minor", "natural minor": "minor"}
SCALE_INTERVALS = {major: [WS, WS, HS, WS, WS, WS], minor: [WS, HS, WS, WS, HS, WS], "melodic minor": [WS, HS, WS, WS, WS, WS], dorian: [WS, HS, WS, WS, WS, HS, WS], phrygian: [HS, WS, WS, WS, HS, WS, WS], lydian: [WS, WS, WS, HS, WS, WS, HS], mixolydian: [WS, WS, HS, WS, WS, HS, WS], locrian: [HS, WS, WS, HS, WS, WS, WS]}

Constructors

Instance Method Summary

Constructor Detail

def self.new(tonic : Mystic::Note, type : String, intervals : Array(Mystic::Interval)) #

[View source]
def self.new(tonic_type : String, type : String) #

[View source]
def self.new(tonic : Mystic::Note, type : String) #

[View source]

Instance Method Detail

def +(interval : Interval) : Scale #

Returns a new scale transposed by the given interval


[View source]
def intervals : Array(Interval) #

[View source]
def name(include_octave = false) : String #

Returns the name of the scale

For example: "C major"

If include_octave is true, will include the octave as part of the tonic note (e.g. "C4 major")


[View source]
def note_names : Array(String) #

Returns the note names


[View source]
def notes : Array(Note) #

Returns the notes of the scale


[View source]
def to_s(io : IO) : Nil #
Description copied from class Reference

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>

[View source]
def tonic : Note #

[View source]
def type : String #

[View source]