class

Mystic::PitchClassSet

Inherits Reference < Object

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

Constructors

from_forte_number(s : String) : PitchClassSet

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

Source
new(pitch_class_nums : Array(Int32))
Source
new(pitch_classes : Array(Mystic::PitchClass))
Source

Instance methods

+(i : Int32) : PitchClassSet

Transpose (Tₙ)

Source
-(i : Int32) : PitchClassSet
Source
<=>(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
Source
==(other : self) : Bool

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

Source
first

Returns the first pitch class

Source
forte_number
Source
interval_vector

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
Source
invert(axis : PitchClass) : PitchClassSet

Returns the inversion around the given axis

Source
invert(axis : Int32 = 0) : PitchClassSet

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

Source
last

Returns the last pitch class

Source
normal_form

Returns the normal form.

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

Source
pitch_class_values

Returns the pitch classes as an array of ints

Source
pitch_classes
Source
prime_form

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
Source
size

Returns the number of pitch classes

Source
sort

Returns the pitch class set with pitch classes in ascending order

Source
t(i : Int32) : PitchClassSet

Transpose (Tₙ)

Source
ti(i : Int32) : PitchClassSet

Inversion + Transpose (TₙI or Iₙ)

Source
to_s(io : IO) : Nil

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

Transpose set to begin with given pitch class value

Source