Permalink
Browse files

Each rhythm has its own clock. This permits the multiple time signatu…

…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...
1 parent ed360d1 commit e80e3fb4923140e9f9a719ef69eedc2e71a3a3e3 @gilesbowkett committed Oct 17, 2008
Showing with 8 additions and 5 deletions.
  1. +3 −1 eval_style.rb
  2. +3 −2 lib/arkx.rb
  3. +0 −1 lib/midi/clock.rb
  4. +2 −1 lib/rhythm.rb
View
4 eval_style.rb
@@ -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
View
5 lib/arkx.rb
@@ -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)
View
1 lib/midi/clock.rb
@@ -15,7 +15,6 @@ def bpm=(bpm)
end
def tick
@time += @interval
- @time
end
end
end
View
3 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

0 comments on commit e80e3fb

Please sign in to comment.