Permalink
Browse files

Finished hack to make tempo variable in real-time. So you can change …

…the tempo while you're making music, without having to stop. Hack uses global variable. Won't be able to clean any of this up until after Burning Man. Demo of the hack in action here:

  http://gilesbowkett.blogspot.com/2008/08/archaeopteryx-variable-tempo.html
  • Loading branch information...
1 parent 6b6e0a4 commit 3f0a2f69e8c0c7b948d2573dd19600e845ec525f @gilesbowkett committed Aug 20, 2008
Showing with 22 additions and 19 deletions.
  1. +2 −0 db_drum_definition.rb
  2. +9 −16 eval_style.rb
  3. +2 −1 lib/metacircular_evaluator.rb
  4. +5 −2 lib/midi/clock.rb
  5. +4 −0 lib/midi/practical_ruby_projects/timer.rb
View
@@ -1,3 +1,5 @@
+$clock.bpm = 5
+
probabilities = {}
probabilities[:none] = [0.0] * 16
View
@@ -1,18 +1,11 @@
require 'lib/archaeopteryx'
-require 'rubyfringe'
-
-zed = Clock.new(15)
-hip_hop = Clock.new(90)
-drum_and_bass = {:clock => Clock.new(170), :drumfile => "db_drum_definition.rb"}
-techno = {}
-
-Arkx.new(:clock => drum_and_bass[:clock],
- :measures => 4,
- :logging => true,
- :evil_timer_offset_wtf => 0.2,
- :generator => Rhythm.new(:drumfile => drum_and_bass[:drumfile],
- :mutation => L{|measure| 0 == (measure - 1) % 2})).go
-
-# if you move mutation definition into drum file you can alternate between 16-bar long loops
-# and 2-bar fills.
+$clock = Clock.new(170)
+
+@loop = Arkx.new(:clock => $clock, # rename Arkx to Loop
+ :measures => 4,
+ :logging => false,
+ :evil_timer_offset_wtf => 0.2,
+ :generator => Rhythm.new(:drumfile => "db_drum_definition.rb",
+ :mutation => L{|measure| 0 == (measure - 1) % 2}))
+@loop.go
@@ -6,12 +6,13 @@ def initialize(file)
end
def reload
eval(File.read(@file))
+ puts "hey"
end
def notes(beat)
- reload
[]
end
def mutate(measure)
+ reload
end
end
end
View
@@ -5,11 +5,14 @@ class Clock # < Singleton
attr_reader :time, :interval, :start
def initialize(bpm)
# assumes 16-step step sequencer, 4/4 beat, etc.
+ self.bpm = bpm
+ @start = Time.now.to_f
+ @time = 0
+ end
+ def bpm=(bpm)
seconds_in_a_minute = 60.0
beats_in_a_measure = 4.0
@interval = seconds_in_a_minute / bpm.to_f / beats_in_a_measure
- @start = Time.now.to_f
- @time = 0
end
def tick
@time += @interval
@@ -13,6 +13,10 @@ def initialize(resolution)
end
end
end
+
+ def flush
+ @queue = []
+ end
def at(time, &block)
time = time.to_f if time.kind_of?(Time)

0 comments on commit 3f0a2f6

Please sign in to comment.