PCSet
public struct PCSet: Equatable, ExpressibleByArrayLiteral, Collection, SetAlgebra
The PCSet type deals with collections of pitch-classes. It abstracts an Array of pitch-classes than a set type, in order to allow for duplicates, explicit ordering, etc.
-
Underlying PitchClass array.
Declaration
Swift
public var pitchClasses = [Element]()
-
Declaration
Swift
public static func ==(lhs: PCSet, rhs: PCSet) -> Bool
-
Initialize an empty pitch-class set.
Declaration
Swift
public init()
-
Initialize from a Set of PitchClasses.
Declaration
Swift
public init(_ set: Set<Element>)
-
Initialize from an array of MIDI note numbers.
Declaration
Swift
public init(with midiNotes: [UInt8])
-
Initialize as an array literal of PitchClasses. For example:
let set: PCSet = [0, 1, 4, 5, 8, 11]
Declaration
Swift
public init(arrayLiteral elements: Element...)
-
Initialize from an Array of PitchClasses.
Declaration
Swift
public init(_ pcSetLiteral: [Element])
-
Initialize from an ArraySlice of PitchClasses.
Declaration
Swift
public init(_ pcSetSlice: ArraySlice<Element>)
-
Initialize from a Forte code string. E.g. PCSet(
4-Z15
) returns [0, 1, 4, 6]Declaration
Swift
public init?(_ forteCodeName: String)
-
Returns the number of unique elements in the current PCSet instance.
Declaration
Swift
public var cardinality: Int
-
Declaration
Swift
public func index(after i: Int) -> Int
-
Declaration
Swift
public var startIndex: Int
-
Declaration
Swift
public var endIndex: Int
-
Declaration
Swift
public func union(_ other: PCSet) -> PCSet
-
Declaration
Swift
public func intersection(_ other: PCSet) -> PCSet
-
Declaration
Swift
public func symmetricDifference(_ other: PCSet) -> PCSet
-
Declaration
Swift
public mutating func formUnion(_ other: PCSet)
-
Declaration
Swift
public mutating func formIntersection(_ other: PCSet)
-
Declaration
Swift
public mutating func formSymmetricDifference(_ other: PCSet)
-
Declaration
Swift
public mutating func insert(_ newMember: Element) -> (inserted: Bool, memberAfterInsert: Element)
-
Declaration
Swift
public mutating func remove(_ member: Element) -> Int?
-
Declaration
Swift
public var isEmpty: Bool
-
Declaration
Swift
public func contains(_ member: Element) -> Bool
-
Declaration
Swift
public mutating func update(with newMember: Element) -> Element?
-
Returns an ordered replica of the current PCSet with duplicates removed.
Declaration
Swift
public func thinned() -> PCSet
-
Returns the Forte code of the current PCSet if one can be found that matches.
Declaration
Swift
public var forteCode: String?
-
Returns the normal form of the current PCSet.
Declaration
Swift
public func normalForm() -> PCSet
-
Returns the prime form of the current PCSet.
Declaration
Swift
public func primeForm() -> PCSet
-
Returns an inversion of the current PCSet.
Declaration
Swift
public func inverted() -> PCSet
-
Inverts the current PCSet.
Declaration
Swift
public mutating func invert()
-
Returns a transposition of the current PCSet.
Declaration
Swift
public func transposed(_ t: Int) -> PCSet
-
Transposes the current PCSet.
Declaration
Swift
public mutating func transpose(_ t: Int)
-
Returns a transposition and/or inversion of the current PCSet.
Declaration
Swift
public func transformed(t: Int, i: Bool) -> PCSet
-
Performs a compound transformation (inversion and transposition) on the current PCSet.
Declaration
Swift
public mutating func transform(t: Int, i: Bool)