Class: Collavoce::Tracker

Inherits:
Object
  • Object
show all
Defined in:
lib/collavoce/tracker.rb

Instance Method Summary collapse

Constructor Details

#initialize(*tracks) ⇒ Tracker

Returns a new instance of Tracker.



3
4
5
# File 'lib/collavoce/tracker.rb', line 3

def initialize(*tracks)
  @tracks = tracks
end

Instance Method Details

#loop(bpm = 120) ⇒ Object



19
20
21
# File 'lib/collavoce/tracker.rb', line 19

def loop(bpm=120)
  run(bpm) while true
end

#run(bpm = 120) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/collavoce/tracker.rb', line 7

def run(bpm = 120)
  @threads = []
  @tracks.each do |track|
    @threads << Thread.new do
      track.each do |voice|
        voice.new(:bpm => bpm).run
      end
    end
  end
  @threads.map(&:join)
end