set-signal!   macro


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/scheme.xtm

Implementation

;; define me first!
(define-macro (set-signal! variable value seconds . rate)
  (let ((r (if (null? rate) 1/30 (car rate))))
    (if (and (or (list? value)
                 (defined? value))
             (closure? (eval value)))
        `(let l1929 ((t (now))
                     (count (/ ,seconds ,r)))
           (if (equal? ,variable 'stop-signal)
               'done
               (begin (set! ,variable (apply ,value (list ,variable)))
                      (if (> count 1)
                          (callback (+ t (* *samplerate* ,r)) l1929 (+ t (* *samplerate* ,r)) (- count 1))))))
        `(let l1929 ((t (now))
                     (inc (/ (- ,value ,variable) (real->integer (/ ,seconds ,r))))
                     (count (real->integer (/ ,seconds ,r))))
           (if (equal? ,variable 'stop-signal)
               'done
               (begin (set! ,variable (+ ,variable inc))
                      (if (> count 1)
                          (callback (+ t (* *samplerate* ,r)) l1929 (+ t (* *samplerate* ,r)) inc (- count 1)))))))))


Back to Index