Class: HeadMusic::Analysis::PitchClassSet
- Inherits:
-
Object
- Object
- HeadMusic::Analysis::PitchClassSet
- Defined in:
- lib/head_music/analysis/pitch_class_set.rb
Overview
A PitchClassSet represents a pitch-class set or pitch collection. See also: PitchSet, PitchClass
Instance Attribute Summary collapse
-
#pitch_classes ⇒ Object
readonly
Returns the value of attribute pitch_classes.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #decachord? ⇒ Boolean
- #dichord? ⇒ Boolean (also: #dyad?)
- #dodecachord? ⇒ Boolean
- #equivalent?(other) ⇒ Boolean
- #heptachord? ⇒ Boolean
- #hexachord? ⇒ Boolean
-
#initialize(identifiers) ⇒ PitchClassSet
constructor
A new instance of PitchClassSet.
- #monochord? ⇒ Boolean (also: #monad?)
- #nonachord? ⇒ Boolean
- #octachord? ⇒ Boolean
- #pentachord? ⇒ Boolean
- #size ⇒ Object
- #tetrachord? ⇒ Boolean
- #to_s ⇒ Object (also: #inspect)
- #trichord? ⇒ Boolean
- #undecachord? ⇒ Boolean
Constructor Details
#initialize(identifiers) ⇒ PitchClassSet
Returns a new instance of PitchClassSet.
12 13 14 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 12 def initialize(identifiers) @pitch_classes = identifiers.map { |identifier| HeadMusic::Rudiment::PitchClass.get(identifier) }.uniq.sort end |
Instance Attribute Details
#pitch_classes ⇒ Object (readonly)
Returns the value of attribute pitch_classes.
7 8 9 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 7 def pitch_classes @pitch_classes end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 21 def ==(other) pitch_classes == other.pitch_classes end |
#decachord? ⇒ Boolean
71 72 73 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 71 def decachord? pitch_classes.length == 10 end |
#dichord? ⇒ Boolean Also known as: dyad?
38 39 40 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 38 def dichord? pitch_classes.length == 2 end |
#dodecachord? ⇒ Boolean
79 80 81 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 79 def dodecachord? pitch_classes.length == 12 end |
#equivalent?(other) ⇒ Boolean
25 26 27 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 25 def equivalent?(other) pitch_classes.sort == other.pitch_classes.sort end |
#heptachord? ⇒ Boolean
59 60 61 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 59 def heptachord? pitch_classes.length == 7 end |
#hexachord? ⇒ Boolean
55 56 57 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 55 def hexachord? pitch_classes.length == 6 end |
#monochord? ⇒ Boolean Also known as: monad?
33 34 35 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 33 def monochord? pitch_classes.length == 1 end |
#nonachord? ⇒ Boolean
67 68 69 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 67 def nonachord? pitch_classes.length == 9 end |
#octachord? ⇒ Boolean
63 64 65 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 63 def octachord? pitch_classes.length == 8 end |
#pentachord? ⇒ Boolean
51 52 53 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 51 def pentachord? pitch_classes.length == 5 end |
#size ⇒ Object
29 30 31 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 29 def size @size ||= pitch_classes.length end |
#tetrachord? ⇒ Boolean
47 48 49 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 47 def tetrachord? pitch_classes.length == 4 end |
#to_s ⇒ Object Also known as: inspect
16 17 18 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 16 def to_s pitch_classes.map(&:to_i).inspect end |
#trichord? ⇒ Boolean
43 44 45 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 43 def trichord? pitch_classes.length == 3 end |
#undecachord? ⇒ Boolean
75 76 77 |
# File 'lib/head_music/analysis/pitch_class_set.rb', line 75 def undecachord? pitch_classes.length == 11 end |