No description, website, or topics provided.
Common Lisp
Switch branches/tags
Nothing to show
Latest commit 3bb2cf2 Sep 18, 2017 @byulparan byulparan committed on GitHub Merge pull request #24 from defaultxr/master
Add bus allocation & handling; few other minor fixes

README.md

cl-collider

A SuperCollider client for CommonLisp.
It supports the SBCL & ClozureCL compilers.
It is an experimental project, so changes to the API are possible.

Videos

Tutorial

Due to API changes, this video is deprecated. A new tutorial video is coming soon.

Live Coding Demo 1

Live Coding Demo 2

Dependencies:

version: 2017.3.15

package: sc, sc-user(use this package)

named-readtable: sc

usage:

(in-package :sc-user)
(named-readtables:in-readtable :sc)

;; please check   *sc-synth-program*, *sc-plugin-paths*, *sc-synthdefs-path*
;; if you have different path then set to
;;
;; (setf *sc-synth-program* "/path/to/scsynth")
;; (setf *sc-plugin-paths* (list "/path/to/plugin_path" "/path/to/extension_plugin_path"))
;; (setf *sc-synthdefs-path* "/path/to/synthdefs_path")

(setf *s* (make-external-server "localhost" :port 48800))
(server-boot *s*)

;; Hack music
(play (sin-osc.ar [320 321] 0 .2))

;; Stop music
(bye *)

;; Quit SuperCollider server
(server-quit *s*)

Create SynthDef

>>>>>>> 98163f8f7ddf36e70069e486658dbca77a6e3a8e
(defsynth sine-wave (&key (note 60))
  (let* ((freq (midicps note))
         (sig (sin-osc.ar [freq (+ freq 2)] 0 .2)))
     (out.ar 0 sig)))

(defparameter *synth* (sine-wave))
(ctrl *synth* :note 72)
(free *synth*)

Create Proxy

(proxy :sinesynth
  (sin-osc.ar [440 441] 0 .2))

(proxy :sinesynth
  (with-controls ((lfo-speed 4))
    (sin-osc.ar (* [440 441] (range (lf-pulse.ar [lfo-speed (+ lfo-speed .2)]) 0 1)) 0 .2))
  :fade 8.0)
   
(ctrl :sinesynth :lfo-speed 8)
(ctrl :sinesynth :gate 0)

Create Musical Sequence

(defsynth saw-synth (&key (note 60) (dur 4.0))
  (let* ((env (env-gen.kr (env [0 .2 0] [(* dur .2) (* dur .8)]) :act :free))
         (freq (midicps note))
    	 (sig (lpf.ar (saw.ar freq env) (* freq 2))))
	(out.ar 0 [sig sig])))

(defun make-melody (time n &optional (offset 0))
  (when (> n 0)
    (at time (saw-synth :note (+ offset (alexandria:random-elt '(62 65 69 72)))))
      (let ((next-time (+ time (alexandria:random-elt '(0 1 2 1.5)))))
        (callback next-time #'make-melody next-time (- n 1) offset))))

(make-melody (quant 4) 16)
(make-melody (+ 4 (quant 4)) 16 12)

Record Audio Output

(setf *synth-definition-mode* :load)

;; Re-define the saw-synth ugen
;; The SynthDef file will be written to the *sc-synthdefs-path*
(defsynth saw-synth (&key (note 60) (dur 4.0))
  (let* ((env (env-gen.kr (env [0 .2 0] [(* dur .2) (* dur .8)]) :act :free))
         (freq (midicps note))
         (sig (lpf.ar (saw.ar freq env) (* freq 2))))
    (out 0 [sig sig])))

;; Render audio file
(with-rendering ("~/Desktop/foo.aiff" :pad 60)
  (make-melody 0.0d0 32)
  (make-melody 8.0d0 32 12)
  (make-melody 16.0d0 32 24))