Class: HeadMusic::PitchClassSet
- Inherits:
-
Object
- Object
- HeadMusic::PitchClassSet
- Defined in:
- lib/head_music/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.
- #inspect ⇒ Object
- #monochord? ⇒ Boolean (also: #monad?)
- #nonachord? ⇒ Boolean
- #octachord? ⇒ Boolean
- #pentachord? ⇒ Boolean
- #size ⇒ Object
- #tetrachord? ⇒ Boolean
- #to_s ⇒ Object
- #trichord? ⇒ Boolean
- #undecachord? ⇒ Boolean
Constructor Details
#initialize(identifiers) ⇒ PitchClassSet
Returns a new instance of PitchClassSet.
11 12 13 |
# File 'lib/head_music/pitch_class_set.rb', line 11 def initialize(identifiers) @pitch_classes = identifiers.map { |identifier| HeadMusic::PitchClass.get(identifier) }.uniq.sort end |
Instance Attribute Details
#pitch_classes ⇒ Object (readonly)
Returns the value of attribute pitch_classes.
6 7 8 |
# File 'lib/head_music/pitch_class_set.rb', line 6 def pitch_classes @pitch_classes end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 |
# File 'lib/head_music/pitch_class_set.rb', line 23 def ==(other) pitch_classes == other.pitch_classes end |
#decachord? ⇒ Boolean
73 74 75 |
# File 'lib/head_music/pitch_class_set.rb', line 73 def decachord? pitch_classes.length == 10 end |
#dichord? ⇒ Boolean Also known as: dyad?
40 41 42 |
# File 'lib/head_music/pitch_class_set.rb', line 40 def dichord? pitch_classes.length == 2 end |
#dodecachord? ⇒ Boolean
81 82 83 |
# File 'lib/head_music/pitch_class_set.rb', line 81 def dodecachord? pitch_classes.length == 12 end |
#equivalent?(other) ⇒ Boolean
27 28 29 |
# File 'lib/head_music/pitch_class_set.rb', line 27 def equivalent?(other) pitch_classes.sort == other.pitch_classes.sort end |
#heptachord? ⇒ Boolean
61 62 63 |
# File 'lib/head_music/pitch_class_set.rb', line 61 def heptachord? pitch_classes.length == 7 end |
#hexachord? ⇒ Boolean
57 58 59 |
# File 'lib/head_music/pitch_class_set.rb', line 57 def hexachord? pitch_classes.length == 6 end |
#inspect ⇒ Object
15 16 17 |
# File 'lib/head_music/pitch_class_set.rb', line 15 def inspect pitch_classes.map(&:to_s).join(" ") end |
#monochord? ⇒ Boolean Also known as: monad?
35 36 37 |
# File 'lib/head_music/pitch_class_set.rb', line 35 def monochord? pitch_classes.length == 1 end |
#nonachord? ⇒ Boolean
69 70 71 |
# File 'lib/head_music/pitch_class_set.rb', line 69 def nonachord? pitch_classes.length == 9 end |
#octachord? ⇒ Boolean
65 66 67 |
# File 'lib/head_music/pitch_class_set.rb', line 65 def octachord? pitch_classes.length == 8 end |
#pentachord? ⇒ Boolean
53 54 55 |
# File 'lib/head_music/pitch_class_set.rb', line 53 def pentachord? pitch_classes.length == 5 end |
#size ⇒ Object
31 32 33 |
# File 'lib/head_music/pitch_class_set.rb', line 31 def size @size ||= pitch_classes.length end |
#tetrachord? ⇒ Boolean
49 50 51 |
# File 'lib/head_music/pitch_class_set.rb', line 49 def tetrachord? pitch_classes.length == 4 end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/head_music/pitch_class_set.rb', line 19 def to_s pitch_classes.map(&:to_s).join(" ") end |
#trichord? ⇒ Boolean
45 46 47 |
# File 'lib/head_music/pitch_class_set.rb', line 45 def trichord? pitch_classes.length == 3 end |
#undecachord? ⇒ Boolean
77 78 79 |
# File 'lib/head_music/pitch_class_set.rb', line 77 def undecachord? pitch_classes.length == 11 end |