Class: HeadMusic::Analysis::PitchClassSet

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_classesObject (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

Returns:

  • (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?

Returns:

  • (Boolean)


38
39
40
# File 'lib/head_music/analysis/pitch_class_set.rb', line 38

def dichord?
  pitch_classes.length == 2
end

#dodecachord?Boolean

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


59
60
61
# File 'lib/head_music/analysis/pitch_class_set.rb', line 59

def heptachord?
  pitch_classes.length == 7
end

#hexachord?Boolean

Returns:

  • (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?

Returns:

  • (Boolean)


33
34
35
# File 'lib/head_music/analysis/pitch_class_set.rb', line 33

def monochord?
  pitch_classes.length == 1
end

#nonachord?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/head_music/analysis/pitch_class_set.rb', line 67

def nonachord?
  pitch_classes.length == 9
end

#octachord?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/head_music/analysis/pitch_class_set.rb', line 63

def octachord?
  pitch_classes.length == 8
end

#pentachord?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/head_music/analysis/pitch_class_set.rb', line 51

def pentachord?
  pitch_classes.length == 5
end

#sizeObject



29
30
31
# File 'lib/head_music/analysis/pitch_class_set.rb', line 29

def size
  @size ||= pitch_classes.length
end

#tetrachord?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/head_music/analysis/pitch_class_set.rb', line 47

def tetrachord?
  pitch_classes.length == 4
end

#to_sObject 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

Returns:

  • (Boolean)


43
44
45
# File 'lib/head_music/analysis/pitch_class_set.rb', line 43

def trichord?
  pitch_classes.length == 3
end

#undecachord?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/head_music/analysis/pitch_class_set.rb', line 75

def undecachord?
  pitch_classes.length == 11
end