Class: Coltrane::Theory::Voicing
- Inherits:
-
Object
- Object
- Coltrane::Theory::Voicing
- Defined in:
- lib/coltrane/theory/voicing.rb
Overview
This class describes an actual implementation of a Chord, being aware of exact octaves of each pitch and even repeating pitches across octaves.
Instance Attribute Summary collapse
-
#pitches ⇒ Object
readonly
Returns the value of attribute pitches.
Class Method Summary collapse
Instance Method Summary collapse
- #chord ⇒ Object
- #frequencies ⇒ Object
-
#initialize(*pitch_strings, pitches: nil) ⇒ Voicing
constructor
A new instance of Voicing.
- #pitch_classes ⇒ Object (also: #notes)
Constructor Details
#initialize(*pitch_strings, pitches: nil) ⇒ Voicing
Returns a new instance of Voicing.
10 11 12 13 14 15 16 17 18 |
# File 'lib/coltrane/theory/voicing.rb', line 10 def initialize(*pitch_strings, pitches: nil) @pitches = if pitch_strings.any? pitch_strings.map { |s| Pitch[s] } elsif pitches pitches else raise WrongArgumentsError end end |
Instance Attribute Details
#pitches ⇒ Object (readonly)
Returns the value of attribute pitches.
8 9 10 |
# File 'lib/coltrane/theory/voicing.rb', line 8 def pitches @pitches end |
Class Method Details
.[](*args) ⇒ Object
20 21 22 |
# File 'lib/coltrane/theory/voicing.rb', line 20 def self.[](*args) new(*args) end |
Instance Method Details
#chord ⇒ Object
30 31 32 33 34 |
# File 'lib/coltrane/theory/voicing.rb', line 30 def chord @chord ||= Chord.new(notes: notes) rescue ChordNotFoundError return false end |
#frequencies ⇒ Object
36 37 38 |
# File 'lib/coltrane/theory/voicing.rb', line 36 def frequencies pitches.map(&:frequency) end |
#pitch_classes ⇒ Object Also known as: notes
24 25 26 |
# File 'lib/coltrane/theory/voicing.rb', line 24 def pitch_classes NoteSet[*pitches.map(&:pitch_class).uniq] end |