librelist archives

« back to archive

clocks + updated docs

clocks + updated docs

From:
Tom Lieber
Date:
2010-02-16 @ 00:23
If you're subscribed to the blog, you may know, but I just committed
clock objects to ckv. Trying to get this right stalled development for
a while, but I like how it turned out.

Clocks are virtual clocks whose speeds can be independently changed
without threads getting out of sync. Below is the sample from the
blog:

  clock = Clock(300) -- bpm

  fork(function()
    while sync(1, clock) do
      local n = Noise()
      c(n, speaker)
      yield(100 * ms)
      disconnect(n, speaker)
    end
  end)

  clock_mod = SinOsc(0.1)
  c(clock_mod, blackhole)

  while true do
    clock.bpm = clock_mod.last * 90 + 100
    print("bpm:", clock.bpm)
    yield(100 * ms)
  end

I recommend you check out the new Language Reference section of the
reference page for more clock examples and information on features of
ckv you probably didn't know existed (because I never told any one):

  http://ckvlang.org/reference.html#language

-- 
Tom Lieber
http://AllTom.com/
http://ckvlang.org/