I have started to transfer Eli Fieldsteel's excellent lectures from superCollider to cl-collider. In addition to cl-collider, cm-utils, incudine and jack and, of course, emacs are required. More on this in the "Setups" tab. The Supercollider video can be viewed here. In order to grant Emacs access to the microphone in macOS, it is mandatory to follow the instructions here:
https://scsynth.org/t/emacs-scsynth-and-microphone-permissions/3253/10
Alternatively, the server must be started manually from the terminal:
/Application/SuperCollider.app/Contents/Resources/scsynth -u 57140
when this is done, start cl-collider like this:
(ql:quickload '(:cl-collider))
(in-package :sc-user)
(named-readtables:in-readtable :sc)
(setf *s* (make-external-server "localhost" :port 57140 :just-connect-p t))
(server-boot *s*)
(play
(pan2.ar (sound-in.ar 0)))
(ql:quickload :cl-collider)
(in-package :sc)
(named-readtables:in-readtable :sc)
(setf *s* (make-external-server "localhost" :port 48800))
(server-boot *s*)
;;MUS499C Eli Fieldsteel Spring 2021
;;simple sinosc synthdef
(defsynth fm ((freq 400) (amp 0.2) (pan 0) (out 0) (atk 0.01) (rel 3))
(let* ((sig (sin-osc.ar freq))
(env (env-gen.kr (env [0 1 0] [atk rel] [1 -1]))))
(out.ar out (pan2.ar (* sig env) pan amp))))
(defparameter *ns* (synth 'fm))
(free *ns*))
(ql:quickload :cm-utils)
(in-package :cm)
(rts)
(sprout (sc::synth 'fm))
(sprout
(process
repeat 100
do
(sc::synth 'sc::fm )
(wait 3)))
;;;;;;;;;;;;;
;;füge einen Modulator mit modfreq und modamp-Kontrollen hinu
;;output wird zum carrier sinosc hinzugefügt
(in-package :sc)
(defun exprand (min max)
(* min (expt (/ max min) (random 1.0))))
(defun between (min max)
(+ min (random (- max min))))
(defsynth fm ((freq 400) (modfreq 600) (modamp 300) (amp 0.2) (pan 0) (out 0) (atk 0.01) (rel 3))
(let* ((modulator (sin-osc.ar modfreq modamp))
(carrier (sin-osc.ar (+ freq modulator)))
(env (env-gen.kr (env [0 1 0] [atk rel] [1 -1])))
(sig (* carrier env)))
(out.ar out (pan2.ar sig pan amp))))
(cm::sprout
(cm::process
cm::repeat 100
do
(sc::synth 'sc::fm
:freq (exprand 20 20000)
:modfreq (exprand 20 20000)
:modamp (exprand 1 20000)
:rel 0.1)
(cm::wait (exprand 0.01 0.5))))
(sc::stop *s*)
;;;um mehr musikalische Tonhöhenkontrolle zu erhalten, sollte die Modulator-Frequenz von Verhältniszahl abhängig von der Carrierfrquenz sein (z.B. modfreq:freq 2:1)
;;;einfache Verhältniszahlen 2, 3, 1,5 produzieren harmonische Spektren
;;;nicht ganzzahlige Teilungen produzieren inharmonische Spektren
(defsynth fm ((freq 400) (amp 0.1) (pan 0) (out 0) (atk 0.01) (rel 3) (ratio 2) (index 1))
(let* ((modulator (sin-osc.ar (* freq ratio) 0 (* freq ratio index)))
(carrier (sin-osc.ar (+ freq (* modulator ratio))))
(env (env-gen.kr (env [0 1 0] [atk rel] [1 0])))
(sig (pan2.ar (* carrier env) pan amp)))
(out.ar out sig)))
(synth 'fm :freq (midicps 60))
(cm::sprout
(cm::process
cm::repeat 100
do
(sc::synth 'sc::fm
:freq (midicps 60)
:ratio (print (between 1 10)))
(cm::wait 2)))
;;;Indem wir die Modulator-Frequenz und die Modulator-Amplitude als Verhältniszahl ausdrücken, ist es einfacher die Anzahl der Seitenbänder mit einem Wert namens "Modulationsindex" gleich modamp/modfreq zu kontrollieren. Der index nähert sich etwa an die Anzahl der hörbaren Seitenbänder an:
(defsynth fm ((freq 400) (amp 0.1) (pan 0) (out 0) (atk 0.01) (rel 3) (ratio 2) (index 1))
(let* ((modulator (sin-osc.ar (* freq ratio) 0 (* freq ratio index)))
(carrier (sin-osc.ar (+ freq (* modulator ratio))))
(env (env-gen.kr (env [0 1 0] [atk rel] [1 0])))
(sig (pan2.ar (* carrier env) pan amp)))
(out.ar out sig)))
(cm::sprout
(cm::process
cm::repeat 20
do
(synth 'fm :freq 50 :index (print (between 1.0 10.0)))
(cm::wait 2)))
;(synth 'fm :freq 50 :index 4)
;;;Wenn man um die Modulation zu kontrollieren eine Hüllkurve verwendet, kann dies zu expressiveren und interessanteren Klängen führen
(defsynth fm-index ((freq 400) (amp 0.1) (pan 0) (out 0) (atk 0.01) (rel 3) (ratio 2) (ipeak 7) (irel 0.2) (iatk 0.01))
(let* ((ienv (env-gen.kr (env [1 ipeak 1] [iatk irel] [1 -3])))
(modulator (sin-osc.ar (* freq ratio) 0 (* freq ratio ienv)))
(carrier (sin-osc.ar (+ freq modulator)))
(env (env-gen.kr (env [0 1 0] [atk rel] [1 -1])))
(sig (pan2.ar (* carrier env) pan amp)))
(out.ar out sig)))
(synth 'fm-index)
;;; mit statischem index
(cm::sprout
(cm::process
cm::repeat 20
do
(synth 'fm :freq (between (midicps 40) (midicps 50))
:rel 0.3
:index 7)
(cm::wait 0.25)))
;;;mit dynamischem index
(cm::sprout
(cm::process
cm::repeat 20
do
(synth 'fm-index :freq (between (midicps 40) (midicps 50))
:rel 0.3)
(cm::wait 0.25)))
;;;Modulator in Serie
;;mod moduliert sig, aber mod2 moduliert auch die Frequenz von mod
(defsynth fm ((freq 400) (amp 0.1) (pan 0) (out 0) (atk 0.01) (rel 10) (ratio (/ 8 400)) (ratio2 (/ 0.5 400)) (index 16) (index2 16))
(let* ((mod2 (sin-osc.ar (* freq ratio2) 0 (* freq ratio2 index2)))
(modulator (sin-osc.ar (+ (* freq ratio) mod2) 0 (* freq ratio index)))
(carrier (sin-osc.ar (+ freq modulator)))
(env (env-gen.kr (env [0 1 0] [atk rel] [1 -1])))
(sig (pan2.ar (* carrier env) pan amp)))
(out.ar out sig)))
(synth 'fm :freq 500)
;;Alien Polizei-Sirene
(synth 'fm :freq 500 :ratio 2 :ratio2 0.01)
;;Verhältniszahlen, die sich langsam von Ganzahlen wegbewegen produzieren interesannte Ergebnisse, die sich langsam "bewegen"
(synth 'fm :freq 50 :ratio 2.002 :index 200 :ratio2 3.001 :index2 10)
;;was aber auch schnell übersteuert
(synth 'fm :freq 50 :ratio 20 :index 350 :ratio2 1.1 :index2 100)
;;Modulator in Serie
;;zwei Modulatoren operieren gleichzeitig an einer Träger-Frequenz
;;in anderen Worten, die Modulatoren werden summiert und hinzugefügt
(defsynth fm ((freq 400) (amp 0.1) (pan 0) (out 0) (atk 0.01) (rel 10) (ratio (/ 8 400)) (ratio2 (/ 1 400)) (index 20) (index2 100))
(let* ((mod2 (sin-osc.ar (* freq ratio2) 0 (* freq ratio2 index2)))
(modulator (sin-osc.ar (* freq ratio) 0 (* freq ratio index)))
(carrier (sin-osc.ar (+ freq modulator mod2)))
(env (env-gen.kr (env [0 1 0] [atk rel] [1 -1])))
(sig (pan2.ar (* carrier env) pan amp)))
(out.ar out sig)))
(synth 'fm)
;;;Oszillator-Selbstmodulation
;;die vertikale Maus-Position kontrolliert die Trägerfrequenz wie auch die Modulator-Frequenz, da sie hier das gleiche Signal darstellen, die horizontale kontrolliert die Modulator-Amplitude
(defsynth fmfb ()
(let* ((fb (local-in.ar 1))
(out-sig (sin-osc.ar (+ (mouse-y.kr 20 20000 :exponential) (* fb (mouse-x.kr 1 10000 :exponential)))))
(local (local-out.ar out-sig))
(sig (pan2.ar out-sig 0 0.2)))
(out.ar 0 sig)))
(synth 'fmfb)
(stop)
;;Danke an Orm Finnendahl für die Hilfe im folgenden Beispiel
;; Load required libraries
(ql:quickload :cl-plot)
(defun coerce-to-vector (2d-array)
"transform the 2d vector returned by supercollider into a 1d vector for plotting"
(make-array (array-total-size 2d-array)
:displaced-to 2d-array
:element-type (array-element-type 2d-array)))
(defparameter *my-buffer* (buffer-alloc (* 2 4096)))
(buffer-fill
*my-buffer*
:sine
'(1 0.5 0.2 0.2 0.15 0.1)
:phases '(0 pi 0 pi 0 0)
:as-wavetable t)
(cl-plot:plot (coerce-to-vector (buffer-get-to-array *my-buffer*)))
;;; Synth Definition:
(defsynth my-synth ()
(let* ((mod (sin-osc.ar (mouse-y.kr 10 10000 :exp) 0 400))
(sig (* 0.15 (osc.ar *my-buffer* (+ (mouse-x.kr 20 20000 :exp) mod)))))
(out.ar 0 (list sig sig))))
;;; Den Synth spielen:
(defparameter *synth-instance* (synth 'my-synth))
;;; ende:
(release *synth-instance*)
;;; oder:
(stop)
;;;das folgende Beispiel Fieldsteels brachte viel Blut, Schweiß und Tränen, da es einige Funktionen in cl-collider nicht gibt, diese selbst zu bauen, brachte wiederum nicht die gewünschten Erfolge, daher wurde auf bipolar verzichtet und stattdessen saw.ar verwendet.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;ein komplexeres Beispiel
(defsynth oscfm ((freq 200) (buf 0) (modfreq 1000) (modamp 1000) (dev 0.1)
(atk 0.02) (rel 0.5) (atkcrv 1) (relcrv -3) (pan 0) (amp 0.2))
(let* ((mod (osc.ar buf modfreq modamp))
(sig (loop for i from 0 to 5
collect
(let* ((spread (midiratio (saw.ar (lf-noise1.kr 0.05) dev)))
(carrier (osc.ar buf (* freq spread) mod)))
carrier)))
(env (env-gen.kr (env [0 1 0] [atk rel] [atkcrv relcrv]))))
(out.ar 0 (pan2.ar (* sig env) pan amp))))
(synth 'oscfm :buf *my-buffer*)
(synth 'oscfm :buf *my-buffer* :freq 50 :modfreq 200 :modamp 500 :rel 4 :amp 0.1)
(defun exprand (min max)
(* min (expt (/ max min) (random 1.0))))
(defun between (min max)
(+ min (random (- max min))))
(defun pwrand (list-to-embed into-list)
(let ((len (length into-list)))
(loop for item in list-to-embed
do (setf (nth (random len) into-list) item))
into-list))
(defun pwhite (min max)
;;generiere eine zufällige Ganzzahl zwischen 0 und max - min Wert
(random (+ 1 (- max min)))
;;füge die Zufallszahl zum min-Wert hinzu
(+ min (random (+ 1 (- max min)))))
(defparameter *my-list* '(1 2 3 4 5)) ; define a list of values
(defun prand (lst)
(nth (random (length lst)) lst))
(print (prand *my-list*))
(defun midiratio-single (interval)
(expt 2 (/ interval 12.0)))
(defun midiratio-list (intervals)
(mapcar #'(lambda (interval) (expt 2 (/ interval 12.0))) intervals))
(sprout
(process
repeat 20
do
(sc::synth sc::'oscfm :buf sc::*my-buffer*
:dur (exprand 0.1 1.5))
(wait 0.1)))
;;;this is a translation of Eli Fieldsteels Sc-Code from SC to cl-collider including Common Music 2 in Orm Finnendahls version!
(sprout
(process
repeat 100
do
(sc::synth sc::'oscfm :buf sc::*my-buffer*
:freq (mapcar #'*
(pwrand '(50 100 200) '(0.8 0.1 0.1))
(cm::midiratio-list (pwrand '(0 7 12 17 28) '(0.6 .1 .1 .1 .1))))
:dev (exprand 0.05 .2)
:modfreq (prand '(50 100 200 400 600 800))
:modamp (exprand 40 1000)
:atk (exprand 0.1 2.5)
:rel (exprand 3 5)
:amp (exprand 0.05 .3)
:pan (pwhite -3.0 3.0))
(wait (exprand 0.1 1.5))))
;;;using bipolar with help from Orm Finnendahl
(defun bipolar (ugen &optional (mul 1))
(range ugen (neg mul) mul))
(defun sum (array)
(let ((sum (first array)))
(dolist (arr (cdr array) sum)
(setf sum (+~ sum arr)))))
(defun sum (array)
(let ((sum (first array)))
(dolist (arr (cdr array) sum)
(setf sum (+~ sum arr)))))
(defsynth oscfm ((freq 200) (buf 0) (modfreq 1000) (modamp 1000) (dev 0.1)
(atk 0.02) (rel 0.5) (atkcrv 1) (relcrv -3) (pan 0) (amp 0.2))
(let* ((mod (osc.ar buf modfreq modamp))
(sig (sum
(loop repeat 5
collect
(let* ((spread (midiratio (bipolar (lf-noise1.kr (* 0.05 dev)))))
(carrier (osc.ar buf (* freq spread) mod)))
carrier))))
(env (env-gen.kr (env [0 1 0] [atk rel] [atkcrv relcrv]))))
(out.ar 0 (* env (pan2.ar sig pan amp)))))
(synth 'oscfm)
(in-package :sc)
(defparameter *my-buffer2* (buffer-alloc (* 2 4096)))
:as-wavetable t)
(buffer-fill
*my-buffer2*
:sine
(mapcar #'(lambda (n) (/ 1.0 n)) (loop for i from 1 to 16 collect i))
:as-wavetable t)
(cl-plot:plot (coerce-to-vector (buffer-get-to-array *my-buffer2*)))
(defsynth my-synth ()
(let* ((sig (osc.ar *my-buffer2* (* (mouse-x.kr 100 800 :exp) [1 1.01]) 0.12)))
(out.ar 0 (dup sig))))
(synth 'my-synth)
(stop)
(defun range (start end &optional step)
"erstellt eine Zahlenfolge von Start nach Ende mit optionaler Schrittgroesse"
"Generates a sequence of numbers from start to end, with optional step size."
(let ((step-size (if step step 1)))
(loop for i from start below end by step-size collect i)))
(defun sum (array)
(let ((sum (first array)))
(dolist (arr (cdr array) sum)
(setf sum (+~ sum arr)))))
(defsynth mysynth-2 ((freqs '(0 0 12 12 19 24 26 31 33 35)))
(dotimes (i (length freqs))
(let* ((n (* (midicps (+ (nth i freqs) 36)) (midiratio (between -0.15 0.15))))
(sig (* (osc.ar *my-buffer* n) 0.1))
(sig (* sig (sin-osc.kr (between 0.1 0.15) (between 0 (* 2 pi)) (range 0.2 1 0.1))))
(sig (* sig (lin-lin sig 0 1 0.2 1)))
(sig (lpf.ar sig (* n 2)))
(sig (pan2.ar sig (between -0.9 0.9)))
(env (env-gen.kr (env [0 1 0] [4 4] [1 -1]))))
(out.ar 0 (* 2(* sig env))))))
(synth 'mysynth-2)
(stop)
;;;another approach
(defsynth mysynth-3 ((freqs '(0 0 12 12 19 24 26 31 33 35)))
(let* ((sig (sum
(loop for i below (length freqs)
collect
(let* ((n (* (midicps (+ (nth i freqs) 36)) (midiratio (between -0.15 0.15))))
(s1 (* (osc.ar *my-buffer* n) 0.1))
(s2 (* s1 (sin-osc.kr (between 0.1 0.15) (between 0 (* 2 pi)) (range 0.2 1 0.1))))
(s3 (* s2 (lin-lin s2 0 1 0.2 1)))
(s4 (lpf.ar s3 (* n 2)))
(s5 (pan2.ar s4 (between -0.9 0.9))))
s5))))
(env (env-gen.kr (env [0 1 0] [4 4] [1 -1]))))
(out.ar 0 (* 2 (* sig env)))))
(synth 'mysynth-3)
;;run me 2-3 times for richer chorus effect
(defsynth mysynth-4 ((freqs '(-1 -1 11 11 19 26 28 30 31 33 38)))
(let* ((sig (sum
(loop for i below (length freqs)
collect
(let* ((n (* (midicps (+ (nth i freqs) 36)) (midiratio (between -0.15 0.15))))
(s1 (* (osc.ar *my-buffer* n) 0.1))
(s2 (* s1 (sin-osc.kr (between 0.1 0.15) (between 0 (* 2 pi)) (range 0.2 1 0.1))))
(s3 (* s2 (lin-lin s2 0 1 0.2 1)))
(s4 (lpf.ar s3 (* n 2)))
(s5 (pan2.ar s4 (between -0.9 0.9))))
s5))))
(env (env-gen.kr (env [0 1 0] [4 4] [1 -1]))))
(out.ar 0 (* 2 (* sig env)))))
(synth 'mysynth-4)
(in-package :cm)
(rts)
(sprout
(process
repeat (sc::between 3 10)
do
(sc::synth sc::'mysynth-4)
(wait 1.2)))
;;; Und nun tausend Dank an Orm Finnendahl für die folgenden Macros und Funktionen
(defgeneric discretize (env &key n))
(defmethod discretize ((env sc:env) &key (n 1024))
(env-as-signal env n))
(defmacro n-collect (n form &key (initial-element '()))
"return a seq of n elems prepended to initial-element by
evaluating form n times with the symbol n bound to the iteration
index in the lexical scope of form."
"Gib eine Sequenz von n Elementen zurück, die dem Initial-Element vorangestellt sind, indem das Formular n-mal ausgewertet wird, wobei das Symbol n an den Iterationsindex im lexikalischen Gültigkeitsbereich des Formulars gebunden ist."
`(labels
((fn (num seq)
(if (< num ,n)
(cons
(let ((n num)) ,form)
(fn (+ num 1) seq))
seq)))
(fn 0 ,initial-element)))
;;; (n-collect 2 (random 1.0) :initial-element '(0)) -> (0.13675463 0.53642476 0)
(defun normalize (seq &optional (min 0.0) (max 1.0))
(let* ((minv (apply #'min seq))
(maxv (apply #'max seq))
(fn
(if (= maxv minv)
(lambda (x) (declare (ignore x)) min)
(lambda (x) (+ min (* (- x minv) (/ (- max min) (- maxv minv))))))))
(mapcar fn seq)))
;;;Mit diesen Definitionen bekommst man Envelope so:
(defparameter *env*
(env
(append '(0) (normalize (n-collect 10 (random 1.0)) -1.0 1.0) '(0))
(loop repeat 11 collect (exprand 0.01 1))
(loop repeat 11 collect (between -4.0 4.0))))
(ql:quickload :cl-plot)
(cl-plot:plot (discretize *env*))
;;;the buffer
(defparameter *my-buf* (buffer-alloc 4096))
;;;and now we fill it
(buffer-setn *my-buf* (discretize *env*))
;;our SynthDef
(defsynth my-synth ()
(let* ((sig (* 0.15 (osc.ar *my-buf* [100 100.5])))
(filter (lpf.ar sig 3000)))
(out.ar 0 (dup filter))))
;;; Den Synth spielen:
;;fire up
(defparameter *synth-instance* (synth 'my-synth))
(stop)
;; alloziiere Buffer 10-13:
(defparameter *4bufs* (n-collect 4 (buffer-alloc 4096 :bufnum (+ n 10))))
;;; Mit env Wavetables füllen:
(dotimes (n 4)
(buffer-setn
(elt *4bufs* n)
(discretize
(env
'(0 -1 1 0.5 -0.5 0.9 -0.8 0.2 0)
(n-collect 8 (exprand 0.01 1))
(n-collect 8 (between -3.0 3.0)))
:n 4096)))
;;; spielen:
;;;/move the mouse horizontally to interpolate across (i.e. "morph" between) these four wavetables
(play (* 0.15 (v-osc.ar (mouse-x.kr 10 13) '(100 100.5))))
;;; optional plotten:
(dotimes (n 4)
(cl-plot:plot (coerce-to-vector (buffer-get-to-array (elt *4bufs* n)))))
(stop)
(ql:quickload :cm-utils)
(in-package :cm)
(rts)
(in-package :sc)
(play (* 0.15 (v-osc.ar (mouse-x.kr 10 13) '(100 100.5))))
;;; Und nochmal tausend Dank an Orm Finnendahl für die folgenden Macros und Funktionen
(in-package :sc)
;; Allocate eight buffers
(defparameter *8bufs* (n-collect 8 (buffer-alloc 8192 :bufnum (+ n 10))))
;; Fill the buffers with data
(dotimes (i 8)
(buffer-setn
(elt *8bufs* i)
(discretize
(env
'(0 -1 1 0.5 -0.5 0.9 -0.8 0.2 0)
(n-collect 8 (exprand 0.01 1))
(n-collect 8 (between -3.0 3.0)))
:n 4096)))
(dotimes (i 8)
(let ((buf (elt *8bufs* i)))
(format t "Buffer ~a: ~a~%" i (bufnum buf))))
(play (* 0.15 (v-osc.ar (mouse-x.kr 10 13) '(100 100.5))))
(play (splay.ar (v-osc.ar 13 (* 100 (midiratio (* (between -0.12 0.12)
(cm::pick 0.5 1.0)))))))
(dotimes (i 8) (play (splay.ar (v-osc.ar 13) (* 100 (midiratio (* (between -0.12 0.12)))))))
(stop)
(defsynth play-voxc ()
(let* ((sig (loop for i from 0 to 7
collect
(* (v-osc.ar (range (lf-noise1.kr 0.1) 10 17)
(* (midiratio (* (between -0.12 0.12)
(cm::pick 0.5 1.0)))
100)
0.2)))))
(out.ar 0 (splay.ar sig))))
(synth 'play-voxc)
(in-package :cm)
(sprout
(process
repeat 8
do
(sc::synth sc::'play-voxc :center (between 0 2) :mul (between 0.01 0.3))
(wait (between 1.1 2.3))))
;;;for (sound-in.ar I have to start cl-collider like this:
/Applications/SuperCollider.app/Contents/Resources/scsynth -u 57140
(in-package :sc-user)
(named-readtables:in-readtable :sc)
(setf *s* (make-external-server "localhost" :port 57140 :just-connect-p t))
(server-boot *s*)
(play
(pan2.ar (sound-in.ar 0)))
;;;;sc2-examples of SuperCollider translated to cl-collider
(ql:quickload '(:cl-collider :sc-extensions))
(in-package :sc-user)
(use-package :sc-extensions)
(named-readtables:in-readtable :sc)
(defun exprand (min max)
(* min (expt (/ max min) (random 1.0))))
(defun between (min max)
(+ min (random (- max min))))
(setf *s* (make-external-server "localhost" :port 48800))
(server-boot *s*)
(
// analog bubbles
(play (comb-n.ar (sin-osc.ar (lf-saw.kr 0.4 0 24 (midicps(lf-saw.kr [8 7.23] 0 3 80))) 0 0.04) 0.2 0.2 4))
(stop)
;; LFO modulation of Pulse waves and resonant filters
(play (comb-l.ar (rlpf.ar (lf-pulse.ar(f-sin-osc.kr 0.05 0 80 160) 0 0.4 0.05) (f-sin-osc.kr [0.6 0.7] 0 3600 4000) 0.2) 0.3 [0.2 0.25] 2))
(stop)
;;moto rev
(play (clip2 (rlpf.ar(lf-pulse.ar(sin-osc.kr 0.2 0 10 21) 0.1) 100 0.1) 0.4))
;;scratchy
(play (rhpf.ar (max 0 (* 20 (brown-noise.ar [0.5 0.5] -0.49))) 5000 1))
(stop)
;;sprinkler
(play (one-pole.ar (white-noise.ar(lf-pulse.kr(lf-pulse.kr 0.09 0 0.16 10 17) 0 0.25 0.1))))
(stop)
(play (one-pole.ar (white-noise.ar(lf-pulse.kr(mouse-x.kr 0.2 50) 0 0.25 0.1))))
(stop)
(in-package :sc)
(defun between (min max)
(+ min (random (- max min))))
(play (let ((f 50) ; fundamental frequency
(p 20) ; number of partials per channel
(z 0.0) ; start of oscil daisy chain
(offset (line.kr 0 -0.02 60))) ; causes sound to separate and fade
(dotimes (i p)
(setf z (f-sin-osc.ar
(* f (+ 1 i)) ; freq of partial
0
(max 0
(lf-noise1.kr
(+ 6 [(between -4.0 4.0)
(between -4.0 4.0)])
0.02
offset))
z)))
z))
(stop)
;;;
;;;harmonic tumbling
(play (let ((f 80) ; fundamental frequency
(p 10) ; number of partials per channel
(z 0.0) ; start of oscil daisy chain
(trig (x-line.kr [10 10] 0.1 60 ))) ; trigger probability decreases over time
(dotimes (i p)
(setf z (f-sin-osc.ar
(* f (+ 1 i)) ; freq of partial
0
(decay2.kr (dust.kr trig 0.02)
0.005;;grain attack time
(random 0.5))
z)))
z)
(in-package :sc)
(defun linrand (min max)
(+ (* (- max min) (random 1.0)) min))
(defun between (min max)
(+ min (random (- max min))))
(defparameter *my-array* (make-array 15 :initial-element (linrand 80 10000.0)))
*my-array*
(defmacro n-collect (n form &key (initial-element '()))
"return a seq of n elems prepended to initial-element by
evaluating form n times with the symbol n bound to the iteration
index in the lexical scope of form."
"Gib eine Sequenz von n Elementen zurück, die dem Initial-Element vorangestellt sind, indem das Formular n-mal ausgewertet wird, wobei das Symbol n an den Iterationsindex im lexikalischen Gültigkeitsbereich des Formulars gebunden ist."
`(labels
((fn (num seq)
(if (< num ,n)
(cons
(let ((n num)) ,form)
(fn (+ num 1) seq))
seq)))
(fn 0 ,initial-element)))
;; Klank - bank of resonators excited by impulses
(play (let ((freqs '())
(amps '())
(ring-times '())
(z (list freqs amps ring-times)))
(dotimes (p 15)
(push (linrand 80 10080.0) freqs)
(push (random 1.0) amps)
(push (between 0.2 8.0) ring-times))
(pan2.ar (klank.ar z (dust.ar 0.7 0.04)) (random 1.0))))
(stop)
;;;klank - excited by noise bursts
(play (let ((freqs '())
(amps '())
(ring-times '())
(z (list freqs ring-times amps)))
(dotimes (p 8)
(push (linrand 80 10080.0) freqs)
(push (between 0.2 4.0) amps)
(push 0 ring-times))
(klank.ar z (decay.ar (dust.ar 0.6 0.001) 3.1 (white-noise.ar 1)))))
(stop)
(play (rlpf.ar (pulse.ar (max (sin-osc.kr 4 0 1 80) (decay.ar(lf-pulse.ar 0.1 0 0.05 (impulse.ar 8 0 500)) 2))
(lf-noise1.kr 0.157 0.4 0.5) 0.04)
(lf-noise1.kr 0.2 2000 2400) 0.2))
(stop)
;;;what was I thinking?
(play
(let* ((z (rlpf.ar (pulse.ar
(max (sin-osc.kr 4 0 1 80)
(decay.ar (lf-pulse.ar 0.1 0 0.05 (impulse.ar 8 0 500)) 2))
(lf-noise1.kr 0.157 0.4 0.5)
0.04)
(lf-noise1.kr 0.2 2000 2400)
0.2))
(y (* z 0.6)))
(+ z (list (comb-l.ar y 0.06 (lf-noise1.kr (* 0.3 (random 1.0)) 0.025 0.035) 1)
(comb-l.ar y 0.06 (lf-noise1.kr (* 0.3 (random 1.0)) 0.025 0.035) 1)))))
(stop)
;; police state
(play
(let ((n '())
(sirens '()))
(dotimes (n 4)
(setf sirens
(Comb-l.ar
(+ (mix (pan2.ar
(sin-osc.ar
(sin-osc.kr (+ (random 0.1) 0.02)
(random (* 2 pi))
(random 600)
(+ 1000 (random 300)))
0
(lf-noise2.ar (+ 100 (random 20.0)) 0.1))
(random 1.0)))
(lf-noise2.ar (lf-noise2.ar [0.4 0.4] 90 620)
(lf-noise2.kr [0.3 0.3] 0.15 0.18)))
0.3 0.3 3)))
sirens))
(stop)