Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
64 lines (48 sloc) 1.79 KB
(in-package #:sc-extensions)
(named-readtables:in-readtable :sc)
(define-code poly (n gate)
(* gate (== 0 (mod (+ (loop for i from 0 below n collect i)
( gate)) n))))
(define-code rand-tr (tr odds)
(* tr (> odds ( .0 .9999 tr))))
(define-code safe-tr (tr)
(let* ((trg tr)
(sel ( 1 trg)))
( sel [1 trg])))
(define-code r+ (sig min max)
(range sig min max))
(define-code g+ (div len contents)
(gate-lane div len contents))
(define-code (start end dur gate)
( (env [0 start end] [0 dur]) :gate gate))
(define-code (start end dur gate)
( (env [0 start end] [0 dur]) :gate gate))
(define-code (gate &optional (attack 0.01) (release 1.0) (level 1.0) (curve -4.0))
( (perc attack release level curve) :gate gate))
(define-code (in del)
( in 2.0 del))
(define-code (attk level rel gate &key (act :no-action))
( (asr attk level rel) :gate gate :act act))
(defun (div len contents)
( (sc::mod~ (sc::floor~ (sc::/~ (cnt div) len)) (length contents)) contents))
(defmacro proxy-handle (key &optional action handle (to 1))
(let* ((name (format nil "~a-HANDLE" (string-upcase key)))
(cmd (format nil "/~a" name))
(key (intern name :keyword)))
(if action `(let ((func ,handle))
(lambda (&rest args)
(flet ((float-to-int (number)
(multiple-value-bind (v fract)
(floor number)
(if (zerop fract) v (+ v fract)))))
(apply func (mapcar #'float-to-int (cddr args))))))
(proxy ,key
(let ((result ,action))
(destructuring-bind (trig &rest values)
( trig ,cmd values)))
:to ,to
:fade .0))
`(proxy ,key))))
You can’t perform that action at this time.