class Mystic::PitchClassSet

Overview

Represents a pitch class set in Set Theory

To create a PitchClass:

# C, E, G
PitchClass.new([PitchClass.new(0), PitchClass.new(4), PitchClass.new(7)])

# Shorthand
PitchClass.new([0, 4, 7])

# Can create from a chord
Chord.new("C").pitch_class_set

Defined in:

mystic/pitch_class_set.cr

Constructors

Instance Method Summary

Constructor Detail

def self.from_forte_number(s : String) : PitchClassSet #

Returns the pitch class set (in prime form) given the Forte number


[View source]
def self.new(pitch_class_nums : Array(Int32)) #

[View source]
def self.new(pitch_classes : Array(Mystic::PitchClass)) #

[View source]

Instance Method Detail

def +(i : Int32) : PitchClassSet #

Transpose (Tₙ)


[View source]
def -(i : Int32) : PitchClassSet #

[View source]
def <=>(other : self) : Int32 #

The more "compact" pitch class set is considered less than the other

"Compactness" is determined by:

  1. Smallest outer distance
  2. If tie, rightmost largest inner distances
  3. If tie, the pitch class set beginning closest to 0

[View source]
def ==(other : self) : Bool #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


[View source]
def first : PitchClass #

Returns the first pitch class


[View source]
def forte_number : String #

[View source]
def interval_vector : Array(Int32) #

The interval vector (also known as Interval Class Content) shows which interval classes (with quantities) exist between all pairs of notes.

Returns an array of 6 ints, denoting how many of each interval class (ic) exist.

For example: an interval vector of [0, 0, 2, 0, 0, 1] means the following:

  1. 2 instances of interval class 3
  2. 1 instance of interval class 6

[View source]
def invert(axis : PitchClass) : PitchClassSet #

Returns the inversion around the given axis


[View source]
def invert(axis : Int32 = 0) : PitchClassSet #

Returns the inversion around the given axis (defaulting to 0)


[View source]
def last : PitchClass #

Returns the last pitch class


[View source]
def normal_form : PitchClassSet #

Returns the normal form.

The normal form is the most compact form of a pitch class set


[View source]
def pitch_class_values : Array(Int32) #

Returns the pitch classes as an array of ints


[View source]
def pitch_classes : Array(PitchClass) #

[View source]
def prime_form : PitchClassSet #

Returns the prime form.

The prime form is calculated by:

  1. Finding the more compact version of either the normal form or inverted normal form
  2. Transposing it to start from 0

[View source]
def size : Int32 #

Returns the number of pitch classes


[View source]
def sort : PitchClassSet #

Returns the pitch class set with pitch classes in ascending order


[View source]
def t(i : Int32) : PitchClassSet #

Transpose (Tₙ)


[View source]
def ti(i : Int32) : PitchClassSet #

Inversion + Transpose (TₙI or Iₙ)


[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 transpose_to(i : Int32) #

Transpose set to begin with given pitch class value


[View source]