Sha256: 373daf4af47e7495bd17ebe14d9f42e5e7e131d76ec4ecd7afa2860156642317
Contents?: true
Size: 1.39 KB
Versions: 17
Compression:
Stored size: 1.39 KB
Contents
# frozen_string_literal: true # A PitchClassSet represents a pitch-class set or pitch collection. # See also: PitchSet, PitchClass class HeadMusic::PitchClassSet attr_reader :pitch_classes delegate :empty?, to: :pitch_classes alias empty_set? empty? def initialize(identifiers) @pitch_classes = identifiers.map { |identifier| HeadMusic::PitchClass.get(identifier) }.uniq.sort end def inspect pitch_classes.map(&:to_s).join(' ') end def to_s pitch_classes.map(&:to_s).join(' ') end def ==(other) pitch_classes == other.pitch_classes end def equivalent?(other) pitch_classes.sort == other.pitch_classes.sort end def size @size ||= pitch_classes.length end def monochord? pitch_classes.length == 1 end alias monad? monochord? def dichord? pitch_classes.length == 2 end alias dyad? dichord? def trichord? pitch_classes.length == 3 end def tetrachord? pitch_classes.length == 4 end def pentachord? pitch_classes.length == 5 end def hexachord? pitch_classes.length == 6 end def heptachord? pitch_classes.length == 7 end def octachord? pitch_classes.length == 8 end def nonachord? pitch_classes.length == 9 end def decachord? pitch_classes.length == 10 end def undecachord? pitch_classes.length == 11 end def dodecachord? pitch_classes.length == 12 end end
Version data entries
17 entries across 17 versions & 1 rubygems