Class: Zgomot::Comp::Chord::Progression
- Defined in:
- lib/zgomot/comp/chord.rb
Instance Attribute Summary collapse
-
#chord ⇒ Object
readonly
Returns the value of attribute chord.
Instance Method Summary collapse
-
#initialize(chord) ⇒ Progression
constructor
A new instance of Progression.
- #notes(prog) ⇒ Object
Constructor Details
#initialize(chord) ⇒ Progression
Returns a new instance of Progression.
8 9 10 |
# File 'lib/zgomot/comp/chord.rb', line 8 def initialize(chord) @chord = chord || :scale end |
Instance Attribute Details
#chord ⇒ Object (readonly)
Returns the value of attribute chord.
7 8 9 |
# File 'lib/zgomot/comp/chord.rb', line 7 def chord @chord end |
Instance Method Details
#notes(prog) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/zgomot/comp/chord.rb', line 11 def notes(prog) chords = prog.mode.chords(chord); count = -1 prog.items.select do |d| d.eql?(:R) || chords[d-1] end.map do |d| count += 1; idx_length, idx_velocity = count % prog.length.length, count % prog.velocity.length unless d.eql?(:R) Chord.new(:tonic => prog.pitches[d-1], :chord => chords[d-1], :length => prog.length[idx_length], :velocity => prog.velocity[idx_velocity]) else Zgomot::Midi::Note.new(:pitch => :R, :length => prog.length[idx_length], :velocity => prog.velocity[idx_velocity]) end end end |