class Coltrane::Theory::Voicing
This class describes an actual implementation of a Chord
, being aware of exact octaves of each pitch and even repeating pitches across octaves.
Attributes
pitches[R]
Public Class Methods
[](*args)
click to toggle source
# File lib/coltrane/theory/voicing.rb, line 23 def self.[](*args) new(*args) end
new(*pitch_strings, pitches: nil)
click to toggle source
# File lib/coltrane/theory/voicing.rb, line 11 def initialize(*pitch_strings, pitches: nil) @pitches = begin if pitch_strings.any? pitch_strings.map { |s| Pitch[s] } elsif pitches pitches else raise WrongArgumentsError end end.sort end
Public Instance Methods
chord()
click to toggle source
# File lib/coltrane/theory/voicing.rb, line 33 def chord @chord ||= Chord.new(notes: notes) rescue ChordNotFoundError return false end
discontinuity()
click to toggle source
# File lib/coltrane/theory/voicing.rb, line 43 def discontinuity frequencies.each_with_index.reduce(0) do |max_dist, (freq, index)| next 0 if index.zero? [max_dist, freq.to_f - frequencies[index - 1].to_f].max end end
frequencies()
click to toggle source
# File lib/coltrane/theory/voicing.rb, line 39 def frequencies @frequencies ||= pitches.map(&:frequency) end
pitch_classes()
click to toggle source
# File lib/coltrane/theory/voicing.rb, line 27 def pitch_classes NoteSet[*pitches.map(&:pitch_class).uniq] end
Also aliased as: notes
Private Instance Methods
ideal_frequency_distance()
click to toggle source
# File lib/coltrane/theory/voicing.rb, line 52 def ideal_frequency_distance (Pitch['D3'].frequency - Pitch['A2'].frequency).to_f end