Skip to content

Commit

Permalink
Each rhythm has its own clock. This permits the multiple time signatu…
Browse files Browse the repository at this point in the history
…res simultaneously thing to work. Unfortunately it kind of sounds like ass. I think that's because I didn't bother to make it sound good, though. The timing sounds about right. Note that although this does solve the problem, it also leaves a significant flaw unresolved, which is the (1..4).each do |measure| (line 21) in arkx.rb. That should really not have 4 hardcoded - the 24-note rhythms should actually have the number 6 there. Basically if you're using triplets, 6 plays the role of 4. Since it only influences the mutation timing, and nothing else, I left it as-is, but it really should change to reflect the other changes on this branch.
  • Loading branch information
gilesbowkett committed Oct 17, 2008
1 parent ed360d1 commit e80e3fb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion eval_style.rb
Expand Up @@ -5,9 +5,11 @@
:logging => false,
:evil_timer_offset_wtf => 0.2,
:generator => Mix.new(:rhythms => [Rhythm.new(:drumfile => "sixteen.rb",
:mutation => L{|measure| 0 == (measure - 1) % 2}),
:mutation => L{|measure| 0 == (measure - 1) % 2},
:clock => Clock.new(170)),
Rhythm.new(:drumfile => "twenty_four.rb",
:mutation => L{|measure| 0 == (measure - 1) % 3},
:clock => Clock.new(170,6),
:beats => 24)]))

@sixteen.go
Expand Down
5 changes: 3 additions & 2 deletions lib/arkx.rb
Expand Up @@ -17,12 +17,13 @@ def go
generate_beats = L do
start = @clock.time
@generator.rhythms.each do |rhythm|
@clock.time = start
rhythm.clock.time = start
(1..4).each do |measure|
rhythm.mutate(measure)
(0..(rhythm.beats - 1)).each do |beat|
play rhythm.notes(beat)
@clock.tick
rhythm.clock.tick
@clock.time = rhythm.clock.time
end
end
@midi.timer.at((@clock.start + @clock.time) - @evil_timer_offset_wtf, &generate_beats)
Expand Down
1 change: 0 additions & 1 deletion lib/midi/clock.rb
Expand Up @@ -15,7 +15,6 @@ def bpm=(bpm)
end
def tick
@time += @interval
@time
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/rhythm.rb
@@ -1,10 +1,11 @@
module Archaeopteryx
class Rhythm
attr_accessor :beats
attr_accessor :beats, :clock
def initialize(attributes)
@mutation = attributes[:mutation]
@drumfile = attributes[:drumfile]
@beats = attributes[:beats] || 16
@clock = attributes[:clock]
reload
end
def reload
Expand Down

0 comments on commit e80e3fb

Please sign in to comment.