;; circular.scm - (c) rohan drape, 2005-2006 ;; The fmod() function computes the remainder of dividing x by y. The ;; return value is x - n * y, where n is the quotient of x / y, ;; rounded towards zero to an integer. (define (fmod x y) (let ((n (quotient x y))) (- x (* n y)))) (define (takt->pulse cycle pulse takt) (let* ((m (fmod pulse cycle)) (i (- takt m)) (p (if (negative? i) (+ i cycle) i))) (+ p pulse))) ;; 'p' and the value reported to 'f' are cyclic in [0, 'cycle'). (define (tschedule-at%! T cycle p f) (tschedule-at! T (takt->pulse cycle (utc->pulse T (utc)) p) (lambda (pulse utc) (f (fmod pulse cycle) utc))))