class Mystic::PitchClassSet
- Mystic::PitchClassSet
- Reference
- Object
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.crConstructors
-
.from_forte_number(s : String) : PitchClassSet
Returns the pitch class set (in prime form) given the Forte number
- .new(pitch_class_nums : Array(Int32))
- .new(pitch_classes : Array(Mystic::PitchClass))
Instance Method Summary
-
#+(i : Int32) : PitchClassSet
Transpose (Tₙ)
- #-(i : Int32) : PitchClassSet
-
#<=>(other : self) : Int32
The more "compact" pitch class set is considered less than the other
-
#==(other : self) : Bool
Returns
true
if this reference is the same as other. -
#first : PitchClass
Returns the first pitch class
- #forte_number : String
-
#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.
-
#invert(axis : PitchClass) : PitchClassSet
Returns the inversion around the given axis
-
#invert(axis : Int32 = 0) : PitchClassSet
Returns the inversion around the given axis (defaulting to 0)
-
#last : PitchClass
Returns the last pitch class
-
#normal_form : PitchClassSet
Returns the normal form.
-
#pitch_class_values : Array(Int32)
Returns the pitch classes as an array of ints
- #pitch_classes : Array(PitchClass)
-
#prime_form : PitchClassSet
Returns the prime form.
-
#size : Int32
Returns the number of pitch classes
-
#sort : PitchClassSet
Returns the pitch class set with pitch classes in ascending order
-
#t(i : Int32) : PitchClassSet
Transpose (Tₙ)
-
#ti(i : Int32) : PitchClassSet
Inversion + Transpose (TₙI or Iₙ)
-
#to_s(io : IO) : Nil
Appends a short String representation of this object which includes its class name and its object address.
-
#transpose_to(i : Int32)
Transpose set to begin with given pitch class value
Constructor Detail
Returns the pitch class set (in prime form) given the Forte number
Instance Method Detail
The more "compact" pitch class set is considered less than the other
"Compactness" is determined by:
- Smallest outer distance
- If tie, rightmost largest inner distances
- If tie, the pitch class set beginning closest to 0
Returns true
if this reference is the same as other. Invokes same?
.
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:
- 2 instances of interval class 3
- 1 instance of interval class 6
Returns the inversion around the given axis
Returns the inversion around the given axis (defaulting to 0)
Returns the normal form.
The normal form is the most compact form of a pitch class set
Returns the prime form.
The prime form is calculated by:
- Finding the more compact version of either the normal form or inverted normal form
- Transposing it to start from 0
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>