beat_scheduler   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/core/scheduler.xtm

Implementation

(bind-func beat_scheduler
  (lambda (bpm:double hz:double)
    (let ((evtlist:SchedEvt{Rational}* null)
          (ft:[void,Rational]* null)
          (scheduler:[i64,Rational]* null)
          (beat:Rational 1/1)
          (running:i64 1)
          (offset:i64 0)
          (time 0.0)
          (i (Rat 1 (dtoi64 hz)))
          (f (lambda ()
              (spawn (lambda ()
                        (set! scheduler (scheduler_init evtlist ft))
                        (set! time (clock_clock))
                        (while (> running 0)
                          (scheduler beat)
                          (set! beat (+ beat (* i (Rat (dtoi64 bpm) 60))))
                          (while (< (clock_clock) time) (thread_sleep 0 100000))
                          (set! time (+ time (rtod i)))
                          void)
                        (println "exiting scheduler")))
              void)))
      (f)
      f)))


Back to Index

Similar Entries

  • beat_loop    xtlang
  • beat_test    xtlang
  • clock_scheduler    xtlang
  • clock_scheduler_main_callback    xtlang
  • onbeat?    macro
  • scheduler_at    xtlang
  • scheduler_evt    xtlang
  • scheduler_init    xtlang
  • start_midi_scheduler    xtlang