Class: Zgomot::Comp::Chord::Progression

Inherits:
Object
  • Object
show all
Defined in:
lib/zgomot/comp/chord.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#chordObject (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