- [Function]
(rts[to])
Starts the "real time" scheduler according to optional arguments. Returns no values.
rts supports the following optional arguments:
- to {stream | false}
- An optional destination output stream, defaults to current-output-stream. If the value is a stream then it must already be open and initialized. If the value is false then no output stream is assumed and the caller is expected to manage stream IO themselves.
Examples:
Example 1. Starting rts and sprouting from the REPL.
(define *pm* (portmidi-open :output 3 :latency 0)) (define (zzz len lb ub wai amp) (process repeat len output (new midi :time (now) :duration .1 :amplitude amp :keynum (between lb ub)) wait wai)) (rts *pm*) ;;; eval to add stuff (let ((k (between 20 100)) (n (pick 3 5 7 11))) (sprout (zzz (* n (pick 2 3 4)) k (+ k 7) (/ 1 n) .75))) ;;; stop when you are done. (rts-stop)
Example 2. Endless Fluff. Stops only when rts-stop is called. (Todd Ingalls)
(define fluff '(60 62 64 67 72 65 69 48 50)) (define (endless-fluff num dur knums) (process repeat num for i from 0 output (new midi :time (now) :duration (* 2 dur) :amplitude .5 :keynum (pickl fluff)) wait (pick dur (/ dur 2) (/ dur 4)) when (= i (1- num)) sprout (process repeat 4 output (new midi :time (now) :duration 5 :amplitude .5 :keynum (pickl knums))) and sprout (endless-fluff 20 1 knums))) (rts *pm*) (sprout (endless-fluff 20 1 fluff)) ;;; stop when you are done. (rts-stop)
Example 3. Sprouting into the scheduler from a receive hook.
(define *pm* (portmidi-open :input 1 :output 3 :latency 0)) (define (major-thirds len knum) (process with d = .1 for i below len for k = (+ knum (* (mod i 5) 4)) output (make-note-on 0 k 90) at (now) sprout (make-note-off 0 k 125) at (+ (now) .5) wait d)) (rts *pm*) (set-receiver! (lambda (mm ms) ms (if (note-on-p mm) (sprout (major-thirds 20 (note-on-key mm))))) *pm*) ;;; stop receiving and scheduling. (remove-receiver! *pm*) (rts?) ⇒ :running (rts-stop) (rts?) ⇒ #f
See also:
rts?[Function]rts-pause[Function]rts-continue[Function]rts-stop[Function]set-receiver![Function]sprout[Function]