diff --git a/rsc3/examples/graph/adso.scm b/rsc3/examples/graph/adso.scm new file mode 100644 index 0000000..a315e3e --- /dev/null +++ b/rsc3/examples/graph/adso.scm @@ -0,0 +1,53 @@ +;; adso (rd) + +(import (rnrs) (sosc) (rsc3) (rhs)) + +(define rand-l + (lambda (n l r) + (replicate-m n (random l r)))) + +(define adso + (lambda (n) + (let* ((b-get + (lambda (b n) + (let ((j (make-mce (enum-from-to 0 (- n 1))))) + (buf-rd-n 1 kr b j 0)))) + (m (sin-osc kr (b-get 3 n) 0)) + (f (mul (midi-cps (b-get 0 n)) + (mul-add m (b-get 4 n) 1)))) + (mix (pan2 (sin-osc ar f 0) + (b-get 2 n) + (b-get 1 n)))))) + +(define pattern + (lambda (fd n) + (lambda (t) + (let ((z (map floor + (replicate-m + n (random (random 22 48) + (random 54 122))))) + (rn (lambda (i j k) + (send fd (b-setn1 i 0 (rand-l n j k)))))) + (send fd (b-setn1 0 0 z)) + (rn 1 0 0.1) + (rn 2 -1 1) + (rn 3 2 12) + (rn 4 0.001 0.0075) + (rn 5 1 24) + (rn 6 0.05 (random 0.075 2.4)) + (thread-sleep t))))) + +(let ((n 24)) + (with-sc3 + (lambda (fd) + (for-each + (lambda (i) + (async fd (b-alloc i n 1))) + (enum-from-to 0 6)) + (play fd (out 0 (adso n))) + (map (pattern fd n) + (replicate-m + 32 + (choose + (list 0.025 0.05 0.075 0.1 0.125 2.5)))) + (reset fd)))) diff --git a/rsc3/examples/graph/aleatoric-quartet.scm b/rsc3/examples/graph/aleatoric-quartet.scm new file mode 100644 index 0000000..1574c49 --- /dev/null +++ b/rsc3/examples/graph/aleatoric-quartet.scm @@ -0,0 +1,32 @@ +;; aleatoric quartet (jmcc) + +(import (rnrs) (rsc3) (rhs)) + +(define aleatoric-quartet + (let* ((amp 0.4) + (density (mouse-x kr 0.01 1 0 0.1)) + (dmul (mul (recip density) (mul 0.5 amp))) + (dadd (add (neg dmul) amp)) + (rapf (lambda (i) + (let ((r (mce2 (rand 0 0.05) (rand 0 0.05)))) + (allpass-n i 0.05 r 1)))) + (rapfn (lambda (n i) + ((foldl1 compose (replicate n rapf)) i))) + (mk-f (lambda () + (let* ((i0 (i-rand 0 2)) + (r0 (select i0 (mce3 1 0.5 0.25))) + (r1 (rand -30 30)) + (n0 (lf-noise0 kr r0)) + (m (u:round (mul-add n0 7 (add 66 r1)) 1))) + (midi-cps (lag m 0.2))))) + (mk-s (lambda (_) + (let* ((f (recip (mk-f))) + (r (rand -1 1)) + (n0 (pink-noise ar)) + (n1 (lf-noise1 kr 8)) + (x (mul n0 (u:max 0 (mul-add n1 dmul dadd))))) + (pan2 (comb-l x 0.02 f 3) r 1)))) + (g (mix-fill 4 mk-s))) + (leak-dc (rapfn 4 g) 0.995))) + +(audition (out 0 aleatoric-quartet)) diff --git a/rsc3/examples/graph/alien-meadow.scm b/rsc3/examples/graph/alien-meadow.scm new file mode 100644 index 0000000..2e8c8c4 --- /dev/null +++ b/rsc3/examples/graph/alien-meadow.scm @@ -0,0 +1,13 @@ +;; alien meadow (jmcc) + +(import (rsc3) (rsc3 lang)) + +(define alien-meadow + (let* ((a (rand 0 20)) + (b (rand 0 5000)) + (c (rand 0 20)) + (p (rand -1 1)) + (f (add (mul3 (sin-osc ar a 0) b 0.1) b))) + (pan2 (sin-osc ar f 0) p (mul-add (sin-osc ar c 0) 0.05 0.05)))) + +(with-sc3 (overlap-texture-u (list 2 6 6 +inf.0) alien-meadow)) diff --git a/rsc3/examples/graph/analog-bubbles.scm b/rsc3/examples/graph/analog-bubbles.scm new file mode 100644 index 0000000..761f83a --- /dev/null +++ b/rsc3/examples/graph/analog-bubbles.scm @@ -0,0 +1,11 @@ +;; analog bubbles (jmcc) + +(import (rnrs) (rsc3)) + +(define analog-bubbles + (let* ((o (mul-add (lf-saw kr (mce2 8 7.23) 0) 3 80)) + (f (mul-add (lf-saw kr 0.4 0) 24 o)) + (s (mul (sin-osc ar (midi-cps f) 0) 0.04))) + (comb-n s 0.2 0.2 4))) + +(audition (out 0 analog-bubbles)) diff --git a/rsc3/examples/graph/babbling-brook.scm b/rsc3/examples/graph/babbling-brook.scm new file mode 100644 index 0000000..ce35595 --- /dev/null +++ b/rsc3/examples/graph/babbling-brook.scm @@ -0,0 +1,15 @@ +;; babbling brook (jmcc) + +(import (rnrs) (rsc3)) + +(define babbling-brook + (let* ((b (lambda (f m a g) + (let* ((n1 (brown-noise ar)) + (n2 (brown-noise ar)) + (n3 (mul-add (lpf n2 f) m a))) + (mul (rhpf (one-pole n1 0.99) n3 0.03) g)))) + (x (clone 2 (b 14 400 500 0.024))) + (y (clone 2 (b 20 800 1000 0.040)))) + (add x y))) + +(audition (out 0 babbling-brook)) diff --git a/rsc3/examples/graph/bit-reduction.scm b/rsc3/examples/graph/bit-reduction.scm new file mode 100644 index 0000000..564dac6 --- /dev/null +++ b/rsc3/examples/graph/bit-reduction.scm @@ -0,0 +1,18 @@ +;; bit reduction (adc) + +(import (rsc3)) + +(let* ((f (lf-noise2 kr 8)) + (nh (lf-noise2 kr 3)) + (src (blip ar (mul-add f 200 300) (mul-add nh 10 20))) + (sr (mouse-x* kr 1000 (mul sample-rate 0.1) 1 0.2))) + (audition (out 0 (latch src (impulse ar sr 0))))) + +(let* ((f (lf-noise2 kr 8)) + (nh (lf-noise2 kr 3)) + (src (blip ar (mul-add f 200 300) (mul-add nh 10 20))) + (sr (mouse-x* kr 1000 (mul sample-rate 0.1) 1 0.2)) + (bit-sz (mouse-y* kr 1 24 1 0.2)) + (down-sample (latch src (impulse ar sr 0))) + (bit-redux (u:round down-sample (pow 0.5 bit-sz)))) + (audition (out 0 (mce2 down-sample bit-redux)))) diff --git a/rsc3/examples/graph/bottle.scm b/rsc3/examples/graph/bottle.scm new file mode 100644 index 0000000..3ef36f1 --- /dev/null +++ b/rsc3/examples/graph/bottle.scm @@ -0,0 +1,26 @@ +;; bottle (sc) + +(import (rnrs) (rsc3) (rhs)) + +(define bottle + (let* ((freq (rand 220 880)) + (perc (env-perc 0.1 0.6 1 (list -4 -4))) + (flute (ringz (mul (env-gen kr 1 1 0 1 0 perc) + (mul (white-noise ar) 0.02)) + freq + 0.3)) + (breath (mul (env-gen kr 1 1 0 1 0 perc) + (resonz (pink-noise ar) + (add 5 (fdiv freq 2)) + 0.1))) + (rapf (lambda (i) + (let ((f (allpass-n i 0.1 (lin-rand 0.001 0.1 -1) 1.0))) + (add i (mul f 0.5))))) + (close (lambda (i) + (let* ((l (env-linen 0.01 3.0 1.0 1 (replicate 3 -4))) + (z (mul (add breath i) + (env-gen kr 1 1 0 1 2 l)))) + (mce2 z z))))) + (close ((foldl1 compose (replicate 2 rapf)) flute)))) + +(audition (out 0 bottle)) diff --git a/rsc3/examples/graph/bowed-string.scm b/rsc3/examples/graph/bowed-string.scm new file mode 100644 index 0000000..2d55dca --- /dev/null +++ b/rsc3/examples/graph/bowed-string.scm @@ -0,0 +1,27 @@ +;; bowed string (jmcc) + +(import (rnrs) (rsc3) (rhs)) + +(define series + (lambda (f n x i) + (if (= n 0) + nil + (cons x (series f (- n 1) (f x i) i))))) + +(define bowed-string + (let* ((root 5) + (scale (map (lambda (n) (+ n root)) (list 0 2 4 5 7 9 11))) + (oct (list 24 36 48 60 72 84)) + (choose (lambda (l) (select (i-rand 0 (length l)) (make-mce l)))) + (f (midi-cps (add (choose scale) (choose oct)))) + (n0 (clone 2 (brown-noise ar))) + (r0 (exp-rand 0.125 0.5)) + (n1 (lf-noise1 kr r0)) + (r1 (rand 0.7 0.9)) + (r2 (replicate-m 12 (rand 1.0 3.0))) + (x (mul3 n0 0.007 (u:max 0 (mul-add n1 0.6 0.4)))) + (d (klank-data (series add 12 f f) (series mul 12 1 r1) r2)) + (k (klank x 1 0 1 d))) + (soft-clip (mul k 0.1)))) + +(audition (out 0 bowed-string)) diff --git a/rsc3/examples/graph/ccomb.scm b/rsc3/examples/graph/ccomb.scm new file mode 100644 index 0000000..6778dbc --- /dev/null +++ b/rsc3/examples/graph/ccomb.scm @@ -0,0 +1,20 @@ +;; ccomb (rd) + +(import (rnrs) (rsc3)) + +(define ccomb + (let* ((rng (lambda (u l r) (lin-lin u -1 1 l r))) + (lwr 48) + (flwr (midi-cps 48)) + (spart (lambda (t) + (let* ((n (rng (lf-noise2 kr 0.1) lwr 72)) + (e (decay2 t 0.01 (t-rand 0.05 0.75 t))) + (x (mul (white-noise ar) e)) + (m (lf-noise2 kr 0.1)) + (f (lag (midi-cps n) 0.25))) + (comb-c x (recip flwr) (recip f) (rng m 1.0 8.0))))) + (t (dust ar (mce2 0.9 0.8)))) + (mix-fill 7 (lambda (_) (mul (spart t) 0.1))))) + +(audition (out 0 ccomb)) + diff --git a/rsc3/examples/graph/chain-saw.scm b/rsc3/examples/graph/chain-saw.scm new file mode 100644 index 0000000..bb9f712 --- /dev/null +++ b/rsc3/examples/graph/chain-saw.scm @@ -0,0 +1,48 @@ +;; chain saw (jrhb) + +(import (rnrs) (rsc3) (rhs)) + +;; SimpleNumber.coin (not UGen/Coin) +(define coin* + (lambda (n a b) + (if (> (random 0.0 1.0) n) a b))) + +(define exp-range + (lambda (s l r) + (lin-exp s -1 1 l r))) + +(define chain + (lambda (n fn) + (foldl1 compose (replicate n fn)))) + +(define mce-product + (mce-edit (lambda (l) (list (foldl1 mul l))))) + +(define clipu + (lambda (s) (clip2 s 1))) + +(define dup + (lambda (a) (mce2 a a))) + +(define mk-f + (lambda (s1) + (let* ((xr (clone 2 (exp-rand 0.1 2))) + (n1 (lf-noise1 kr xr)) + (n2 (lf-noise1 kr xr)) + (n3 (lf-noise1 kr xr)) + (f1 (coin* 0.6 (exp-range n1 0.01 10) (exp-range n2 10 50))) + (s2 (coin* 0.5 (sub 1 s1) (mce-reverse s1))) + (f2 (lin-exp s1 -1 1 f1 (mul f1 (exp-range n3 2 10)))) + (u1 (lf-saw kr f2 0)) + (u2 (mul-add (lf-saw kr (mul f1 0.1) 0) 0.1 1))) + (clipu (coin* 0.5 (mul u1 s2) (mul u1 u2)))))) + +(define chain-saw + (let* ((inp (lf-saw kr (mul 0.2 (mce2 1 1.1)) 0)) + (b-freq (make-mce (list 70 800 9000 5242))) + (ff ((chain 8 mk-f) inp)) + (c-saw (mce-product (saw ar (exp-range ff 6 11000)))) + (b-saw (dup (mix (bpf c-saw b-freq 0.2))))) + (mul b-saw 0.3))) + +(audition (out 0 chain-saw)) diff --git a/rsc3/examples/graph/chrd.scm b/rsc3/examples/graph/chrd.scm new file mode 100644 index 0000000..dce4a7a --- /dev/null +++ b/rsc3/examples/graph/chrd.scm @@ -0,0 +1,22 @@ +;; chrd (rd) + +(import (rnrs) (rsc3)) + +(define chrd + (lambda (_) + (let* ((m (make-mce (list 60 65 72 77 79 84))) + (ds 3) + (d (make-mce (map (lambda (x) (* x ds)) (list 5 4 5 7 4 5)))) + (l (x-line kr m (add m (random 0.05 0.5)) d do-nothing)) + (f (midi-cps l)) + (z (env-trapezoid 0 (rand 0.15 0.35) d (rand 0.005 0.01))) + (e (env-gen kr 1 1 0 1 do-nothing z)) + (p (x-line kr (rand -1 1) (rand -1 1) d do-nothing)) + (o (f-sin-osc ar f 0))) + (mix (pan2 o p e))))) + +(define chrdn + (lambda (n) + (mix-fill n chrd))) + +(audition (out 0 (chrdn 5))) diff --git a/rsc3/examples/graph/cricket.scm b/rsc3/examples/graph/cricket.scm new file mode 100644 index 0000000..10bd48c --- /dev/null +++ b/rsc3/examples/graph/cricket.scm @@ -0,0 +1,21 @@ +;; cricket (rd) + +(import (rnrs) (rsc3)) + +(define cricket + (let* ((m-rand + (lambda (l r) + (mce2 (rand l r) (rand l r)))) + (mt-rand + (lambda (l r t) + (mce2 (t-rand l r t) (t-rand l r t)))) + (r1 (m-rand 10 13)) + (r2 (m-rand 10 13)) + (r3 (m-rand 4 7)) + (t (impulse kr 0.7 0)) + (e (decay2 (impulse kr r1 0) 0.001 0.005)) + (f (mul3 (sin-osc kr r2 0) e r3)) + (r4 (mt-rand 2220 2227 t))) + (mul3 (sin-osc ar r4 0) f 0.25))) + +(audition (out 0 cricket)) diff --git a/rsc3/examples/graph/crotale.scm b/rsc3/examples/graph/crotale.scm new file mode 100644 index 0000000..81a7191 --- /dev/null +++ b/rsc3/examples/graph/crotale.scm @@ -0,0 +1,175 @@ +;; crotale (rd) + +(import (rnrs) (rsc3)) + +(define cf + (list 35.45676040649414 + 128.59849548339844 + 346.9721984863281 + 483.5544128417969 + 1049.2449951171875 + 1564.0279541015625 + 1756.3399658203125 + 3391.666015625 + 3451.802001953125 + 3497.261962890625 + 3596.89794921875 + 3696.739013671875 + 3835.235107421875 + 3845.955078125 + 4254.85107421875 + 4407.533203125 + 4415.26416015625 + 4552.865234375 + 5538.076171875 + 5637.73681640625 + 5690.2978515625 + 5728.0068359375 + 5764.27685546875 + 5824.4189453125 + 6377.60498046875 + 6544.35009765625 + 6807.14404296875 + 6994.97021484375 + 7026.84619140625 + 7144.5859375 + 7269.61279296875 + 7393.6708984375 + 7897.259765625 + 8040.4580078125 + 8157.77099609375 + 8225.01953125 + 9126.150390625 + 9488.529296875 + 9916.408203125 + 10155.599609375 + 11715.9599609375 + 12111.830078125 + 12339.990234375 + 12417.669921875 + 12459.2802734375 + 12618.330078125 + 13116.490234375 + 13201.1298828125 + 13297.830078125 + 13533.75)) + +(define ca + (list 0.0012827360769733787 + 0.0008040848188102245 + 0.017361238598823547 + 0.004835359752178192 + 0.004413491114974022 + 0.004110544919967651 + 0.0003338181704748422 + 0.0036140112206339836 + 0.006919348146766424 + 0.0003224937245249748 + 0.0006031467346474528 + 0.06686479598283768 + 0.000605064386036247 + 0.003602313343435526 + 0.0002835785271599889 + 0.015243238769471645 + 0.020536603406071663 + 0.016677580773830414 + 0.0009245267719961703 + 0.20205098390579224 + 0.0012542791664600372 + 0.012705927714705467 + 0.0002523190632928163 + 0.0004866079252678901 + 0.0006429700297303498 + 0.0007763264584355056 + 0.2081160992383957 + 0.0024918108247220516 + 0.00193469924852252 + 0.005231771152466536 + 0.0069242212921381 + 0.001203975174576044 + 0.2050020843744278 + 0.04060448706150055 + 0.0038344631902873516 + 0.002189427148550749 + 0.18056060373783112 + 0.002192433224990964 + 0.006516554858535528 + 0.009982921183109283 + 0.004745401442050934 + 0.046154771000146866 + 0.000510294979903847 + 0.0018905038014054298 + 0.0019782145973294973 + 0.006729386281222105 + 0.0023426134139299393 + 0.0024002245627343655 + 0.03515550494194031 + 0.0014084168942645192)) + +(define cd + (list 5.203680992126465 + 1.7034343481063843 + 40.16516876220703 + 27.282501220703125 + 0.8950523138046265 + 42.84742736816406 + 2.6603667736053467 + 15.7678861618042 + 6.848367214202881 + 3.2325007915496826 + 1.7343382835388184 + 2.0202419757843018 + 4.7279052734375 + 9.400103569030762 + 0.7102512717247009 + 37.494625091552734 + 36.24879455566406 + 29.172658920288086 + 3.891019344329834 + 4.757885456085205 + 3.851426124572754 + 20.90781021118164 + 3.732874870300293 + 2.3834102153778076 + 10.443285942077637 + 8.795611381530762 + 20.98564338684082 + 18.01180076599121 + 25.297883987426758 + 14.819819450378418 + 42.39189910888672 + 2.9485135078430176 + 11.043763160705566 + 49.55165100097656 + 29.882694244384766 + 10.527188301086426 + 23.5572452545166 + 26.55561637878418 + 45.099605560302734 + 22.550390243530273 + 36.46126174926758 + 11.826201438903809 + 16.818185806274414 + 14.903121948242188 + 32.81113815307617 + 43.1389045715332 + 12.289558410644531 + 11.498942375183105 + 10.465788841247559 + 24.93169593811035)) + +(define crotale + (let* ((ps (make-mce (list -12 -5 0 2 4 5 7 12))) + (n (pink-noise ar)) + (t (dust kr 3)) + (fs (select (ti-rand 0 7 t) ps)) + (g (t-rand 0 1 t)) + (fo (t-rand 0 1 t)) + (ds (t-rand 2 7 t)) + (p (t-rand -1 1 t)) + (s (mul3 (decay2 t 0.06 0.01) n g)) + (kd (klank-data cf ca (map recip cd))) + (k (dyn-klank s (midi-ratio fs) fo ds kd))) + (pan2 k p 1))) + +(audition (out 0 crotale)) diff --git a/rsc3/examples/graph/cut-outs.scm b/rsc3/examples/graph/cut-outs.scm new file mode 100644 index 0000000..1333809 --- /dev/null +++ b/rsc3/examples/graph/cut-outs.scm @@ -0,0 +1,19 @@ +;; cut-outs (rd) + +(import (rnrs) (rsc3)) + +(define cut-outs + (let* ((t (mul (impulse ar 22 0) (add (sin-osc kr 0.5 0) 1))) + (x (mouse-x* kr 0.005 0.12 1 0.1)) + (y (mouse-y* kr 0.01 0.52 1 0.1)) + (n (lambda (_) + (let* ((n1 (lf-noise0 kr 2)) + (n2 (coin-gate (add3 0.05 (mul n1 0.4) y) (mul t 0.5))) + (n3 (t-exp-rand (mce2 500 900) 1600 t))) + (ringz n2 n3 x)))) + (s (mix-fill 3 n)) + (b (t-rand 0 1 (dust kr 8)))) + (make-mrg (mul (clip2 s (in 1 kr 0)) 0.25) + (out 0 b)))) + +(audition (out 0 cut-outs)) diff --git a/rsc3/examples/graph/cymbalism.scm b/rsc3/examples/graph/cymbalism.scm new file mode 100644 index 0000000..3752c55 --- /dev/null +++ b/rsc3/examples/graph/cymbalism.scm @@ -0,0 +1,21 @@ +;; cymbalism (jmcc) + +(import (rnrs) (rsc3) (rhs)) + +(define cymbalism + (let* ((p 15) + (f1 (rand 500 2500)) + (f2 (rand 0 8000)) + (y + (lambda () + (let ((f (replicate-m p (add f1 (rand 0 f2)))) + (rt (replicate-m p (rand 1 5))) + (a (replicate p 1))) + (klank-data f a rt)))) + (z (mce2 (y) (y))) + (t (impulse ar (rand 0.5 3.5) 0)) + (n (mul (white-noise ar) 0.03)) + (s (mul (decay t 0.004) n))) + (klank s 1 0 1 (mce-transpose z)))) + +(audition (out 0 cymbalism)) diff --git a/rsc3/examples/graph/data-space.scm b/rsc3/examples/graph/data-space.scm new file mode 100644 index 0000000..0c1b72a --- /dev/null +++ b/rsc3/examples/graph/data-space.scm @@ -0,0 +1,20 @@ +;; data space (jmcc) + +(import (rsc3) (rsc3 lang)) + +(define data-space + (let* ((r (lambda (n) (rand 0 n))) + (lp (lambda (f m a) (mul-add (lf-pulse kr (r f) 0 (r 1)) m a))) + (p0 (lp 200 1 0)) + (p1 (lp 40 (r 8000) (r 2000))) + (p2 (lp 20 1 0)) + (p3 (lp 4 (r 8000) (r 2000))) + (p4 (lp 20 1 0)) + (p5 (lp 4 (r 8000) (r 2000))) + (f (add3 (mul p0 p1) (mul p2 p3) (mul p4 p5))) + (dt (rand 0.15 0.35)) + (o (mul (lf-pulse ar f 0 0.5) 0.04)) + (l (mul (lf-noise0 kr (r 3)) 0.8))) + (comb-l (pan2 o l 1) dt dt 3))) + +(with-sc3 (overlap-texture-u (list 1 6 4 +inf.0) data-space)) diff --git a/rsc3/examples/graph/deep-sea.scm b/rsc3/examples/graph/deep-sea.scm new file mode 100644 index 0000000..8284ca9 --- /dev/null +++ b/rsc3/examples/graph/deep-sea.scm @@ -0,0 +1,28 @@ +;; deep sea (jrhb) + +(import (rnrs) (rsc3)) + +(define range + (lambda (s l r) + (let ((m (mul (sub r l) 0.5))) + (mul-add s m (add m l))))) + +(define deep-sea + (let* ((amp 1) + (pan 0) + (variation 0.9) + (n (rand 7 46)) + (dt1 (add 25 (rand -1.7 1.7))) + (dt2 (mul3 (add dt1 (lf-noise2 kr 2)) variation 0.001)) + (freq (add 901 (rand 0 65))) + (t (mul (impulse ar (recip dt2) 0) 100)) + (count (pulse-count t 0)) + (ml (lt count n)) + (u1 (mul (bpf (mul ml t) freq 1) 0.1)) + (freq2 (mul freq + (add (u:mod count (range (lf-noise1 kr 1) 2 20)) 1))) + (u2 (mul (bpf u1 freq2 1) 0.2))) + (mrg2 (pan2 u2 pan (mul amp 10)) + (detect-silence u2 0.0001 0.2 remove-synth)))) + +(audition (out 0 deep-sea)) diff --git a/rsc3/examples/graph/demanding-studies.scm b/rsc3/examples/graph/demanding-studies.scm new file mode 100644 index 0000000..0631a30 --- /dev/null +++ b/rsc3/examples/graph/demanding-studies.scm @@ -0,0 +1,17 @@ +;; demanding studies (jmcc) + +(import (rnrs) (rsc3)) + +(define demanding-studies + (let* ((s1 (drand dinf (mce4 72 75 79 82))) + (s2 (drand 1 (mce3 82 84 86))) + (s3 (dseq dinf (mce4 72 75 79 s2))) + (x (mouse-x kr 5 6 0 0.2)) + (tr (impulse kr x 0)) + (f (demand tr 0 (mce2 (midi-cps (sub s1 12)) (midi-cps s3)))) + (o1 (sin-osc ar (add f (mce2 0 0.7)) 0)) + (o2 (mul (saw ar (add f (mce2 0 0.7))) 0.3)) + (o3 (cubed (distort (u:log (distort (add o1 o2))))))) + (mul o3 0.1))) + +(audition (out 0 demanding-studies)) diff --git a/rsc3/examples/graph/dial-history.scm b/rsc3/examples/graph/dial-history.scm new file mode 100644 index 0000000..7515f7c --- /dev/null +++ b/rsc3/examples/graph/dial-history.scm @@ -0,0 +1,42 @@ +;; dial history (jrhb) + +(import (rnrs) (rsc3) (rhs)) + +(define range + (lambda (s l r) + (lin-lin s 0 1 l r))) + +(define mce-r + (lambda (l) + (make-mce (map make-mce l)))) + +(define mce-mrg + (lambda (u) + (mrg-n (mce-channels u)))) + +(define dial-history + (let* ((mfv (transpose (list (list 697 770 852 941) + (list 1209 1336 1477 1633)))) + (numbers (transpose (list (list 3 0 0 0 1 1 1 2 2 2) + (list 1 0 1 2 0 1 2 0 1 2)))) + (n (dwhite dinf 7 12)) + (w (dwhite 1 2 7)) + (b (dbrown n 0.1 0.2 0.01)) + (rt (dseq dinf (mce2 w b))) + (q (dseq dinf (make-mce (enum-from-to 1 10)))) + (g1 (gray-noise ar)) + (g2 (gray-noise ar)) + (d (lfd-noise3 kr 0.5)) + (tr (trig (t-duty kr rt 0 do-nothing q 1) 0.09)) + (pat (latch tr tr)) + (x (mouse-x* kr 0 1 linear 0.2)) + (h (hasher (mul pat x))) + (which (trunc (range h 0 (length numbers)) 1)) + (both (select which (mce-r numbers))) + (dial (select both (mce-r mfv))) + (sig (mul3 (sin-osc ar dial 0) 0.05 tr)) + (dsig (delay-n sig 0.2 (range d 0 0.01))) + (hiss (mul-add g1 0.01 (hpf (mul g2 0.02) 3000)))) + (add dsig hiss))) + +(audition (out 0 dial-history)) diff --git a/rsc3/examples/graph/diffraction.scm b/rsc3/examples/graph/diffraction.scm new file mode 100644 index 0000000..df598ff --- /dev/null +++ b/rsc3/examples/graph/diffraction.scm @@ -0,0 +1,30 @@ +;; diffraction (rd) + +(import (rnrs) (rsc3)) + +(define mk-p + (lambda () + (let* ((x (mouse-x kr 0.001 0.02 1 0.1)) + (y (mouse-y kr 120 400 1 0.1)) + (f (mul (lf-noise0 kr 4) (mce2 32 64))) + (w (mul (lf-noise0 kr 32) x))) + (mul (resonz (pulse ar f w) + (add y (mul (lf-noise0 kr 2) 0.1)) + (mul-add (lf-noise0 kr 6) 0.4 0.8)) + 0.5)))) + +(define diffraction + (let* ((q (comb-n (mk-p) + 0.2 + (mul-add (lf-noise0 kr 128) 0.1 0.1) + 3)) + (r (let* ((x (mouse-x kr 0.75 1.25 1 0.1)) + (y (mouse-y kr 0.25 1 1 0.1)) + (f (lambda (_) + (mul (sin-osc ar (mul x (rand 50 59)) 0) + (mul y (rand 0.04 0.16)))))) + (mce2 (mix-fill 16 f) + (mix-fill 12 f))))) + (add3 (mk-p) q r))) + +(audition (out 0 diffraction)) diff --git a/rsc3/examples/graph/discretion.scm b/rsc3/examples/graph/discretion.scm new file mode 100644 index 0000000..42dd7e8 --- /dev/null +++ b/rsc3/examples/graph/discretion.scm @@ -0,0 +1,20 @@ +;; discretion (rd) + +(import (rnrs) (rsc3) (rhs)) + +(define discretion + (let* ((mkls (lambda (bp t) + (let ((c (replicate (/ (length bp) 2) 1))) + (env-gen kr 1 1 0 1 remove-synth (env-bp bp t 1 c))))) + (part (lambda (_) + (let* ((f1 (clone 2 (rand 50 55))) + (f2 (clone 2 (rand 50 65))) + (f3 (clone 2 (rand 50 55))) + (a (clone 2 (rand 0.01 0.035))) + (t 21) + (f (mkls (list 0.0 f1 0.33 f2 1.0 f3) t)) + (g (mkls (list 0 0 0.33 a 1 0) t))) + (mul (saw ar f) g))))) + (mix-fill 8 part))) + +(audition (out 0 discretion)) diff --git a/rsc3/examples/graph/drummer.scm b/rsc3/examples/graph/drummer.scm new file mode 100644 index 0000000..d71984d --- /dev/null +++ b/rsc3/examples/graph/drummer.scm @@ -0,0 +1,16 @@ +;; drummer (thor magnusson) + +(import (rnrs) (rsc3)) + +(define drummer + (let* ((tempo 4) + (n (white-noise ar)) + (tr (impulse ar tempo 0)) + (tr-2 (pulse-divider tr 4 2)) + (tr-4 (pulse-divider tr 4 0)) + (snare (mul n (decay2 tr-2 0.005 0.5))) + (bass (mul (sin-osc ar 60 0) (decay2 tr-4 0.005 0.5))) + (hihat (mul (hpf n 10000) (decay2 tr 0.005 0.5)))) + (pan2 (add3 snare bass hihat) 0 0.4))) + +(audition (out 0 drummer)) diff --git a/rsc3/examples/graph/e-lamell.scm b/rsc3/examples/graph/e-lamell.scm new file mode 100644 index 0000000..b5579f2 --- /dev/null +++ b/rsc3/examples/graph/e-lamell.scm @@ -0,0 +1,52 @@ +;; e-lamell (rd) + +(import (rnrs) (sosc) (rsc3)) + +(define e-lamell + (letc ((f 440) (n 12) (d 0.1) (p 0) (a 1.0)) + (let* ((h (line ar n (t-choose 1 (mce2 1 32)) d do-nothing)) + (s (blip ar f h)) + (e-d (env-perc 0.005 d 1 (list -4 -4))) + (e (env-gen ar 1 a 0 1 remove-synth e-d))) + (out 0 (pan2 s p e))))) + +(define r-note + (lambda (o p) + (+ (* (choose o) 12) + (choose p)))) + +(define l-sel + (lambda () + (r-note (list 2 3) + (list 0)))) + +(define h-sel + (lambda () + (r-note (list 2 3 4) + (list 0)))) + +(define pattern + (lambda (fd) + (send + fd + (bundle + -1 + (list (s-new "blip" -1 add-to-tail 1 + (list "f" (midi-cps (l-sel)) + "n" (i-random 2 36) + "d" (exp-random 0.01 0.4) + "a" (random 0 0.75) + "p" (random -1 1))) + (s-new "blip" -1 add-to-tail 1 + (list "f" (midi-cps (h-sel)) + "n" (i-random 2 36) + "d" (exp-random 0.01 0.4) + "a" (choose (list 0 0.25 0.5 1.0)) + "p" (random -1 1)))))) + (thread-sleep 0.1) + (pattern fd))) + +(with-sc3 + (lambda (fd) + (send-synth fd "blip" e-lamell) + (pattern fd))) diff --git a/rsc3/examples/graph/eggcrate.scm b/rsc3/examples/graph/eggcrate.scm new file mode 100644 index 0000000..f7adb8a --- /dev/null +++ b/rsc3/examples/graph/eggcrate.scm @@ -0,0 +1,20 @@ +;; eggcrate (rd) + +(import (rnrs) (rsc3)) + +(define eggcrate-f + (lambda (u v) + (mul (u:cos (mul u pi)) (u:sin (mul v pi))))) + +(define eggcrate + (let* ((p (make-mce (list 64 72 96 128 256 6400 7200 8400 9600))) + (x (brown-noise kr)) + (y (brown-noise kr)) + (t (dust kr 2.4)) + (f0 (t-choose t p)) + (f1 (t-choose t p)) + (f (lin-lin (eggcrate-f x y) -1 1 f0 f1)) + (a (lin-lin x -1 1 0 0.1))) + (pan2 (mix (sin-osc ar f 0)) y a))) + +(audition (out 0 eggcrate)) diff --git a/rsc3/examples/graph/f-lets.scm b/rsc3/examples/graph/f-lets.scm new file mode 100644 index 0000000..d6d0ad2 --- /dev/null +++ b/rsc3/examples/graph/f-lets.scm @@ -0,0 +1,29 @@ +;; f-lets (rd) + +(import (rnrs) (rsc3) (rhs)) + +(define f + (lambda (t g j n f) + (let ((pd (pulse-divider t j 0))) + (mul (formlet pd + (mul f (ti-rand (mce2 2 1) n pd)) + (t-rand 0.01 0.04 pd) + (t-rand 0.05 0.10 pd)) + g)))) + +(define n + (lambda (t) + (list (f t 0.15 2 9 (mce2 200 400)) + (f t 0.25 2 9 (mce2 (add 200 (t-rand 0 1 t)) + (add 400 (t-rand 0 1 t)))) + (f t 0.05 4 5 (mce2 25 50)) + (f t 0.15 4 5 (mce2 (add 25 (t-rand 0 1 t)) + (add 50 (t-rand 0 1 t)))) + (mul (f t 0.5 1 16 (mce2 300 600)) + (latch (coin-gate 0.2 t) t))))) + +(define f-lets + (mul (mul-add (lf-noise0 kr 2) 0.25 0.25) + (foldl1 add (n (impulse ar 24 0))))) + +(audition (out 0 f-lets)) diff --git a/rsc3/examples/graph/feedr.scm b/rsc3/examples/graph/feedr.scm new file mode 100644 index 0000000..16b9ef3 --- /dev/null +++ b/rsc3/examples/graph/feedr.scm @@ -0,0 +1,39 @@ +;; feedr (rd) +;; warning: input/output feedback loop + +(import (sosc) (rsc3) (rhs)) + +(with-sc3 + (lambda (fd) + (let* ((delay-wr + (lambda (b in) + (record-buf b 0 1 0 1 1 0 in))) + (tap + (lambda (nc b delay-time) + (play-buf nc b 1 0 (mul delay-time (neg sample-rate)) 1))) + (dl 6) + (ff (* dl (server-sample-rate-actual fd))) + (nc 2)) + (send fd (b-alloc 10 ff nc)) + (audition + (let* ((n 18) + (t (replicate-m n (rand 0.0 dl))) + (g (replicate-m n (rand 0.4 1.0))) + (f (replicate-m n (rand 0.9 0.95))) + (d (zip-with + (lambda (t g) + (mul (tap nc 10 t) g)) + t g)) + (x (mouse-x* kr 0.02 1.0 1 0.1))) + (make-mrg + (out 0 (clip2 (leak-dc (hpf (foldl1 add d) 20) 0.995) 1)) + (delay-wr 10 (foldl add + (in nc ar num-output-buses) + (map + (lambda (e) + (mul e x)) + (zip-with mul d f)))))))))) + +(with-sc3 + (lambda (fd) + (send fd (b-zero 10)))) diff --git a/rsc3/examples/graph/fm-iter.scm b/rsc3/examples/graph/fm-iter.scm new file mode 100644 index 0000000..1405d0e --- /dev/null +++ b/rsc3/examples/graph/fm-iter.scm @@ -0,0 +1,20 @@ +;; fm-iter (rd) + +(import (rnrs) (rsc3)) + +(define fm-iter + (let* ((t0 (impulse ar (recip 0.30) 0)) + (t1 (t-delay t0 0.15)) + (t (mce2 t0 t1)) + (k (t-rand 56 57 t)) + (i (t-rand 40 480 t)) + (j (t-rand -1 1 t)) + (c (midi-cps k)) + (m (midi-cps (add3 k 1 j))) + (s (env-perc 0.01 0.9 1 (list -4 -4))) + (e (env-gen ar t 0.1 0 1 remove-synth s)) + (f (mul-add (sin-osc ar c 0) i m))) + (mul (sin-osc ar f 0) e))) + +(audition (out 0 fm-iter)) + diff --git a/rsc3/examples/graph/fm-kltr.scm b/rsc3/examples/graph/fm-kltr.scm new file mode 100644 index 0000000..0ada7d2 --- /dev/null +++ b/rsc3/examples/graph/fm-kltr.scm @@ -0,0 +1,93 @@ +;; fm-kltr (rd) + +(import (rnrs) (sosc) (rsc3) (rhs)) + +(define fm-instr + (letc ((bus 0) + (trig 0) + (amp 0.1) + (dur 0.1) + (freq 400) + (index 40) + (pan 0) + (freq2 600)) + (let* ((p (env-perc 0.01 dur 1 (replicate 2 -4))) + (e (env-gen ar 1 amp 0 1 remove-synth p)) + (x (x-line kr freq (mul freq (random 0.975 1.025)) dur 0)) + (o (sin-osc ar x 0)) + (l (line kr index (mul freq (random 0.5 1.5)) dur 0)) + (x2 (x-line kr freq2 (mul freq2 (random 0.975 1.025)) dur 0)) + (m (mul-add o l x2))) + (out bus (pan2 (sin-osc ar m 0) + (line kr pan (mul pan (random 0.75 1.25)) dur 0) + e))))) + +(define fm + (lambda (fd f ff a d i) + (send + fd + (s-new "fm" -1 1 1 + (list "freq" (midi-cps f) + "freq2" (+ (midi-cps ff) (random -1 1)) + "amp" a + "dur" d + "index" i))))) + +(define r-note + (lambda (o p) + (+ (* (choose o) 12) + (choose p)))) + +(define low-f + (lambda (fd) + (fm + fd + (r-note (list 3 5) + (list 0 3 7 8)) + (random 36 72) + (random 0.0 0.2) + (random 1.2 7.2) + (random 240 1480)))) + +(define high-f + (lambda (fd) + (fm + fd + (r-note (list 7 10) + (list 0 2 5 10)) + (random 84 120) + (random 0.1 0.6) + (random 0.2 1.2) + (random 240 1480)))) + +(define cmp-f + (lambda (a b) + (compare (car a) (car b)))) + +(define low-t + (integrate + (cons 0 + (replicate-m + 36 + (choose (list 0.25 0.5 0.75 1.0 1.5)))))) + +(define high-t + (integrate + (cons 0 + (replicate-m + 36 + (choose (list 0.05 0.15 0.25 0.5 0.75)))))) + +(define fm-kltr + (lambda (fd) + (send-synth fd "fm" fm-instr) + (map1 + (lambda (x) + ((cadr x) fd) + (thread-sleep (car x))) + (sort-by + cmp-f + (append2 (map1 (lambda (x) (list x low-f)) low-t) + (map1 (lambda (x) (list x high-f)) high-t)))))) + +(with-sc3 fm-kltr) diff --git a/rsc3/examples/graph/forest-sounds.scm b/rsc3/examples/graph/forest-sounds.scm new file mode 100644 index 0000000..bd6c395 --- /dev/null +++ b/rsc3/examples/graph/forest-sounds.scm @@ -0,0 +1,16 @@ +;; forest sounds (paul jones) + +(import (rnrs) (rsc3)) + +(define insects + (lambda (_) + (let* ((n1 (brown-noise ar)) + (n2 (lf-noise2 kr 50)) + (f (mul-add n2 50 50)) + (o (mul-add (sin-osc kr f 0) 100 2000))) + (mul (bpf n1 o 0.001) 10)))) + +(define forest-sounds + (mce-fill 2 insects)) + +(audition (out 0 forest-sounds)) diff --git a/rsc3/examples/graph/fwalk.scm b/rsc3/examples/graph/fwalk.scm new file mode 100644 index 0000000..007f3b4 --- /dev/null +++ b/rsc3/examples/graph/fwalk.scm @@ -0,0 +1,32 @@ +;; fwalk (rd) + +(import (rnrs) (sosc) (rsc3) (rhs)) + +(define fwalk-i + (lambda (r) + (let* ((t (dust kr 3)) + (r1 (ti-rand 0 6 t)) + (r2 (t-rand -0.0001 0.0001 t)) + (f (buf-rd-l 1 kr (mce2 0 1) r1 no-loop)) + (o1 (blip ar (midi-cps (add r f)) 12)) + (o2 (blip ar (midi-cps (add3 r f r2)) 12))) + (mul3 (add o1 o2) (decay2 t 0.3 1.2) 0.1)))) + +(define fwalk + (let* ((n (list 40.0 47.0 42.0 40.0 50.0 + 43.0 35.0 43.0 40.0 47.0 + 45.0 35.0 43.0 42.0 59.0 + 48.0 40.0 47.0 52.0 45.0)) + (m (list 40.0 40.0 42.0 47.0 50.0 + 35.0 43.0 43.0 40.0 45.0 + 42.0 35.0 48.0 47.0 43.0 + 40.0 59.0 45.0 47.0 52.0)) + (a (map (lambda (b) (b-alloc b 20 1)) (list 0 1))) + (s (zip-with (lambda (b d) (b-setn1 b 0 d)) (list 0 1) (list n m)))) + (lambda (fd) + (for-each (lambda (m) (async fd m)) a) + (for-each (lambda (m) (send fd m)) s) + (play fd (out 0 (add (fwalk-i 24) (fwalk-i 36))))))) + +(with-sc3 fwalk) + diff --git a/rsc3/examples/graph/h-chatter.scm b/rsc3/examples/graph/h-chatter.scm new file mode 100644 index 0000000..11c4e22 --- /dev/null +++ b/rsc3/examples/graph/h-chatter.scm @@ -0,0 +1,33 @@ +;; h-chatter (rd) + +(import (rnrs) (rsc3)) + +(define wrp + (lambda (i l r) + (let ((m (fdiv (sub r l) 2))) + (mul-add i m (add l m))))) + +(define h0 + (let* ((n (mul-add (lf-noise0 kr 1) 5 5)) + (a (mul-add (lf-noise2 kr n) 0.20 1.20)) + (b (mul-add (lf-noise2 kr n) 0.15 0.15)) + (f 40) + (h (henon-n ar (mce2 f (mul f 0.5)) a b 0 0))) + (mul (saw ar (mul-add h 3200 1600)) 0.35))) + +(define h1 + (let* ((n0 (lf-noise0 ar 32)) + (n1 (lf-noise0 ar 2)) + (a (mouse-x* kr 1.2 1.4 0 0.1)) + (b (mouse-y* kr 0.2 0.3 0 0.1)) + (h (wrp n0 1 32)) + (p (wrp n1 2400 3200)) + (l (wrp n1 -0.75 0.75)) + (g (wrp n1 0.55 0.85)) + (f 40) + (o (blip ar (wrp (henon-n ar f a b 0 0) p (mul p 2)) h))) + (mul (pan2 o l g) 0.35))) + +(define h-chatter (add h0 h1)) + +(audition (out 0 h-chatter)) diff --git a/rsc3/examples/graph/half-life.scm b/rsc3/examples/graph/half-life.scm new file mode 100644 index 0000000..4791d48 --- /dev/null +++ b/rsc3/examples/graph/half-life.scm @@ -0,0 +1,12 @@ +;; half-life (jrhb) + +(import (rnrs) (rsc3)) + +(define half-life + (let* ((t-half 3.92) + (n-atoms 1e+5) + (n (u:max 0 (sub n-atoms (pulse-count (local-in 2 ar) 0)))) + (activity (dust ar (mul n (fdiv (log 2) t-half))))) + (mrg2 activity (local-out activity)))) + +(audition (out 0 half-life)) diff --git a/rsc3/examples/graph/harmonic-swimming.scm b/rsc3/examples/graph/harmonic-swimming.scm new file mode 100644 index 0000000..41a2c4a --- /dev/null +++ b/rsc3/examples/graph/harmonic-swimming.scm @@ -0,0 +1,19 @@ +;; harmonic swimming (jmcc) + +(import (rnrs) (rsc3)) + +(define harmonic-swimming + (let* ((a 0.02) + (f 50) + (p 20) + (z 0) + (l (line kr 0 (neg a) 60 0)) + (o (lambda (h) + (let* ((r (clone 2 (rand 2 8))) + (n (lf-noise1 kr r)) + (e (u:max 0 (mul-add n a l)))) + (mul (f-sin-osc ar (* f (+ h 1)) 0) e))))) + (mix-fill p o))) + +(audition (out 0 harmonic-swimming)) + diff --git a/rsc3/examples/graph/harmonic-tumbling.scm b/rsc3/examples/graph/harmonic-tumbling.scm new file mode 100644 index 0000000..498110a --- /dev/null +++ b/rsc3/examples/graph/harmonic-tumbling.scm @@ -0,0 +1,16 @@ +;; harmonic tumbling (jmcc) + +(import (rnrs) (rsc3)) + +(define harmonic-tumbling + (let* ((f 80) + (p 10) + (t (x-line kr (mce2 10 11) 0.1 60 0)) + (o (lambda (h) + (let* ((n (dust kr t)) + (r (rand 0.25 0.5)) + (e (decay2 (mul n 0.02) 0.005 r))) + (mul (f-sin-osc ar (* f (+ h 1)) 0) e))))) + (mix-fill p o))) + +(audition (out 0 harmonic-tumbling)) diff --git a/rsc3/examples/graph/hh-808.scm b/rsc3/examples/graph/hh-808.scm new file mode 100644 index 0000000..bda8248 --- /dev/null +++ b/rsc3/examples/graph/hh-808.scm @@ -0,0 +1,42 @@ +;; hh-808 (ryan at wabdo.com) + +(import (rnrs) (rhs) (rsc3)) + +(define hh-808 + (let* ((time 250) + (freqs (list 205.35 304.41 369.64 522.71 540.54 812.21)) + (pulse-env + (let ((e (env (list 1.0 0.6) (list time) (list -0.5) 0 0))) + (env-gen ar 1 1 0 (/ 1 1000) do-nothing e))) + (s (let ((f (make-mce (map (lambda (x) (mul x 4.09)) freqs)))) + (mix (lf-pulse ar f 0 0.5)))) + (f (list + (lambda (a) + (add3 (mul (eq a 6.0) 0.6) + (mul (eq a 2.0) 0.2) + (mul (eq a 1.0) 0.9))) + (lambda (a) + (add (mul a pulse-env) + (mul (mix (lf-pulse ar (make-mce freqs) 0 0.55)) 0.9))) + (lambda (a) + (rlpf a 7000 0.6)) + (lambda (a) + (rhpf a 6800 1.5)) + (lambda (a) + (rhpf a 6800 1.5)) + (lambda (a) + (rhpf a 1200 1.5)) + (lambda (a) + (add a (free-verb a 0.33 0.5 0.5))) + (lambda (a) + (let* ((c (list 0 -0.5 0 -50)) + (e (env (list 0 1 0.4 0 0) + (list 2 time 50 500) + c 0 0))) + (mul a (env-gen ar 1 1 0 (/ 1 1000) remove-synth e)))) + (lambda (a) + (mce2 a (delay-n a 0.005 0.005))))) + (>>> (flip compose))) + (mul ((foldl1 >>> f) s) 2))) + +(audition (out 0 hh-808)) diff --git a/rsc3/examples/graph/implosion.scm b/rsc3/examples/graph/implosion.scm new file mode 100644 index 0000000..33b9ee3 --- /dev/null +++ b/rsc3/examples/graph/implosion.scm @@ -0,0 +1,29 @@ +;; implosion (rd) + +(import (rnrs) (rsc3) (rhs)) + +(define implosion + (let* ((mkls + (lambda (bp t) + (env-gen kr 1 1 0 1 remove-synth (env-bp-linear bp t 1)))) + (mkrmp + (lambda (l r t) + (mkls (list 0 l 1 r) t))) + (wrp + (lambda (i l r) + (let ((m (fdiv (sub r l) 2))) + (mul-add i m (add l m))))) + (pmr/n + (lambda (rt l0 l1 r0 r1 d) + (let ((le (mkrmp l0 r0 d)) + (re (mkrmp l1 r1 d))) + (wrp (white-noise rt) le re)))) + (d (rand 7.5 13.5)) + (f0 (rand 10990 16220)) + (f1 (rand 9440 19550)) + (f (pmr/n ar 440 f0 f1 f1 d)) + (l (pmr/n kr (rand -1 0) (rand 0 1) 0 0 d)) + (a (pmr/n kr 0.1 0.6 0 0 d))) + (pan2 (saw ar f) l a))) + +(audition (out 0 implosion)) diff --git a/rsc3/examples/graph/k-ppr.scm b/rsc3/examples/graph/k-ppr.scm new file mode 100644 index 0000000..4bfd436 --- /dev/null +++ b/rsc3/examples/graph/k-ppr.scm @@ -0,0 +1,28 @@ +;; k-ppr (rd) + +(import (rnrs) (rsc3)) + +(define wrp + (lambda (i l r) + (lin-lin i -1 1 l r))) + +(define stream + (lambda (y ti t lf rf ld rd g) + (lambda (_) + (let* ((r1 (rand 9 18)) + (t* (pulse-divider t r1 0)) + (r2 (t-rand lf (wrp ti lf rf) t*)) + (r3 (t-rand ld rd t*))) + (mul (ringz (decay2 t* 0.01 0.5) r2 (mul r3 y)) g))))) + +(define k-ppr + (let* ((x (mouse-x kr 0.05 0.35 0 0.1)) + (y (mouse-y kr 0.15 0.75 0 0.1)) + (ti (lf-tri kr x 0)) + (tf (wrp ti 100 200)) + (t (impulse ar tf 0)) + (s1 (stream y ti t 3140 6240 0.050 0.005 0.15)) + (s2 (stream y ti t 0400 9000 0.005 0.005 0.15))) + (add (mce-fill 2 s1) (mce-fill 2 s2)))) + +(audition (out 0 k-ppr)) diff --git a/rsc3/examples/graph/karplus-strong.scm b/rsc3/examples/graph/karplus-strong.scm new file mode 100644 index 0000000..68254fc --- /dev/null +++ b/rsc3/examples/graph/karplus-strong.scm @@ -0,0 +1,64 @@ +;; karplus strong (alex mclean) + +(import (rnrs) (sosc) (rsc3)) + +(define a-a + (list "a-a" + (list 800 1150 2800 3500 4950) + (list 0 -4 -20 -36 -60) + (list 80 90 120 130 140))) + +(define a-u + (list "a-u" + (list 325 700 2530 3500 4950) + (list 0 -12 -30 -40 -64) + (list 50 60 170 180 200))) + +(define cs + (lambda (l) + (append (list-ref l 1) + (list-ref l 2) + (list-ref l 3)))) + +(define vf + (lambda (i s) + (let ((f (in 5 kr i)) + (a (in 5 kr (add i 5))) + (b (in 5 kr (add i 10)))) + (mix (mul (resonz s f (fdiv b f)) (db-amp a)))))) + +(define ugen-if + (lambda (a b c) + (add (mul a b) (mul (sub 1 a) c)))) + +(define prob-switch + (lambda (n0 i prob) + (ugen-if (gt n0 prob) i (neg i)))) + +(define ks + (lambda (n d) + (let* ((x (mouse-x kr 0 0.01 linear 0.1)) ;; {- delay -} + (y (mouse-y kr 0.85 1 linear 0.1)) ;; {- blend / gain -} + (n0 (add (fdiv n 2) 0.5)) + (lagged-delay (lag x 0.01)) + (o (sin-osc ar 200 0)) + (a0 (mul (decay d 0.025) o)) + (a1 (add (local-in 1 ar) (mul a0 (sub y 0.25)))) + (a2 (delay-n a1 0.01 lagged-delay)) + (a3 (delay1 a2)) + (a4 (fdiv (add a2 a3) 2.0)) + (a5 (prob-switch n0 a4 y)) + (a6 (vf (mul (toggle-ff d) 15) a5)) + (a7 (mul a6 1.5))) + (mrg2 (local-out (mul a5 0.99)) + (out 0 (mce2 a7 a7)))))) + +(define karplus-strong + (lambda (fd) + (send fd (c-setn1 0 (cs a-a))) + (send fd (c-setn1 15 (cs a-u))) + (let ((n (white-noise ar)) + (d (dust kr 4))) + (play fd (ks n d))))) + +(with-sc3 karplus-strong) diff --git a/rsc3/examples/graph/klink.scm b/rsc3/examples/graph/klink.scm new file mode 100644 index 0000000..471e6a6 --- /dev/null +++ b/rsc3/examples/graph/klink.scm @@ -0,0 +1,18 @@ +;; klink (rd) + +(import (rnrs) (rsc3)) + +(define klink + (let* ((n1 (lf-noise0 kr (mce2 0.5 1.5))) + (o (sin-osc kr n1 0)) + (f (mce2 2 3)) + (a (mul (u:abs (slope o)) f)) + (t (impulse ar a 0)) + (i (decay2 t 0.01 0.1)) + (x (mouse-x kr 960 3620 1 0.1)) + (y (mouse-y kr 0.5 2.0 0 0.2)) + (n2 (t-rand x 3940 t)) + (n3 (t-rand 0.005 0.275 t))) + (ringz i n2 (mul n3 y)))) + +(audition (out 0 klink)) diff --git a/rsc3/examples/graph/lf-pulses.scm b/rsc3/examples/graph/lf-pulses.scm new file mode 100644 index 0000000..2c269df --- /dev/null +++ b/rsc3/examples/graph/lf-pulses.scm @@ -0,0 +1,13 @@ +;; lf pulses (rd) + +(import (rnrs) (rsc3)) + +(define lf-pulses + (let* ((n0 (lf-noise0 ar (mce2 20 40))) + (n1 (lf-noise0 ar (mce2 5 10))) + (x (mouse-x kr 0.012 0.19 1 0.1)) + (f (formlet (blip ar 10 12) (mul-add n0 43 700) 0.005 x)) + (o (mul (sin-osc ar 40 0) n1))) + (clip2 (add f o) 1))) + +(audition (out 0 lf-pulses)) diff --git a/rsc3/examples/graph/lfo-modulation.scm b/rsc3/examples/graph/lfo-modulation.scm new file mode 100644 index 0000000..91c886e --- /dev/null +++ b/rsc3/examples/graph/lfo-modulation.scm @@ -0,0 +1,11 @@ +;; lfo modulation (jmcc) + +(import (rnrs) (rsc3)) + +(define lfo-modulation + (let* ((o (mul-add (f-sin-osc kr 0.05 0) 80 160)) + (p (mul-add (f-sin-osc kr (mce2 0.6 0.7) 0) 3600 4000)) + (s (rlpf (mul (lf-pulse ar o 0 0.4) 0.05) p 0.2))) + (comb-l s 0.3 (mce2 0.2 0.25) 2))) + +(audition (out 0 lfo-modulation)) diff --git a/rsc3/examples/graph/lg-timed.scm b/rsc3/examples/graph/lg-timed.scm new file mode 100644 index 0000000..6877ae4 --- /dev/null +++ b/rsc3/examples/graph/lg-timed.scm @@ -0,0 +1,25 @@ +;; lg-timed (rd) + +(import (rnrs) (rsc3)) + +(define timed + (lambda (r y p) + (let* ((d0 (dser r p)) + (d1 (dcons 0 d0)) + (d2 (dser r y)) + (t (t-duty ar d1 0 remove-synth d2 1))) + (latch t t)))) + +(define lg + (lambda (u) (lag u 0.03))) + +(define lg-timed + (let* ((n (make-mce (list 52 76 66 67 68 69))) + (a (make-mce (list 0.35 0.15 0.04 0.05 0.16 0.07))) + (d (make-mce (list 0.1 0.5 0.09 0.08 0.07 0.3))) + (x (mouse-x kr 0.5 1.25 linear 0.2)) + (tn (lg (timed dinf n (mul d x)))) + (ta (lg (timed dinf a (mul d x))))) + (mul (sin-osc ar (midi-cps tn) 0) ta))) + +(audition (out 0 lg-timed)) diff --git a/rsc3/examples/graph/lin-sosc.scm b/rsc3/examples/graph/lin-sosc.scm new file mode 100644 index 0000000..4696c21 --- /dev/null +++ b/rsc3/examples/graph/lin-sosc.scm @@ -0,0 +1,99 @@ +;; lin-sosc (rd) + +(import (rnrs) (sosc) (rsc3) (rhs)) + +(define two-pi (* 2.0 pi)) + +(define mk-line + (lambda (n l r) + (enum-from-then-to l (+ l (/ (- r l) n)) r))) + +(define geom + (lambda (n i s) + (if (= n 0) + nil + (cons i (geom (- n 1) (* i s) s))))) + +(define mk-xline + (lambda (n l r) + (geom n l (expt (/ r l) (/ 1 n))))) + +(define rng + (lambda (l r) + (let ((m (- l r))) + (lambda (e) + (+ l (* e m)))))) + +(define s-rng + (lambda (l r) + (let* ((m (/ (- l r) 2)) + (n (+ m l))) + (lambda (e) + (+ n (* e m)))))) + +(define cmp + (lambda (f g) + (lambda (n) + (f (g n))))) + +(define tbl-m + (lambda (b) + (play-buf 1 b (mul (mouse-x kr 0.001 1.0 0 0.1) + (buf-rate-scale kr b)) 0 0 1))) + +(define tbl-c + (lambda (b c) + (play-buf 1 b (mul (in 1 kr c) (buf-rate-scale kr b)) 0 0 1))) + +(define settr + (lambda (fd n) + (let* ((freq + (list + (mk-line n 440.0 444.0) + (mk-line n 40.0 16000.0) + (mk-xline n 40.0 16000.0) + (map (cmp (s-rng 20 21000) sin) (mk-line n 0 two-pi)) + (map (cmp (s-rng 20 12000) cos) (mk-line n 0 two-pi)) + (map (cmp (s-rng 20 22000) tan) (mk-line n -0.76 0.76)) + (map (cmp (s-rng 20 90) tan) (mk-line n -0.76 0.76)))) + (ampl + (list + (mk-line n 0.1 1.0) + (mk-line n 1.0 0.1) + (mk-line n 0.5 0.01) + (mk-line n 0.01 0.5) + (mk-xline n 1.0 0.1) + (mk-xline n 0.1 1.0) + (map sin (mk-line n 0.0 two-pi)) + (map cos (mk-line n 0.0 two-pi)) + (map (lambda (n) (* n 0.001)) + (map tan (mk-line n 0.0 two-pi))))) + (f (choose freq)) + (a (choose ampl))) + (send fd (b-setn1 0 0 f)) + (send fd (b-setn1 1 0 a)) + (send fd (c-set1 0 (choose (list 0.005 0.0075 0.01 0.025 0.05 0.075 + 0.1 0.25 0.5 0.75 + 0.8 0.85 1.0 1.005)))) + (choose (list 0.01 0.05 0.1 0.15 0.25 0.5 0.75))))) + +(define lsi + (clip2 (pan2 (mul (sin-osc ar (tbl-m 0) 0) + (tbl-m 1)) + (tbl-c 1 0) + 0.025) + 0.25)) + +(define lin-sosc + (lambda (n) + (lambda (fd) + (async fd (b-alloc 0 n 1)) + (async fd (b-alloc 1 n 1)) + (play fd (out 0 lsi)) + (letrec ((pattern + (lambda (fd) + (thread-sleep (settr fd n)) + (pattern fd)))) + (pattern fd))))) + +(with-sc3 (lin-sosc 1024)) diff --git a/rsc3/examples/graph/lz-bf.scm b/rsc3/examples/graph/lz-bf.scm new file mode 100644 index 0000000..4988bee --- /dev/null +++ b/rsc3/examples/graph/lz-bf.scm @@ -0,0 +1,27 @@ +;; lz-bf (rd) + +(import (rnrs) (rsc3)) + +(define lz-bf-i + (let* ((x (mouse-x kr 1 12 0 0.1)) + (l (lorenz-l ar + sample-rate + (mul-add (lf-noise0 kr x) 2 12) + (mul-add (lf-noise0 kr x) 20 38) + (mul-add (lf-noise0 kr x) 1.5 3) + (mce2 0.025 0.05) + 0.1 0.0 0.0)) + (p (phasor ar + 0 + (mul3 l 24 (buf-rate-scale kr 0)) + 0 + (buf-frames kr 0) 0))) + (buf-rd 1 ar 0 p 0 2))) + +(define lz-bf + (lambda (fn) + (lambda (fd) + (async fd (b-alloc-read 0 fn 0 0)) + (play fd (out 0 lz-bf-i))))) + +(with-sc3 (lz-bf "/home/rohan/data/audio/pf-c5.aif")) diff --git a/rsc3/examples/graph/modal-space.scm b/rsc3/examples/graph/modal-space.scm new file mode 100644 index 0000000..22f29ed --- /dev/null +++ b/rsc3/examples/graph/modal-space.scm @@ -0,0 +1,24 @@ +;; modal space (jmcc) + +(import (rnrs) (sosc) (rsc3)) + +(define modal-space-i + (let* ((x (mouse-x kr 0 15 0 0.1)) + (k (degree-to-key 0 x 12)) + (c (lambda (n r) + (let* ((o (mul (sin-osc ar (midi-cps (add3 r k n)) 0) 0.1)) + (t (lf-pulse ar (midi-cps (mce2 48 55)) 0.15 0.5)) + (f (midi-cps (mul-add (sin-osc kr 0.1 0) 10 r))) + (d (mul (rlpf t f 0.1) 0.1)) + (m (add o d))) + (add (comb-n m 0.31 0.31 2) m)))) + (n (mul (lf-noise1 kr (mce2 3 3.05)) 0.04))) + (mul (add (c n 48) (c n 72)) 0.25))) + +(define modal-space + (lambda (fd) + (async fd (b-alloc 0 7 1)) + (send fd (b-setn1 0 0 (list 0 2 3.2 5 7 9 10))) + (play fd (out 0 modal-space-i)))) + +(with-sc3 modal-space) diff --git a/rsc3/examples/graph/moto-rev.scm b/rsc3/examples/graph/moto-rev.scm new file mode 100644 index 0000000..b343521 --- /dev/null +++ b/rsc3/examples/graph/moto-rev.scm @@ -0,0 +1,10 @@ +;; moto rev (jmcc) + +(import (rnrs) (rsc3)) + +(define moto-rev + (let* ((f (mul-add (sin-osc kr 0.2 0) 10 21)) + (s (lf-pulse ar f (mce2 0 0.1) 0.1))) + (clip2 (rlpf s 100 0.1) 0.4))) + +(audition (out 0 moto-rev)) diff --git a/rsc3/examples/graph/mouse-clatter.scm b/rsc3/examples/graph/mouse-clatter.scm new file mode 100644 index 0000000..77f297e --- /dev/null +++ b/rsc3/examples/graph/mouse-clatter.scm @@ -0,0 +1,23 @@ +;; mouse clatter (rd) + +(import (rnrs) (rsc3)) + +(define mouse-clatter + (let* ((x (mouse-x kr 100 12000 0 0.1)) + (y (mouse-y kr 0.01 0.15 0 0.1)) + (n1 (lf-noise0 kr (mce2 3 3.25))) + (t (impulse kr (mul-add n1 16 18) 0)) + (n2 (t-rand 0.005 y t)) + (n3 (white-noise ar)) + (n4 (t-rand 10 x t)) + (n5 (t-rand 0.0 1.0 t)) + (n6 (t-exp-rand 0.15 1.0 t)) + (e (decay2 t 0.01 n2)) + (o (bpf (mul n3 e) n4 n5)) + (n7 (pv-rand-comb (fft* 10 o) n6 t))) + (add (mul o 0.05) (ifft* n7)))) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (play fd (out 0 mouse-clatter)))) diff --git a/rsc3/examples/graph/nharm.scm b/rsc3/examples/graph/nharm.scm new file mode 100644 index 0000000..3758ef6 --- /dev/null +++ b/rsc3/examples/graph/nharm.scm @@ -0,0 +1,31 @@ +;; nharm (rd) + +(import (rnrs) (rsc3) (rhs)) + +(define nharm + (lambda (n f) + (if (<= n 0) + (list) + (cons f (nharm (- n 1) (add f f)))))) + +(define klg + (lambda (m u) + (let* ((n (i-random 4 u)) + (d (i-random 9 12)) + (a 0.5) + (e (env-gen kr 1 0.9 0 1 remove-synth (env-sine d a))) + (s (klang-data (nharm n (midi-cps (random m (+ m 2)))) + (replicate-m n (random 0.01 0.02)) + (replicate n 0)))) + (pan2 (klang ar 1 0 s) + (random -1 1) + e)))) + +(define pattern + (lambda (fd) + (play fd (out 0 (klg (random 32 92) + (i-random 9 24)))) + (thread-sleep (random 0.25 0.75)) + (pattern fd))) + +(with-sc3 pattern) diff --git a/rsc3/examples/graph/noise-burst-sweep.scm b/rsc3/examples/graph/noise-burst-sweep.scm new file mode 100644 index 0000000..67a38ca --- /dev/null +++ b/rsc3/examples/graph/noise-burst-sweep.scm @@ -0,0 +1,13 @@ +;; noise burst sweep (jmcc) + +(import (rnrs) (rsc3)) + +(define noise-burst-sweep + (let* ((n (clone 2 (white-noise ar))) + (lfo-rate (mouse-x* kr 10 60 1 0.2)) + (amp (u:max 0 (lf-saw kr lfo-rate -1))) + (cfreq (mouse-y* kr 400 8000 1 0.2)) + (freq (mul-add (sin-osc kr 0.2 0) cfreq (mul 1.05 cfreq)))) + (resonz (mul n amp) freq 0.1))) + +(audition (out 0 noise-burst-sweep)) diff --git a/rsc3/examples/graph/one-line.scm b/rsc3/examples/graph/one-line.scm new file mode 100644 index 0000000..aa7803e --- /dev/null +++ b/rsc3/examples/graph/one-line.scm @@ -0,0 +1,11 @@ +;; one-line (lance putnam) + +(import (rnrs) (rsc3)) + +(define one-line + (let* ((lfs (mul-add (lf-saw ar (mce2 1 0.99) (mce2 0 0.6)) 2000 2000)) + (lfs-t (mul (trunc lfs (mce2 400 600)) (mce2 1 -1))) + (f (one-pole (mix lfs-t) 0.98))) + (pan2 (sin-osc ar f 0) 0 0.1))) + +(audition (out 0 one-line)) diff --git a/rsc3/examples/graph/oscillator-cluster.scm b/rsc3/examples/graph/oscillator-cluster.scm new file mode 100644 index 0000000..ce384d7 --- /dev/null +++ b/rsc3/examples/graph/oscillator-cluster.scm @@ -0,0 +1,40 @@ +;; oscillator cluster (rd) + +(import (rnrs) (rsc3) (rhs)) + +(define ln + (lambda (a b d) + (line kr a b d remove-synth))) + +(define xln + (lambda (a b d) + (x-line kr a b d remove-synth))) + +(define rln + (lambda (r a b d) + (line kr (add a (rand 0 r)) b d remove-synth))) + +(define rxln + (lambda (r a b d) + (x-line kr (add a (rand 0 r)) b d remove-synth))) + +(define prt + (lambda (d a) + (lambda (cf) + (let* ((r1 (rand cf (add cf 2))) + (r2 (rln 1 5 0.01 d)) + (r3 (rln 10 20 0 d)) + (r4 (rand 0.1 0.2)) + (f (add (mce2 cf r1) (mul (sin-osc kr r2 0) r3))) + (o (f-sin-osc ar f 0)) + (e (mul (decay2 (impulse ar 0 0) r4 d) a))) + (mul o e))))) + +(define oscillator-cluster + (let* ((np 12) + (fp (replicate-m np (rand 220 660))) + (d (rand 4 7)) + (a (rand 0.01 0.05))) + (foldl add 0 (map (prt d a) fp)))) + +(audition (out 0 oscillator-cluster)) diff --git a/rsc3/examples/graph/pattern-buffer.scm b/rsc3/examples/graph/pattern-buffer.scm new file mode 100644 index 0000000..a23eb42 --- /dev/null +++ b/rsc3/examples/graph/pattern-buffer.scm @@ -0,0 +1,36 @@ +;; pattern buffer (rd) + +(import (rnrs) (sosc) (rsc3) (rhs)) + +(define tseq + (lambda (l) + (let ((n (/ (length l) 2))) + (select (mul-add (lf-saw kr 0.5 0) n n) (make-mce l))))) + +(define rs + (lambda (nf fd) + (let ((r0 (random 0 nf)) + (r1 (random 0 1))) + (send fd (b-set1 10 r0 r1))))) + +(define pattern-buffer + (lambda (nf c) + (let* ((p (phasor ar 0 (buf-rate-scale kr 10) 0 (buf-frames kr 10) 0)) + (t (buf-rd-c 1 ar 10 p 1)) + (r1 (replicate-m c (random 36 96))) + (r2 (replicate-m c (random -1 1))) + (r3 (i-random 0 2)) + (n1 (t-rand 0.02 0.08 t)) + (e (decay2 t 0.01 n1)) + (f (midi-cps (tseq r1))) + (l (tseq r2)) + (o (list-ref (list (sin-osc ar f 0) (saw ar f)) r3))) + (pan2 o l e)))) + +(with-sc3 + (lambda (fd) + (let ((nf (mul 2 48000)) + (c 24)) + (async fd (b-alloc 10 (* nf 2) 1)) + (replicate-m c (rs nf fd)) + (play fd (out 0 (pattern-buffer nf c)))))) diff --git a/rsc3/examples/graph/plucked-strings.scm b/rsc3/examples/graph/plucked-strings.scm new file mode 100644 index 0000000..dcb9626 --- /dev/null +++ b/rsc3/examples/graph/plucked-strings.scm @@ -0,0 +1,22 @@ +;; plucked strings (jmcc) + +(import (rnrs) (rsc3)) + +(define plucked-strings + (let ((s (lambda (_) + (let* ((r0 (rand 2 2.2)) + (n0 (dust ar 0.5)) + (r1 (rand 0.05 0.15)) + (r2 (rand 0 (* pi 2))) + (r3 (i-rand 0 2)) + (s0 (impulse ar r0 0.3)) + (s1 (mul n0 0.3)) + (f (mul-add (sin-osc kr r1 r2) 5 5.2)) + (s2 (impulse ar f 0.3)) + (im (select r3 (mce3 s0 s1 s2))) + (dt (fdiv 1 (midi-cps (u:floor (rand 60 90))))) + (t (mul3 (decay im 0.1) (pink-noise ar) 0.1))) + (pan2 (comb-l t dt dt 4) (rand -1 1) 1))))) + (leak-dc (mix-fill 5 s) 0.96))) + +(audition (out 0 plucked-strings)) diff --git a/rsc3/examples/graph/police-state.scm b/rsc3/examples/graph/police-state.scm new file mode 100644 index 0000000..a9f834d --- /dev/null +++ b/rsc3/examples/graph/police-state.scm @@ -0,0 +1,24 @@ +;; police state (jmcc) + +(import (rnrs) (rsc3)) + +(define node + (lambda (_) + (let* ((r0 (rand 0.02 0.1)) + (r1 (rand 0 (* pi 2))) + (r2 (rand 0 600)) + (r3 (rand 700 1300)) + (r4 (rand -1 1)) + (r5 (rand 80 120)) + (n0 (lf-noise2 ar r5)) + (f (mul-add (sin-osc kr r0 r1) r2 r3))) + (pan2 (mul (sin-osc ar f 0) n0) r4 0.1)))) + +(define police-state + (let* ((n0 (lf-noise2 kr (mce2 0.4 0.4))) + (n1 (lf-noise2 ar (mul-add n0 90 620))) + (n2 (lf-noise2 kr (mce2 0.3 0.3))) + (e (mul n1 (mul-add n2 0.15 0.18)))) + (comb-l (add (mix-fill 4 node) e) 0.3 0.3 3))) + +(audition (out 0 police-state)) \ No newline at end of file diff --git a/rsc3/examples/graph/pulsing-bottles.scm b/rsc3/examples/graph/pulsing-bottles.scm new file mode 100644 index 0000000..0dd115e --- /dev/null +++ b/rsc3/examples/graph/pulsing-bottles.scm @@ -0,0 +1,20 @@ +;; pulsing bottles (jmcc) + +(import (rnrs) (rsc3)) + +(define u + (lambda (_) + (let* ((n (white-noise ar)) + (r0 (rand 4 14)) + (r1 (rand 0 0.7)) + (r2 (rand 400 7400)) + (r (resonz (mul3 n (lf-pulse kr r0 0 0.25) r1) r2 0.01)) + (f (rand 0.1 0.5)) + (p (rand 0 (mul pi 2))) + (s (sin-osc kr f p))) + (pan2 r s 1)))) + +(define pulsing-bottles + (mix-fill 6 u)) + +(audition (out 0 pulsing-bottles)) diff --git a/rsc3/examples/graph/record-scratcher.scm b/rsc3/examples/graph/record-scratcher.scm new file mode 100644 index 0000000..f750128 --- /dev/null +++ b/rsc3/examples/graph/record-scratcher.scm @@ -0,0 +1,18 @@ +;; record scratcher (josh parmenter) + +(import (rnrs) (rsc3)) + +(define dup (lambda (a) (mce2 a a))) + +(define record-scratcher + (lambda (b) + (let* ((x (mouse-x* kr -10 10 linear 0.2)) + (dx (sub x (delay-n x 0.1 0.1))) + (bdx (add (mouse-button* kr 1 0 0.3) dx)) + (bdxr (mul bdx (buf-rate-scale kr b)))) + (dup (play-buf 1 b bdxr 0 0 loop))))) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 10 "/home/rohan/data/audio/pf-c5.snd" 0 0)) + (play fd (out 0 (record-scratcher 10))))) diff --git a/rsc3/examples/graph/red-frik.scm b/rsc3/examples/graph/red-frik.scm new file mode 100644 index 0000000..9208106 --- /dev/null +++ b/rsc3/examples/graph/red-frik.scm @@ -0,0 +1,22 @@ +;; red frik (f0) + +(import (rnrs) (rsc3)) + +(define red + (lambda (tr n) + (let* ((r1 (t-rand 0.3 3 tr)) + (r2 (t-rand 0.3 5 tr)) + (r3 (t-rand 0 0.5 tr)) + (r4 (t-rand 0.49 0.56 tr)) + (r5 (t-rand 0.3 0.6 tr)) + (r6 (t-rand 0.3 0.5 tr)) + (o1 (mul-add (f-sin-osc kr r2 0) r3 r4)) + (o2 (mul (f-sin-osc kr o1 r5) r6))) + (rhpf n r1 o2)))) + +(define red-frik + (let ((n (clone 2 (brown-noise ar))) + (tr (impulse kr 0.1 0))) + (red tr n))) + +(audition (out 0 red-frik)) diff --git a/rsc3/examples/graph/reset.scm b/rsc3/examples/graph/reset.scm new file mode 100644 index 0000000..5821c54 --- /dev/null +++ b/rsc3/examples/graph/reset.scm @@ -0,0 +1,3 @@ +(import (rnrs) (rsc3)) +(with-sc3 reset) + diff --git a/rsc3/examples/graph/reverberated-sine-percussion.scm b/rsc3/examples/graph/reverberated-sine-percussion.scm new file mode 100644 index 0000000..33944a8 --- /dev/null +++ b/rsc3/examples/graph/reverberated-sine-percussion.scm @@ -0,0 +1,33 @@ +;; reverberated sine percussion (jmcc) + +(import (rnrs) (rsc3) (rhs)) + +(define rallpass + (lambda (i) + (allpass-n i 0.050 (clone 3 (rand 0 0.05)) 1))) + +(define chain-of + (lambda (n f) + (foldl1 compose (replicate n f)))) + +(define reverberated-sine-percussion + (let* ((d 10) + (c 7) + (a 4) + (s (mix-fill + d + (lambda (_) + (resonz (mul (dust ar (/ 2 d)) 50) + (+ 200 (random 0 3000)) + 0.003)))) + (z (delay-n s 0.048 0.48)) + (y (mix (comb-l z + 0.1 + (mul-add (lf-noise1 kr (clone c (rand 0 0.1))) + 0.04 + 0.05) + 15))) + (x ((chain-of a rallpass) y))) + (add s (mul 0.2 x)))) + +(audition (out 0 reverberated-sine-percussion)) diff --git a/rsc3/examples/graph/rm-octaver.scm b/rsc3/examples/graph/rm-octaver.scm new file mode 100644 index 0000000..968fe7b --- /dev/null +++ b/rsc3/examples/graph/rm-octaver.scm @@ -0,0 +1,11 @@ +;; rm-octaver (andrea valle, miller puckette) + +(import (rnrs) (rsc3)) + +(let* ((default-pitch + (lambda (i) + (pitch i 440 60 4000 100 16 1 0.01 0.5 1))) + (i (sound-in 4)) + (p (default-pitch i)) + (f (mce-channel p 0))) + (audition (out 0 (mul-add (sin-osc ar (mul f 0.5) 0) i i)))) diff --git a/rsc3/examples/graph/rzblp.scm b/rsc3/examples/graph/rzblp.scm new file mode 100644 index 0000000..4087999 --- /dev/null +++ b/rsc3/examples/graph/rzblp.scm @@ -0,0 +1,43 @@ +;; rzblp (rd) + +(import (rnrs) (rsc3) (rhs)) + +(define wrp + (lambda (i l r) + (let ((m (fdiv (sub r l) 2))) + (mul-add i m (add l m))))) + +(define lfn + (lambda (f l r) + (wrp (lf-noise0 kr f) l r))) + +(define hpb + (lambda (q) + (mix-fill + 2 + (lambda (_) + (let ((f (lfn q 1330 1395)) + (a (lfn q 0.001 0.007))) + (mul (blip ar f 24) a)))))) + +(define f + (lambda (u) + (let* ((q (lfn 5.2 5.2 5.21)) + (a (u dinf (mce5 1 3 2 7 8))) + (trig (impulse kr q 0)) + (freq (mul-add (demand trig 0 a) 30 340))) + (foldl1 add + (list (mul (blip ar freq 3) + (lfn q 0.001 0.01)) + (mul (resonz (impulse ar q (mce2 0 0)) + (lfn 5 30 640) + (lfn q 0.1 0.5)) + (lfn q 0.01 1.8)) + (mul (hpb q) + (lfn q 1.2 1.8)) + (mul (blip ar (lfn q 16 36) 3) + (mce2 0.03 0.09))))))) + +(define rzblp (add (f drand) (f dxrand))) + +(audition (out 0 rzblp)) diff --git a/rsc3/examples/graph/s-chirp.scm b/rsc3/examples/graph/s-chirp.scm new file mode 100644 index 0000000..b0695b9 --- /dev/null +++ b/rsc3/examples/graph/s-chirp.scm @@ -0,0 +1,25 @@ +;; s-chirp (rd) + +(import (rnrs) (sosc) (rsc3)) + +(define s-chirp + (let* ((x (mouse-x kr 15 0 0 0.1)) + (y (mouse-y kr 15 27 0 0.1)) + (t (dust kr 9)) + (b (t-choose t (make-mce (list 36 48 60 72)))) + (n (mul (lf-noise1 kr (mce2 3 3.05)) 0.04)) + (d (ti-rand x y t)) + (e (decay2 t 0.005 (t-rand 0.02 0.15 t))) + (k (degree-to-key 0 d 12)) + (f (midi-cps (add3 b k n))) + (m (mul3 e (sin-osc ar f 0) 0.2)) + (u (pulse-divider t 9 0)) + (r0 (t-rand 0.0075 0.125 u)) + (r1 (t-rand 0.05 0.15 u))) + (mul-add m 0.5 (allpass-c m 0.15 r0 r1)))) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 7 1)) + (send fd (b-setn1 0 0 (list 0 2 3.2 5 7 9 10))) + (audition (out 0 s-chirp)))) diff --git a/rsc3/examples/graph/sample-and-hold-liquidities.scm b/rsc3/examples/graph/sample-and-hold-liquidities.scm new file mode 100644 index 0000000..8a4f367 --- /dev/null +++ b/rsc3/examples/graph/sample-and-hold-liquidities.scm @@ -0,0 +1,16 @@ +;; sample and hold liquidities (jmcc) + +(import (rnrs) (rsc3)) + +(define sahl + (let* ((r (mouse-x kr 1 200 1 0.1)) + (t (recip r)) + (c (impulse kr r 0.4)) + (cf (mouse-y kr 100 8000 1 0.1)) + (f (latch (mul-add (white-noise kr) (mul cf 0.5) cf) c)) + (p (latch (white-noise kr) c)) + (e (decay2 c (mul 0.1 t) (mul 0.9 t))) + (i (pan2 (mul (sin-osc ar f 0) e) p 1))) + (comb-n i 0.3 0.3 2))) + +(audition (out 0 sahl)) diff --git a/rsc3/examples/graph/scratchy.scm b/rsc3/examples/graph/scratchy.scm new file mode 100644 index 0000000..e449b47 --- /dev/null +++ b/rsc3/examples/graph/scratchy.scm @@ -0,0 +1,10 @@ +;; scratchy (jmcc) + +(import (rnrs) (rsc3)) + +(define scratchy + (let* ((n (mul (clone 2 (brown-noise ar)) 0.5)) + (f (mul (u:max (sub n 0.49) 0) 20))) + (rhpf f 5000 1))) + +(audition (out 0 scratchy)) \ No newline at end of file diff --git a/rsc3/examples/graph/scritto.scm b/rsc3/examples/graph/scritto.scm new file mode 100644 index 0000000..c678195 --- /dev/null +++ b/rsc3/examples/graph/scritto.scm @@ -0,0 +1,82 @@ +;; scritto (rd) + +(import (rnrs) (sosc) (rsc3)) + +(define putnam + '((sA ((800 1150 2900 3900 4950) (0 -6 -32 -20 -50) (80 90 120 130 140))) + (sE ((350 2000 2800 3600 4950) (0 -20 -15 -40 -56) (60 100 120 150 200))) + (sI ((270 2140 2950 3900 4950) (0 -12 -26 -26 -44) (60 90 100 120 120))) + (sO ((450 800 2830 3800 4950) (0 -11 -22 -22 -50) (70 80 100 130 135))) + (sU ((325 700 2700 3800 4950) (0 -16 -35 -40 -60) (50 60 170 180 200))) + (aA ((800 1150 2800 3500 4950) (0 -4 -20 -36 -60) (80 90 120 130 140))) + (aE ((400 1600 2700 3300 4950) (0 -24 -30 -35 -60) (60 80 120 150 200))) + (aI ((350 1700 2700 3700 4950) (0 -20 -30 -36 -60) (50 100 120 150 200))) + (aO ((450 800 2830 3500 4950) (0 -9 -16 -28 -55) (70 80 100 130 135))) + (aU ((325 700 2530 3500 4950) (0 -12 -30 -40 -64) (50 60 170 180 200))) + (ctA ((660 1120 2750 3000 3350) (0 -6 -23 -24 -38) (80 90 120 130 140))) + (ctE ((440 1800 2700 3000 3300) (0 -14 -18 -20 -20) (70 80 100 120 120))) + (ctI ((270 1850 2900 3350 3590) (0 -24 -24 -36 -36) (40 90 100 120 120))) + (ctO ((430 820 2700 3000 3300) (0 -10 -26 -22 -34) (40 80 100 120 120))) + (ctU ((370 630 2750 3000 3400) (0 -20 -23 -30 -34) (40 60 100 120 120))) + (tA ((650 1080 2650 2900 3250) (0 -6 -7 -8 -22) (80 90 120 130 140))) + (tE ((400 1700 2600 3200 3580) (0 -14 -12 -14 -20) (70 80 100 120 120))) + (tI ((290 1870 2800 3250 3540) (0 -15 -18 -20 -30) (40 90 100 120 120))) + (tO ((400 800 2600 2800 3000) (0 -10 -12 -12 -26) (40 80 100 120 120))) + (tU ((350 600 2700 2900 3300) (0 -20 -17 -14 -26) (40 60 100 120 120))) + (bA ((600 1040 2250 2450 2750) (0 -7 -9 -9 -20) (60 70 110 120 130))) + (bE ((400 1620 2400 2800 3100) (0 -12 -9 -12 -18) (40 80 100 120 120))) + (bI ((250 1750 2600 3050 3340) (0 -30 -16 -22 -28) (60 90 100 120 120))) + (bO ((400 750 2400 2600 2900) (0 -11 -21 -20 -40) (40 80 100 120 120))) + (bU ((350 600 2400 2675 2950) (0 -20 -32 -28 -36) (40 80 100 120 120))))) + +(define v-filter + (lambda (in freq ampl bw) + (mul (resonz in freq (fdiv bw freq)) + (db-amp ampl)))) + +(define voice-tr + (lambda (i t fr amr bwr) + (mix (v-filter + i + (mul (in 5 kr 0) (t-rand (sub 1 fr) (add 1 fr) t)) + (mul (in 5 kr 5) (t-rand (sub 1 amr) (add 1 amr) t)) + (mul (in 5 kr 10) (t-rand (sub 1 bwr) (add 1 bwr) t)))))) + +(define scritto + (lambda (rt) + (let* ((t (impulse ar (mul-add (lf-noise2 kr 3) 12 12) 0)) + (n (ti-rand 30 52 t)) + (i (lambda (d) + (mul3 (decay2 (pulse-divider t d 0) 0.01 (t-rand 0.005 rt t)) + (blip ar (midi-cps n) (t-rand 16 32 t)) + 12.0))) + (x (mouse-x kr 0 1 0 0.1)) + (y (mouse-y kr 0 1 0 0.1))) + (mrg2 (send-trig t 0 n) + (out 0 (clip2 + (mce2 (voice-tr (i 1) + t + (mul x 1.05) + (mul x 1.25) + (mul x 0.05)) + (voice-tr (i 2) + t + (mul y 0.05) + (mul y 0.75) + (mul y 1.00))) + 1)))))) + +(define updater + (lambda (fd) + (let* ((v (choose putnam)) + (data (list-ref v 1)) + (freq (list-ref data 0)) + (ampl (list-ref data 1)) + (bw (list-ref data 2))) + (send fd (c-setn1 0 freq)) + (send fd (c-setn1 5 ampl)) + (send fd (c-setn1 10 bw))))) + +(audition (scritto (mouse-x kr 0.0125 0.35 0 0.1))) + +(with-sc3 updater) diff --git a/rsc3/examples/graph/seqr.scm b/rsc3/examples/graph/seqr.scm new file mode 100644 index 0000000..5935478 --- /dev/null +++ b/rsc3/examples/graph/seqr.scm @@ -0,0 +1,25 @@ +;; seqr (rd) + +(import (rnrs) (rsc3) (rhs)) + +(define nfreq + (lambda (n l r) + (map midi-cps (map floor (replicate-m n (random l r)))))) + +(define seqr-f + (lambda (f e) + (let ((n (/ (length e) 2))) + (select (mul-add (lf-saw kr f 0) n n) (make-mce e))))) + +(define seqr + (let* ((n (i-random 6 18)) + (f (/ (i-random 9 18) n))) + (mul (blip ar + (mce2 (seqr-f f (nfreq n 72 96)) + (seqr-f f (nfreq n 72 84))) + (mce2 (seqr-f f (replicate-m n (random 1 3))) + (seqr-f f (replicate-m n (random 3 6))))) + (mce2 (seqr-f f (replicate-m n (random 0.05 0.10))) + (seqr-f f (replicate-m n (random 0.05 0.15))))))) + +(audition (out 0 seqr)) diff --git a/rsc3/examples/graph/shepard-tones.scm b/rsc3/examples/graph/shepard-tones.scm new file mode 100644 index 0000000..b20543b --- /dev/null +++ b/rsc3/examples/graph/shepard-tones.scm @@ -0,0 +1,48 @@ +;; shepard tones (alberto de campo) + +(import (rnrs) (sosc) (rsc3) (rhs)) + +(define iota + (lambda (n l j) + (if (= n 0) + nil + (cons l (iota (- n 1) (+ l j) j))))) + +(define indxs + (lambda (n l r) + (iota n l (/ (- r l) n)))) + +(define hanning-window + (lambda (n) + (let* ((lp (* pi -0.5)) + (rp (+ lp (* 2 pi))) + (hf (lambda (i) (+ (* (sin i) 0.5) 0.5)))) + (map hf (indxs n lp rp))))) + +(define square (lambda (x) (* x x))) + +(define amp-table (map square (hanning-window 1024))) + +(define amp-f (lambda (i) (* (expt 0.5 i) 20000))) + +(define freq-table (map amp-f (indxs 1024 0 10))) + +(define shepard-tones + (let* ((rate-scale (/ (/ 1024 44100) 10)) + (rate 0.1) + (ph (phasor ar 0 (* rate rate-scale) 0 1024 0)) + (phases (make-mce + (map + (lambda (n) (add (mul3 n 0.1 1024) ph)) + (enum-from-to 0 9)))) + (freqs (buf-rd-c 1 ar 1 phases 1)) + (amps (buf-rd-c 1 ar 2 phases 1))) + (mul (mix (mul (sin-osc ar freqs 0) amps)) 0.1))) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 1 1024 1)) + (async fd (b-alloc 2 1024 1)) + (send fd (b-setn1 1 0 freq-table)) + (send fd (b-setn1 2 0 amp-table)) + (audition (out 0 shepard-tones)))) diff --git a/rsc3/examples/graph/shifting-pulses.scm b/rsc3/examples/graph/shifting-pulses.scm new file mode 100644 index 0000000..6a45522 --- /dev/null +++ b/rsc3/examples/graph/shifting-pulses.scm @@ -0,0 +1,44 @@ +;; shifting pulses (rd) + +(import (rnrs) (sosc) (rsc3) (rhs)) + +(define wrp + (lambda (i l r) + (lin-lin i -1 1 l r))) + +(define prt + (lambda (f a) + (let ((f* (mul f (mul (wrp (sin-osc kr (rand 0.2 0.9) 0) 1 1.01) + (rand 0.95 1.05))))) + (mul (sin-osc ar (mce2 f f*) 0) + (mul a (clone 2 (rand 0.95 1.05))))))) + +;; (audition (out 0 (prts 2 900 0.002))) +;; (audition (out 0 (prts 9 40 0.006))) +(define prts + (lambda (n f a) + (mix + (make-mce + (map + (lambda (f) + (prt f a)) + (enum-from-then-to f (+ f f) (* n f))))))) + +(define shifting-pulses + (let* ((n1 (clone 2 (brown-noise kr))) + (n2 (clone 2 (brown-noise kr))) + (n3 (clone 2 (brown-noise kr))) + (t (dust kr 0.75)) + (l (latch t t)) + (p (mul (pulse ar (wrp n1 2 (mce2 11 15)) 0.01) 0.1)) + (f (wrp n2 300 1800)) + (rq (wrp n3 0.01 2))) + (mrg2 + (add4 + (prts 2 900 0.002) + (prts 9 40 0.006) + (mul (formant ar (mce2 20 21) (wrp (lf-noise2 kr 2) 10 100) 200) 0.35) + (mul l (rlpf p f rq))) + (send-trig t 0 t)))) + +(audition (out 0 shifting-pulses)) diff --git a/rsc3/examples/graph/slly-wlk.scm b/rsc3/examples/graph/slly-wlk.scm new file mode 100644 index 0000000..5ff6bf3 --- /dev/null +++ b/rsc3/examples/graph/slly-wlk.scm @@ -0,0 +1,51 @@ +;; slly-walk (rd) + +(import (rnrs) (sosc) (rsc3)) + +(define o1 + (let* ((t (dust kr 2)) + (e (env-bp-linear (list 0 0 (t-rand 0.05 0.5 t) 1 1 0) 1 1)) + (d (t-rand 0.15 0.25 t)) + (a (env-gen kr t (t-rand 0.02 0.04 t) 0 d do-nothing e)) + (p (env-gen kr t (t-rand 1.0 2.0 t) -1.0 d do-nothing e)) + (n (t-choose t (mce4 0 2 5 7))) + (o 72)) + (pan2 (sin-osc ar (midi-cps (add n o)) 0) p a))) + +(define shft + (lambda () + (let* ((t (impulse kr 12 0)) + (e (env-bp-linear (list 0 0 (t-rand 0.25 1.0 t) 1 1 0) 1 1)) + (d (t-rand 0.05 0.125 t)) + (a (env-gen kr t (t-rand 0.02 0.04 t) 0 d do-nothing e)) + (p (env-gen kr t (t-rand 1.0 2.0 t) -1.0 d do-nothing e)) + (n (t-choose t (make-mce (list 0 0 5 7 7 12 12 19)))) + (o (add 84 (mul (toggle-ff t) 12)))) + (pan2 (saw ar (midi-cps (add n o))) p a)))) + +(define o2 + (mul (add3 (shft) (shft) (shft)) 0.1)) + +(define o3 + (let* ((t (impulse kr 6 0)) + (e (env-bp-linear (list 0 0 (t-rand 0.25 1.0 t) 1 1 0) 1 1)) + (d (t-rand 0.05 0.25 t)) + (a (env-gen kr t (t-rand 0.01 0.02 t) 0 d do-nothing e)) + (p (env-gen kr t (t-rand 1.0 2.0 t) -1.0 d do-nothing e)) + (n (demand t 0 (dibrown dinf 0 7 1))) + (o 52)) + (pan2 (saw ar (midi-cps (degree-to-key 0 (add n o) 12))) p a))) + +(define o4 + (mul (rlpf (lf-pulse ar (midi-cps (mce2 36 43)) 0.15 0.5) + (midi-cps (mul-add (sin-osc kr 0.1 0) 10 36)) + 0.1) + 0.1)) + +(define slly-wlk + (lambda (fd) + (async fd (b-alloc 0 7 1)) + (send fd (b-setn1 0 0 (list 0 2 3.2 5 7 9 10))) + (play fd (out 0 (add4 o1 o2 o3 o4))))) + +(with-sc3 slly-wlk) diff --git a/rsc3/examples/graph/snare-909.scm b/rsc3/examples/graph/snare-909.scm new file mode 100644 index 0000000..28d9213 --- /dev/null +++ b/rsc3/examples/graph/snare-909.scm @@ -0,0 +1,31 @@ +;; snare-909 (jmcc) + +(import (rnrs) (rsc3)) + +(define snr + (lambda (tr n v) + (let* ((mk-e + (lambda (a b) + (let ((p (env-perc a b 1 (list -4 -4)))) + (env-gen ar tr 1 0 1 do-nothing p)))) + (e1 (mk-e 0.0005 0.055)) + (e2 (mk-e 0.0005 0.075)) + (e3 (mk-e 0.0005 0.4)) + (e4 (mk-e 0.0005 0.283)) + (t1 (lf-tri ar 330 0)) + (t2 (lf-tri ar 185 0)) + (x1 (mul-add (lpf n 7040) 0.1 v)) + (x2 (hpf x1 523)) + (m1 (add (mul3 t1 e1 0.25) (mul3 t2 e2 0.25))) + (m2 (add (mul3 x1 e3 0.20) (mul3 x2 e4 0.20)))) + (add m1 m2)))) + +(define snare-909 + (let* ((x (mouse-x* kr 1 4 linear 0.2)) + (y (mouse-y* kr 0.25 0.75 exponential 0.2)) + (t (impulse kr (mul 3 x) 0)) + (n (white-noise ar)) + (v (t-rand 0.25 1.0 t))) + (pan2 (snr t n v) 0 y))) + +(audition (out 0 snare-909)) \ No newline at end of file diff --git a/rsc3/examples/graph/sosc-lp.scm b/rsc3/examples/graph/sosc-lp.scm new file mode 100644 index 0000000..047cf88 --- /dev/null +++ b/rsc3/examples/graph/sosc-lp.scm @@ -0,0 +1,39 @@ +;; sosc-lp (rd) + +(import (rnrs) (sosc) (rsc3)) + +(define dust-r + (lambda (r lo hi) + (let ((d (dseq dinf (make-mce (list (dwhite 1 lo hi)))))) + (t-duty r d 0 0 (u:abs (white-noise r)) 1)))) + +(define sosc-lp + (let* ((clk (dust-r kr 0.2 0.9)) + (env (decay2 clk 0.002 2.5)) + (idx (stepper clk 0 0 15 1 0)) + (f1 (midi-cps (mce2 (sub (buf-rd 1 kr 10 idx 1 1) 24) + (sub (buf-rd 1 kr 11 idx 1 1) 24)))) + (f2 (add f1 (mul (lf-noise0 kr (mce2 1 3)) 1.2))) + (o1 (mul (sin-osc ar f1 0) env)) + (o2 (mul (sin-osc ar f2 0) env))) + (mrg2 + (send-trig clk 0 clk) + (mul (add o1 o2) 0.2)))) + +(with-sc3 + (lambda (fd) + (let ((a (list 60 71 89 65 36 57 92 97 92 97)) + (b (list 71 89 60 57 65 36 95 92 93 97))) + (async fd (b-alloc 10 9 1)) + (async fd (b-alloc 11 9 1)) + (send fd (b-setn1 10 0 a)) + (send fd (b-setn1 11 0 b)) + (play fd (out 0 sosc-lp))))) + +(define alternate + (with-sc3 + (lambda (fd) + (let ((a (list 71 60 65 89 36 57 95 97 92 97)) + (b (list 89 71 60 65 57 36 92 95 93 97))) + (send fd (b-setn1 10 0 a)) + (send fd (b-setn1 11 0 b)))))) diff --git a/rsc3/examples/graph/spe.scm b/rsc3/examples/graph/spe.scm new file mode 100644 index 0000000..239bb7d --- /dev/null +++ b/rsc3/examples/graph/spe.scm @@ -0,0 +1,27 @@ +;; spe (jmcc) + +(import (rnrs) (rhs) (rsc3)) + +(define chain-of + (lambda (n f) + (foldl1 compose (replicate n f)))) + +(define rapf + (lambda (i) + (allpass-n i 0.05 (clone 2 (rand 0 0.05)) 4))) + +(define spe + (let* ((n (lf-noise1 kr 1)) + (s (make-mce (list 00 03 02 07 + 08 32 16 18 + 00 12 24 32))) + (m (dseq dinf s)) + (t (impulse kr 9 0)) + (f (midi-cps (add (demand t 0 m) 32))) + (p (env-perc 0.01 1 1 (list -4 -4))) + (e (env-gen kr t 0.1 0 1 do-nothing p)) + (o (mul (lf-saw ar f 0) e)) + (rq (midi-cps (mul-add n 36 110)))) + ((chain-of 4 rapf) (rlpf o rq 0.1)))) + +(audition (out 0 spe)) diff --git a/rsc3/examples/graph/sprinkler.scm b/rsc3/examples/graph/sprinkler.scm new file mode 100644 index 0000000..a2c3f84 --- /dev/null +++ b/rsc3/examples/graph/sprinkler.scm @@ -0,0 +1,10 @@ +;; sprinkler (jmcc) + +(import (rnrs) (rsc3)) + +(define sprinkler + (let* ((f (mul-add (lf-pulse kr 0.09 0 0.16) 10 7)) + (t (mul (lf-pulse kr f 0 0.25) 0.1))) + (bpz2 (mul (white-noise ar) t)))) + +(audition (out 0 sprinkler)) diff --git a/rsc3/examples/graph/status.scm b/rsc3/examples/graph/status.scm new file mode 100644 index 0000000..a5e4930 --- /dev/null +++ b/rsc3/examples/graph/status.scm @@ -0,0 +1,2 @@ +(import (rnrs) (rsc3)) +(with-sc3 display-server-status) diff --git a/rsc3/examples/graph/strtchd-scrmbld.scm b/rsc3/examples/graph/strtchd-scrmbld.scm new file mode 100644 index 0000000..1f264db --- /dev/null +++ b/rsc3/examples/graph/strtchd-scrmbld.scm @@ -0,0 +1,66 @@ +;; strtchd-scrmbld (rd) + +(import (rnrs) (sosc) (rsc3)) + +(define dust-r + (lambda (r lo hi) + (let ((d (dseq dinf (dwhite 1 lo hi)))) + (t-duty r d 0 0 (u:abs (white-noise r)) 1)))) + +(define rpr + (lambda (n t) + (let ((i (in 2 kr n))) + (t-rand (mce-channel i 0) (mce-channel i 1) t)))) + +(define strtchd + (lambda (b z) + (let* ((clk (dust-r ar (in 1 kr 0) (in 1 kr 1))) + (rat (rpr 2 clk)) + (dur (rpr 4 clk)) + (bdr (buf-dur kr b)) + (hbd (mul bdr 0.5)) + (pos (add (mul (rpr 8 clk) bdr) + (mul-add (lf-saw ar z 0) hbd hbd))) + (pan (rpr 10 clk)) + (amp (rpr 6 clk))) + (t-grains 2 clk b rat pos dur pan amp 2)))) + +(define scrmbld + (lambda (u b t) + (let* ((f (fft* b u)) + (g (pv-bin-scramble f + (mouse-x kr 0.5 1.0 0 0.1) + (mouse-y kr 0.5 1.0 0 0.1) + t))) + (ifft* g)))) + +(define strtchd-scrmbld + (let ((t0 (dust kr 0.01)) + (t1 (dust kr 0.02)) + (u (add (strtchd 10 0.015) + (strtchd 10 0.0175)))) + (out 0 (mce2 (scrmbld (mce-channel u 0) 20 t0) + (scrmbld (mce-channel u 1) 30 t1))))) + +(define mk-r-set + (lambda () + (list (random 0.005 0.001) (random 0.0075 0.0125) + (random 0.90 0.975) (random 1.025 1.10) + (random 0.005 0.075) (random 0.075 0.125) + (random 0.005 0.01) (random 0.15 0.25) + (random -0.015 -0.005) (random 0.005 0.015) + (random -1 0) (random 0 1.0)))) + +(define pattern + (lambda (fd) + (send fd (c-setn1 0 (mk-r-set))) + (thread-sleep (choose (list 0.05 0.15 0.25 0.5 0.75 1.25))) + (pattern fd))) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 10 "/home/rohan/data/audio/pf-c5.snd" 0 0)) + (async fd (b-alloc 20 2048 1)) + (async fd (b-alloc 30 2048 1)) + (play fd strtchd-scrmbld) + (pattern fd))) diff --git a/rsc3/examples/graph/strummable-guitar.scm b/rsc3/examples/graph/strummable-guitar.scm new file mode 100644 index 0000000..09ba22f --- /dev/null +++ b/rsc3/examples/graph/strummable-guitar.scm @@ -0,0 +1,18 @@ +;; strummable guitar (jmcc) + +(import (rnrs) (rsc3)) + +(define sg + (let* ((scale (list 52 57 62 67 71 76)) + (str (lambda (i) + (let* ((x (mouse-x kr 0 1 0 0.2)) + (t (u:abs (hpz1 (gt x (add 0.25 (mul i 0.1)))))) + (e (decay t 0.05)) + (n (mul (pink-noise ar) e)) + (dt (recip (midi-cps (list-ref scale i)))) + (s (comb-l n dt dt 4))) + (pan2 s (sub (mul i 0.2) 0.5) 1)))) + (strs (mix-fill (length scale) str))) + (leak-dc (lpf strs 12000) 0.995))) + +(audition (out 0 sg)) diff --git a/rsc3/examples/graph/sweepy-noise.scm b/rsc3/examples/graph/sweepy-noise.scm new file mode 100644 index 0000000..e7969b5 --- /dev/null +++ b/rsc3/examples/graph/sweepy-noise.scm @@ -0,0 +1,15 @@ +;; sweepy noise (jmcc) + +(import (rnrs) (rsc3)) + +(define sn + (let* ((n (clone 2 (white-noise ar))) + (lfo-depth (mouse-y kr 200 8000 1 0.2)) + (lfo-rate (mouse-x kr 4 60 1 0.2)) + (freq (mul-add (lf-saw kr lfo-rate 0) + lfo-depth + (mul lfo-depth 1.2))) + (filtered (rlpf (mul n 0.03) freq 0.1))) + (add (comb-n filtered 0.3 0.3 2) filtered))) + +(audition (out 0 sn)) diff --git a/rsc3/examples/graph/synthetic-piano.scm b/rsc3/examples/graph/synthetic-piano.scm new file mode 100644 index 0000000..3c57059 --- /dev/null +++ b/rsc3/examples/graph/synthetic-piano.scm @@ -0,0 +1,21 @@ +;; synthetic piano (jmcc) + +(import (rnrs) (rsc3)) + +(define sp + (lambda (_) + (let* ((n (i-rand 36 90)) + (f (rand 0.1 0.5)) + (ph (rand 0 (mul pi 2))) + (s (mul (impulse ar f ph) 0.1)) + (e (decay2 s 0.008 0.04)) + (c + (lambda (i) + (let* ((n0 (lf-noise2 ar 3000)) + (o (list-ref (list -0.05 0 0.04) i)) + (dt (fdiv 1 (midi-cps (add n o))))) + (comb-l (mul n0 e) dt dt 6)))) + (l (sub (fdiv (sub n 36) 27) 1))) + (pan2 (mix-fill 3 c) l 1)))) + +(audition (out 0 (mix-fill 6 sp))) diff --git a/rsc3/examples/graph/tank.scm b/rsc3/examples/graph/tank.scm new file mode 100644 index 0000000..a15af8c --- /dev/null +++ b/rsc3/examples/graph/tank.scm @@ -0,0 +1,35 @@ +;; tank (jmcc) + +(import (rnrs) (rhs) (rsc3)) + +(define bang + (let ((d (dust ar 0.01)) + (n (brown-noise ar))) + (pan2 (mul (decay2 d 0.04 0.3) n) 0 1))) + +(define pling + (lambda (_) + (let ((o (f-sin-osc ar (exp-rand 300 2200) 0)) + (d (decay2 (dust ar 0.5) 0.1 0.5))) + (pan2 (mul (mul d 0.1) (cubed o)) (rand -1 1) 1)))) + +(define rallpass + (lambda (i) + (allpass-n i 0.03 (clone 2 (rand 0.005 0.02)) 1))) + +(define rallpasses + (foldl1 compose (replicate 4 rallpass))) + +(define tank + (lambda (i) + (let* ((l0 (mul (local-in 2 ar) 0.98)) + (l1 (one-pole l0 0.33)) + (l2 (rotate2 (mce-channel l1 0) (mce-channel l1 1) 0.23)) + (l3 (allpass-n l2 0.05 (clone 2 (rand 0.01 0.05)) 2)) + (l4 (delay-n l3 0.3 (mce2 0.17 0.23))) + (l5 (allpass-n l4 0.05 (clone 2 (rand 0.03 0.15)) 2)) + (l6 (leak-dc l5 0.995)) + (l7 (add l6 i))) + (mrg2 l7 (local-out l7))))) + +(audition (out 0 (tank (rallpasses (add bang (mix-fill 8 pling)))))) diff --git a/rsc3/examples/graph/tgb.scm b/rsc3/examples/graph/tgb.scm new file mode 100644 index 0000000..ba7e78b --- /dev/null +++ b/rsc3/examples/graph/tgb.scm @@ -0,0 +1,61 @@ +;; tgb (rd) + +(import (rnrs) (rsc3)) + +(define mkls + (lambda (bp t) + (env-gen kr 1 1 0 1 remove-synth (env-bp-linear bp t 1)))) + +(define pm/t + (lambda (l r d t) + (let ((le (mkls l d)) + (re (mkls r d))) + (t-rand le re t)))) + +(define wrp + (lambda (i l r) + (let ((m (fdiv (sub r l) 2))) + (mul-add i m (add l m))))) + +(define pm/n + (lambda (rt l r d) + (let ((le (mkls l d)) + (re (mkls r d))) + (wrp (white-noise rt) le re)))) + +(define gb + (lambda (b d) + (let* ((gps (pm/n ar + (list 0 400 1 0900) + (list 0 600 1 1200) + d)) + (t (impulse ar gps 0)) + (dur (pm/t (list 0 0.005 0.5 0.015 1 0.005) + (list 0 0.009 0.5 0.020 1 0.009) + d + t)) + (pan (pm/t (list 0 -1.0 0.5 -0.5 1 0.5) + (list 0 -0.5 0.5 +0.5 1 1.0) + d + t)) + (rate (pm/t (list 0 06 0.5 12 1 06) + (list 0 12 0.5 12 1 12) + d + t)) + (cpos (pm/t (list 0 0 1 0.95) + (list 0 0 1 1.00) + d + t)) + (amp (pm/t (list 0 0.25 0.5 0.55 1.0 0.15) + (list 0 0.50 0.5 0.75 1.0 0.25) + d + t))) + (t-grains 2 t b rate (mul cpos (buf-dur kr b)) dur pan amp 2)))) + +(define tgb + (lambda (fn) + (lambda (fd) + (async fd (b-alloc-read 10 fn 0 0)) + (play fd (out 0 (gb 10 7)))))) + +(with-sc3 (tgb "/home/rohan/data/audio/pf-c5.snd")) diff --git a/rsc3/examples/graph/tgr-rpr.scm b/rsc3/examples/graph/tgr-rpr.scm new file mode 100644 index 0000000..0f94503 --- /dev/null +++ b/rsc3/examples/graph/tgr-rpr.scm @@ -0,0 +1,51 @@ +;; tgr-rpr (rd) + +(import (rnrs) (sosc) (rsc3)) + +(define dust-r + (lambda (r lo hi) + (let ((d (dseq dinf (dwhite 1 lo hi)))) + (t-duty r d 0 0 (u:abs (white-noise r)) 1)))) + +(define rpr + (lambda (n t) + (let ((i (in 2 kr n))) + (t-rand (mce-channel i 0) (mce-channel i 1) t)))) + +(define r-set + (lambda (r) + (if (> r 0.5) + (list (random 0.005 0.025) (random 0.05 0.25) + (random 0.75 0.95) (random 1.05 1.25) + (random 0.001 0.01) (random 0.02 0.04) + (random 0.1 0.2) (random 0.2 0.4) + (random 0.0 0.45) (random 0.55 1.0) + (random -1 0) (random 0 1.0)) + (list (random 0.005 0.025) (random 0.05 0.25) + (random -1.25 -1.05) (random -0.95 -0.75) + (random 0.001 0.01) (random 0.02 0.04) + (random 0.1 0.2) (random 0.2 0.4) + (random 0.0 0.45) (random 0.55 1.0) + (random -1 0) (random 0 1.0))))) + +(define tgr-rpr + (lambda (b) + (let* ((clk (dust-r ar (in 1 kr 0) (in 1 kr 1))) + (rat (rpr 2 clk)) + (dur (rpr 4 clk)) + (pos (mul (rpr 8 clk) (buf-dur kr b))) + (pan (rpr 10 clk)) + (amp (rpr 6 clk))) + (t-grains 2 clk b rat pos dur pan amp 2)))) + +(define pattern + (lambda (fd) + (send fd (c-setn1 0 (r-set (random 0 1)))) + (thread-sleep (choose (list 0.25 0.75 1.5))) + (pattern fd))) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 10 "/home/rohan/data/audio/pf-c5.snd" 0 0)) + (play fd (out 0 (tgr-rpr 10))) + (pattern fd))) diff --git a/rsc3/examples/graph/theremin.scm b/rsc3/examples/graph/theremin.scm new file mode 100644 index 0000000..7515691 --- /dev/null +++ b/rsc3/examples/graph/theremin.scm @@ -0,0 +1,15 @@ +;; theremin (jmcc) + +(import (rnrs) (rsc3)) + +(define theremin + (let* ((mod 7) + (detune 0) + (x (mouse-x kr 0 0.9 0 0.2)) + (y (mouse-y kr 4000 200 1 0.8)) + (f (add y detune)) + (f* (add f (mul3 f (sin-osc ar mod 0) 0.02))) + (a (mul (sin-osc ar f* 0) x))) + (pan2 a 0 1))) + +(audition (out 0 theremin)) \ No newline at end of file diff --git a/rsc3/examples/graph/three-cpsw.scm b/rsc3/examples/graph/three-cpsw.scm new file mode 100644 index 0000000..cbd8c73 --- /dev/null +++ b/rsc3/examples/graph/three-cpsw.scm @@ -0,0 +1,16 @@ +;; three-cpsw (rd) + +(import (rnrs) (rsc3)) + +(define three-cpsw + (let* ((t (dust kr (mce2 12 18))) + (f0 (t-rand 1 64 t)) + (f1 (lf-noise0 kr f0)) + (a (t-rand 0.0 0.5 t)) + (dt (t-rand 0.975 1.025 t)) + (dh (t-rand 0.750 0.7505 t)) + (f (mul-add f1 (mce2 9000 12000) 9500)) + (o (add3 (saw ar f) (saw ar (mul f dh)) (saw ar (mul f dt))))) + (clip2 (mul o a) 0.75))) + +(audition (out 0 three-cpsw)) \ No newline at end of file diff --git a/rsc3/examples/graph/tipnso.scm b/rsc3/examples/graph/tipnso.scm new file mode 100644 index 0000000..b0c5d6d --- /dev/null +++ b/rsc3/examples/graph/tipnso.scm @@ -0,0 +1,17 @@ +;; tipnso.scm (rd) + +(import (rnrs) (rsc3)) + +(define tipnso + (let* ((t (impulse ar (mouse-x kr 1 32 0 0.1) 0)) + (e (decay2 t 0.01 (mce2 0.1 0.15))) + (n (ti-rand 16 72 t)) + (f (midi-cps (add n (add 36 (mul 12 (ti-rand 0 1 t))))))) + (mrg2 (mul (add (mul (sin-osc ar f 0) e) + (bpf (mul (pink-noise ar) e) + (add 36 (midi-cps n)) + (fdiv 175 (midi-cps n)))) + (mce2 0.15 0.1)) + (send-trig t 0 n)))) + +(audition (out 0 tipnso)) diff --git a/rsc3/examples/graph/tr-out.scm b/rsc3/examples/graph/tr-out.scm new file mode 100644 index 0000000..6657dea --- /dev/null +++ b/rsc3/examples/graph/tr-out.scm @@ -0,0 +1,26 @@ +;; tr-out (rd) + +(import (rnrs) (rhs) (sosc) (rsc3)) + +(define tr-out + (let* ((node + (lambda (n) + (let* ((t (dust kr 1.6)) + (f (midi-cps (buf-rd-n 1 kr 0 (t-rand 0 6 t) 0))) + (p (buf-rd-n 1 kr 1 (t-rand 0 6 t) 0)) + (a (buf-rd-n 1 kr 2 (t-rand 0 6 t) 0))) + (tuple2 (pan2 (sin-osc ar f 0) p a) + (send-trig t n (fdiv f 660)))))) + (ns (map node (enum-from-to 1 4)))) + (mrg-n (cons (foldl1 add (map fst ns)) + (map snd ns))))) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 6 1)) + (send fd (b-setn1 0 0 (list 60 62 64 65 67 69))) + (async fd (b-alloc 1 6 1)) + (send fd (b-setn1 1 0 (list -1 -0.5 0 0.25 0.75 1.0))) + (async fd (b-alloc 2 6 1)) + (send fd (b-setn1 2 0 (list 0.01 0.05 0.1 0.15 0.25 0.35))) + (play fd (out 0 tr-out)))) diff --git a/rsc3/examples/graph/trkl.scm b/rsc3/examples/graph/trkl.scm new file mode 100644 index 0000000..93113c0 --- /dev/null +++ b/rsc3/examples/graph/trkl.scm @@ -0,0 +1,26 @@ +;; trkl (rd) + +(import (rnrs) (rsc3)) + +(define trkl + (lambda (d ul fu dy la fy) + (let* ((tf (x-line kr 1 ul d remove-synth)) + (st (impulse ar (mul tf 8) 0)) + (t (impulse ar tf 0)) + (a (db-amp (line kr 12 la d remove-synth))) + (f (x-line kr fu 900 d remove-synth)) + (p (line kr (rand -1 1) (rand -1 1) d remove-synth)) + (fh (t-rand 1.75 2.25 t))) + (pan2 (add (mix (ringz (decay2 t 0.01 dy) (mce2 f (mul f fh)) fy)) + (mix (mul3 (saw ar (mce2 f (mul f fh))) + (decay2 t 0.1 (t-rand 0.05 1.0 t)) + (t-exp-rand 0.001 0.25 st)))) + p a)))) + +(audition + (out 0 (trkl (rand 0.5 16) + (rand 16 64) + (rand 1200 9000) + (rand 0.005 0.175) + (rand -60 -25) + (rand 0.015 0.125)))) diff --git a/rsc3/examples/graph/trmlo.scm b/rsc3/examples/graph/trmlo.scm new file mode 100644 index 0000000..bc35615 --- /dev/null +++ b/rsc3/examples/graph/trmlo.scm @@ -0,0 +1,56 @@ +;; trmlo (rd) + +(import (rnrs) (rsc3)) + +(define m-wrp + (lambda (i l r) + (lin-lin i -1 1 (midi-cps l) (midi-cps r)))) + +(define m-wrp1 + (lambda (i m) + (m-wrp i m (add m 1)))) + +(define m-wrp-n + (lambda (i m n) + (m-wrp i m (add m n)))) + +(define o1 + (let* ((f 5) + (d 3) + (s (env-sine d 0.1)) + (e (env-gen kr 1 1 0 1 do-nothing s)) + (n 65) + (m (sin-osc kr f 0))) + (pan2 (sin-osc ar (m-wrp1 m n) 0) m e))) + +(define o2 + (let* ((f (i-rand 5 9)) + (d (i-rand 5 9)) + (s (env-sine d (rand 0.1 0.2))) + (e (env-gen kr 1 1 0 1 do-nothing s)) + (n (i-rand 69 72)) + (m (sin-osc kr f 0))) + (pan2 (sin-osc ar (m-wrp1 m n) 0) m e))) + +(define o3 + (let* ((f (i-rand 5 9)) + (d (i-rand 9 12)) + (s (env-sine d (rand 0.1 0.2))) + (e (env-gen kr 1 1 0 1 do-nothing s)) + (n (i-rand 69 72)) + (m (sin-osc kr f 0)) + (l (line kr 0 (i-rand 1 5) d do-nothing))) + (pan2 (blip ar (m-wrp1 m (add n l)) (lin-lin m -1 1 1 2)) m e))) + +(define o4 + (let* ((f (i-rand 5 18)) + (d (i-rand 12 15)) + (s (env-sine d (rand 0.1 0.2))) + (e (env-gen kr 1 0.05 0 1 do-nothing s)) + (n (i-rand 69 72)) + (m (sin-osc kr f 0)) + (l (line kr 0 (i-rand 1 5) d remove-synth)) + (fr (m-wrp-n m (add n l) (i-rand 1 5)))) + (pan2 (blip ar fr (lin-lin m -1 1 1 (i-rand 2 24))) m e))) + +(audition (out 0 (add4 o1 o2 o3 o4))) diff --git a/rsc3/examples/graph/tsort.scm b/rsc3/examples/graph/tsort.scm new file mode 100644 index 0000000..3fd8b29 --- /dev/null +++ b/rsc3/examples/graph/tsort.scm @@ -0,0 +1,22 @@ +;; tsort (jmcc) + +;; This simple graph tests the topological sort of the unit generator +;; graph, it ought only to use a minimal number of interconnect buffers. + +;; The below 369 node graph works with 'scsynth -u 57110 -w 2'. + +;; (Note that graphs loaded from disk during startup will grow the number +;; of interconnect buffers, so to test this we must delete all graphs that +;; would otherwise be loaded.) + +(import (rnrs) (rsc3)) + +(define tsort + (let* ((n 122) + (c (env-bp '(0 0 0.15 1 6 0) 1 1 '(1 1 1))) + (e (env-gen kr 1 1 0 1 remove-synth c)) + (f (lambda (o) (mul (sin-osc ar (add 440 o) 0) 0.001))) + (s (mix-fill n f))) + (mul s e))) + +(audition (out 0 tsort)) diff --git a/rsc3/examples/graph/vla-adttn.scm b/rsc3/examples/graph/vla-adttn.scm new file mode 100644 index 0000000..9929e9a --- /dev/null +++ b/rsc3/examples/graph/vla-adttn.scm @@ -0,0 +1,145 @@ +;; vla-adttn (rd) + +(import (rnrs) (rhs) (sosc) (rsc3)) + +(define vla + '((-49.43290 1.99165) + (0.00000 1.09187) + (-2.53835 -2.73340) + (-8.55317 0.73919) + (-7.58952 -0.75267) + (-8.48353 1.70372) + (-13.92700 1.64759) + (-39.93130 -2.25142) + (-19.87800 -3.12024) + (-34.19660 -1.58899) + (-18.82040 -1.39847) + (-21.22520 2.04672) + (-21.33070 -0.14754) + (-31.08620 2.05345) + (-42.51880 -0.55890) + (-41.19730 0.23896) + (-46.80570 1.71249) + (-47.17510 2.37942) + (-37.97520 -0.83005) + (-38.32750 -2.49358) + (-44.79280 -1.16301) + (-49.11850 1.33082) + (-45.26480 -0.45146) + (-46.27050 -0.15578) + (-63.14360 -3.13979) + (-44.27590 -2.59826) + (-40.19680 -2.16540) + (-56.83330 0.48774) + (-56.62160 -0.84155) + (-55.76370 1.59076) + (-59.36050 -0.99090) + (-55.42520 -0.58264) + (-64.99020 0.00110) + (-63.45910 1.55117) + (-64.77610 2.68228) + (-68.27080 -1.82120) + (-71.90240 1.80545) + (-79.13910 2.99369) + (-64.94640 -3.12388) + (-59.41810 1.84679) + (-86.33570 1.81713) + (-88.53500 1.01834) + (-64.17470 -1.52081) + (-61.24430 1.45757) + (-69.88980 -0.47708) + (-65.39420 0.82882) + (-73.84740 0.41623) + (-72.26330 0.31856) + (-73.88560 2.64035) + (-70.86610 -0.43802) + (-67.86130 -0.43389) + (-80.76020 -2.50016) + (-66.44520 2.26219) + (-83.49810 2.57825) + (-66.01220 -2.08254) + (-65.30220 -2.83644) + (-74.05780 0.21665) + (-72.69060 -2.78729) + (-75.49700 2.96210) + (-69.45200 0.72293) + (-75.36160 0.14687) + (-70.21110 1.42155) + (-79.34420 0.76044) + (-81.56200 2.16997) + (-84.20670 3.11095) + (-74.40450 -2.98094) + (-76.67820 1.96564) + (-79.95980 2.68183) + (-77.31420 -1.92260) + (-74.60450 -1.89189) + (-67.98670 1.99457) + (-80.17960 -1.95013) + (-79.44400 -2.70955) + (-81.89010 3.12971) + (-80.18220 1.76888) + (-82.94420 2.77531))) + +(define prep + (lambda (p) + (let ((ampl (list-ref p 0)) + (phase (list-ref p 1))) + (list (s:db-amp ampl) phase)))) + +(define vla-partial + (lambda (freq rise fall detune) + (lambda (n) + (let* ((m (* n 2)) + (ampl (buf-rd 1 kr 0 m 0 0)) + (phase (buf-rd 1 kr 0 (+ m 1) 0 0))) + (mul (f-sin-osc ar + (mul3 freq + (+ n 1) + (mul-add (lf-noise1 kr 1) detune 1.0)) + phase) + (linen (impulse kr 0 0) + (mul rise (rand 0.75 1.25)) + ampl + (mul fall (rand 0.75 1.25)) + do-nothing)))))) + +(define vla-plyr + (lambda (n) + (letc ((buf 0) + (ampl 0.1) + (freq 129.897) + (rise 0.1) + (fall 0.5) + (loc 0.0) + (detune 0.001)) + (let ((s (foldl1 add (map (vla-partial freq rise fall detune) + (enum-from-to 0 (- n 1)))))) + (mrg2 (detect-silence s 0.001 0.2 remove-synth) + (out 0 (pan2 s loc ampl))))))) + +(define vla-get-cps + (lambda (b) + (midi-cps (+ (choose b) + (s:degree-to-key (choose (list 0 1 2 3 4 5 6 7 8)) + (list 0 2 3 5 7 8 10) + 12))))) + +(define pattern + (lambda (fd) + (send fd (s-new "plyr36" -1 add-to-tail 1 + (list "buf" 0 + "loc" (random -1 1) + "ampl" (random 0.05 0.1) + "freq" (vla-get-cps (list 24 36)) + "detune" (random 0.001 0.005) + "rise" (random 1 2) + "fall" (random 4 7)))) + (thread-sleep 5) + (pattern fd))) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 (* (length vla) 2) 1)) + (send fd (b-setn1 0 0 (flatten (map prep vla)))) + (send-synth fd "plyr36" (vla-plyr 36)) + (pattern fd))) diff --git a/rsc3/examples/graph/vlc-distrtn.scm b/rsc3/examples/graph/vlc-distrtn.scm new file mode 100644 index 0000000..a02068d --- /dev/null +++ b/rsc3/examples/graph/vlc-distrtn.scm @@ -0,0 +1,143 @@ +;; vlc-distrtn (rd) +;; caution - audio feedback graph + +(import (rnrs) (rhs) (sosc) (rsc3)) + +(define prep + (lambda (p) + (let ((ampl (list-ref p 0)) + (phase (list-ref p 1))) + (list (s:db-amp ampl) phase)))) + +(define vlc + '((0.00000 1.85550) + (-9.92383 -0.65147) + (-8.74205 -0.74728) + (-3.70464 -1.39796) + (-9.43435 -1.14812) + (-25.84790 -1.03375) + (-16.99500 -2.41724) + (-29.17040 2.67419) + (-26.82750 -1.61810) + (-18.59870 1.34568) + (-19.72160 -2.85972) + (-29.43650 0.54603) + (-23.63120 -1.47813) + (-28.20100 -1.98501) + (-41.20700 -1.11808) + (-33.14310 -2.19369) + (-31.54010 1.43134) + (-47.62740 1.28571) + (-28.79740 -1.03754) + (-34.97950 0.37740) + (-39.05770 -0.57557) + (-38.84060 2.34836) + (-40.18090 -0.96978) + (-47.32150 2.14768) + (-45.49290 2.52100) + (-40.57100 -1.39905) + (-47.19530 -2.23994) + (-50.80920 2.97853) + (-48.13640 0.46815) + (-58.56890 -1.01821) + (-57.81200 -3.08971) + (-47.96870 -0.48657) + (-43.96100 -0.10311) + (-50.49810 -2.80977) + (-50.61640 -0.17212) + (-60.64640 -1.02433) + (-58.03410 1.06921) + (-55.46390 -2.04501) + (-54.31000 -1.53512) + (-52.78670 -1.49875) + (-57.99380 0.17697) + (-56.76990 2.28241) + (-54.17450 -1.85553) + (-62.58220 -2.40971) + (-59.86460 1.04782) + (-61.58570 1.56183) + (-52.62080 1.68360) + (-49.82940 -1.11019) + (-56.18160 -0.78538) + (-57.73320 -2.23918) + (-49.87560 3.09604) + (-51.00100 -0.53762) + (-59.71530 0.99017) + (-65.73280 2.43855) + (-73.01270 -0.90664) + (-61.81450 -0.53346) + (-65.58980 1.51174) + (-75.94320 -3.06072) + (-65.22210 -1.49937) + (-70.79970 -2.96199) + (-64.72450 1.78172) + (-73.24130 0.26939) + (-66.17110 -0.23305) + (-61.32910 -3.12592) + (-66.98180 0.64700) + (-65.23060 -2.94395) + (-70.13430 1.29805) + (-68.43470 -1.35906) + (-71.33000 -2.71582) + (-86.90080 2.11646) + (-74.97450 2.76118) + (-68.02520 0.94979) + (-67.32960 3.05994) + (-67.32140 -2.79905) + (-68.22010 -2.33831))) + +(define vlc-partial + (lambda (in freq detune fall) + (lambda (n) + (let* ((m (* n 2)) + (ampl (buf-rd 1 kr 0 m 0 0))) + (mul (ringz in + (mul3 freq + (+ n 1) + (mul-add (lf-noise1 kr 1) detune 1.0)) + (mul fall (rand 0.75 1.25))) + ampl))))) + +(define vlc-plyr + (lambda (n) + (letc ((buf 0) + (iamp 0.1) + (ampl 0.1) + (freq 129.897) + (fall 0.5) + (loc 0.0) + (detune 0.001)) + (let* ((i (mul (sound-in 4) iamp)) + (s (foldl1 add + (map (vlc-partial i freq detune fall) + (enum-from-to 0 (- n 1)))))) + (mrg2 (detect-silence s 0.001 0.2 remove-synth) + (out 0 (clip2 (pan2 s loc ampl) 0.1))))))) + +(define vlc-get-cps + (lambda (b) + (midi-cps (+ (choose b) + (s:degree-to-key (choose (list 0 1 2 3 4 5 6 7 8)) + (list 0 2 3 5 7 8 10) + 12))))) + +(define pattern + (lambda (fd) + (send fd (n-set1 1002 "freq" (vlc-get-cps (list 24 36 48 60)))) + (send fd (n-set1 1002 "iamp" (random 0.5 0.75))) + (thread-sleep (choose (list 0.5 0.75 1.5 3.0))) + (pattern fd))) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 (* (length vlc) 2) 1)) + (send fd (b-setn1 0 0 (flatten (map prep vlc)))) + (send-synth fd "vlc-plyr48" (vlc-plyr 48)) + (send fd (s-new "vlc-plyr48" 1002 add-to-tail 1 + (list "buf" 0 + "loc" (random -1 1) + "ampl" (random 0.05 0.1) + "freq" (vlc-get-cps (list 48 55 60)) + "detune" (random 0.001 0.005) + "fall" (random 1 7)))) + (pattern fd))) diff --git a/rsc3/examples/graph/voscil.scm b/rsc3/examples/graph/voscil.scm new file mode 100644 index 0000000..696ee56 --- /dev/null +++ b/rsc3/examples/graph/voscil.scm @@ -0,0 +1,33 @@ +;; voscil (rd) + +(import (rnrs) (rhs) (sosc) (rsc3)) + +(define voscil + (lambda (b) + (let* ((hb (/ (- b 1) 2)) + (r 6) + (f 600)) + (add + (pan2 (add (v-osc ar (mul-add (lf-noise0 kr r) hb hb) (* f 2) 0) + (mul (blip ar + (mul-add (lf-noise0 kr r) 40 600) + (mul-add (lf-noise0 kr r) 16 24)) + (mul-add (lf-noise0 kr r) 0.1 0.1))) + (lf-noise0 kr r) + (mul-add (lf-noise0 kr r) 0.5 0.5)) + (pan2 (v-osc ar (mul-add (lf-saw kr (/ 1 r) 0) hb hb) f 0) + (lf-noise0 kr r) + (mul-add (lf-noise0 kr r) 0.5 0.5)))))) + +(let ((n (* 8192 4)) + (b 32)) + (with-sc3 + (lambda (fd) + (for-each + (lambda (i) + (async fd (b-alloc i n 1)) + (replicate-m + (i-random 2 512) + (send fd (b-set1 i (i-random 0 n) (random -1 1))))) + (enum-from-to 0 (- b 1))) + (play fd (out 0 (voscil b)))))) \ No newline at end of file diff --git a/rsc3/examples/graph/what-was-i-thinking.scm b/rsc3/examples/graph/what-was-i-thinking.scm new file mode 100644 index 0000000..eedb714 --- /dev/null +++ b/rsc3/examples/graph/what-was-i-thinking.scm @@ -0,0 +1,21 @@ +;; what was i thinking? (jmcc) + +(import (rnrs) (rsc3)) + +(define what-was-i-thinking + (let* ((n0 (mul-add (lf-noise1 kr 0.2) 2000 2400)) + (n1 (mul-add (lf-noise1 kr 0.157) 0.4 0.5)) + (i (mul3 (lf-pulse ar 0.1 0 0.05) (impulse ar 8 0) 500)) + (d (decay i 2)) + (f (u:max (add (sin-osc kr 4 0) 80) d)) + (p (mul (pulse ar f n1) 0.04)) + (z (rlpf p n0 0.2)) + (c (lambda (x) + (let* ((r (rand 0 0.3)) + (n (mul-add (lf-noise1 kr r) 0.025 0.035))) + (comb-l x 0.06 n 1)))) + (y (mul z 0.6))) + (add z (mce2 (add (c y) (c y)) + (add (c y) (c y)))))) + +(audition (out 0 what-was-i-thinking)) diff --git a/rsc3/examples/graph/wial.scm b/rsc3/examples/graph/wial.scm new file mode 100644 index 0000000..96304af --- /dev/null +++ b/rsc3/examples/graph/wial.scm @@ -0,0 +1,43 @@ +;; wial (rd) + +(import (rnrs) (rhs) (rsc3)) + +(define pls + (lambda (clk div frq) + (let* ((t (pulse-divider clk div 0)) + (e (decay2 t 0.05 0.75)) + (f (mul-add (toggle-ff t) frq (mul 2 frq)))) + (foldl1 mul (list (sin-osc ar f 0) + e + (ti-rand 0 1 t) + 0.5))))) + +(define plss + (lambda (clk descr) + (mix + (make-mce + (map (lambda (l) + (let ((d (list-ref l 0)) + (f (list-ref l 1)) + (a (list-ref l 2))) + (mul (pls clk d f) a))) + descr))))) + +(define smpl + (lambda (f) + (list (list (mce2 4 6) f 0.75) + (list (mce2 2 6) (mul f 2) 0.75) + (list (mce2 1 2) (mul f 16) 0.025) + (list (mce2 1 5) (mul f 64) 0.005) + (list (mce2 1 3) (mul f 128) 0.035) + (list (mce2 1 4) (mul f 256) 0.15) + (list (mce2 2 3) (mul f 512) 0.35)))) + +(define wial + (let ((clk (impulse ar 16 0))) + (plss clk (smpl (tw-choose (dust kr 1) + (mce2 (* 20 2/3) 20) + (mce2 0.25 0.75) + 0))))) + +(audition (out 0 wial)) diff --git a/rsc3/examples/graph/wind-metals.scm b/rsc3/examples/graph/wind-metals.scm new file mode 100644 index 0000000..8a65f48 --- /dev/null +++ b/rsc3/examples/graph/wind-metals.scm @@ -0,0 +1,19 @@ +;; wind-metals (jmcc) + +(import (rnrs) (rhs) (rsc3)) + +(define wind-metals + (let* ((n 6) + (base (exp-rand 60 4000)) + (range (rand 500 8000)) + (n0 (clone 2 (brown-noise ar))) + (r0 (exp-rand 0.125 0.5)) + (n1 (lf-noise1 kr r0)) + (f (replicate-m n (rand base (add base range)))) + (dt (replicate-m n (rand 0.1 2))) + (exc (mul3 n0 0.007 (u:max 0 (mul-add n1 0.75 0.25)))) + (k (klank-data f (replicate n 1) dt)) + (s (klank exc 1 0 1 k))) + (soft-clip (mul s 0.1)))) + +(audition (out 0 wind-metals)) diff --git a/rsc3/examples/graph/xy-interference.scm b/rsc3/examples/graph/xy-interference.scm new file mode 100644 index 0000000..94a1aad --- /dev/null +++ b/rsc3/examples/graph/xy-interference.scm @@ -0,0 +1,15 @@ +;; xy-interference (rd) + +(import (rnrs) (rsc3)) + +(define xy-interference + (let* ((x (mouse-x kr 20 22000 1 (mce2 0.005 0.025))) + (y (mouse-y kr 20 22000 1 (mce2 0.005 0.075))) + (nd (lambda (_) + (let* ((n (lf-noise0 kr (mce2 5 9))) + (a (sin-osc ar (add x n) 0)) + (b (sin-osc ar y 0))) + (mul a b))))) + (mix-fill 3 nd))) + +(audition (out 0 xy-interference)) \ No newline at end of file diff --git a/rsc3/examples/server-command/b-alloc.help.scm b/rsc3/examples/server-command/b-alloc.help.scm new file mode 100644 index 0000000..64ab5f5 --- /dev/null +++ b/rsc3/examples/server-command/b-alloc.help.scm @@ -0,0 +1,10 @@ +; /b_alloc Allocate buffer space. + +; int - buffer number +; int - number of frames +; int - number of channels (optional. default = 1 channel) +; bytes - an OSC message to execute upon completion. (optional) + +; Allocates zero filled buffer to number of channels and samples. + +; Asynchronous. Replies to sender with /done when complete. diff --git a/rsc3/examples/server-command/b-allocRead.help.scm b/rsc3/examples/server-command/b-allocRead.help.scm new file mode 100644 index 0000000..a885fb2 --- /dev/null +++ b/rsc3/examples/server-command/b-allocRead.help.scm @@ -0,0 +1,16 @@ +; /b_allocRead Allocate buffer space and read a sound file. + +; int - buffer number +; string - path name of a sound file. +; int - starting frame in file (optional. default = 0) +; int - number of frames to read (optional. default = 0, see below) +; bytes - an OSC message to execute upon completion. (optional) + +; Allocates buffer to number of channels of file and number of samples +; requested, or fewer if sound file is smaller than requested. Reads +; sound file data from the given starting frame in the file. If the +; number of frames argument is less than or equal to zero, the entire +; file is read. + +; Asynchronous. Replies to sender with /done when complete. + diff --git a/rsc3/examples/server-command/b-close.help.scm b/rsc3/examples/server-command/b-close.help.scm new file mode 100644 index 0000000..4cbd357 --- /dev/null +++ b/rsc3/examples/server-command/b-close.help.scm @@ -0,0 +1,6 @@ +; /b_close + +; int - buffer number + +; After using a buffer with DiskOut, close the soundfile and write +; header information. diff --git a/rsc3/examples/server-command/b-fill.help.scm b/rsc3/examples/server-command/b-fill.help.scm new file mode 100644 index 0000000..a5d5f02 --- /dev/null +++ b/rsc3/examples/server-command/b-fill.help.scm @@ -0,0 +1,13 @@ +; /b_fill Fill ranges of sample value(s) + +; int - buffer number +; [ +; int - sample starting index +; int - number of samples to fill (M) +; float - value +; ] * N + +; Set contiguous ranges of sample indices to single values. For each +; range, the starting sample index is given followed by the number of +; samples to change, followed by the value to fill. This is only meant +; for setting a few samples, not whole buffers or large sections. diff --git a/rsc3/examples/server-command/b-free.help.scm b/rsc3/examples/server-command/b-free.help.scm new file mode 100644 index 0000000..9979406 --- /dev/null +++ b/rsc3/examples/server-command/b-free.help.scm @@ -0,0 +1,8 @@ +; /b_free Free buffer data. + +; int - buffer number +; bytes - an OSC message to execute upon completion. (optional) + +; Frees buffer space allocated for this buffer. + +; Asynchronous. Replies to sender with /done when complete. diff --git a/rsc3/examples/server-command/b-gen.help.scm b/rsc3/examples/server-command/b-gen.help.scm new file mode 100644 index 0000000..b3eb13c --- /dev/null +++ b/rsc3/examples/server-command/b-gen.help.scm @@ -0,0 +1,81 @@ +; /b_gen Call a command to fill a buffer + +; int - buffer number +; string - command name +; .. command arguments + +; Plug-ins can define commands that operate on buffers. The arguments +; after the command name are defined by the command. The currently +; defined buffer fill commands are listed below in a separate section. + +; Buffer Fill Commands + +; These are the currently defined fill routines for use with the +; /b_gen command. + +; Common flags are defined as follows: + +; 1 - normalize Normalize peak amplitude of wave to 1.0. +; 2 - wavetable If set, then the buffer is written in wavetable +; format so that it can be read by interpolating +; oscillators. +; 4 - clear If set then the buffer is cleared before new partials +; are written into it. Otherwise the new partials are +; summed with the existing contents of the buffer. + +; sine1 +; int - flags, see above +; [ +; float - partial amplitude +; ] * N + +; Fills a buffer with a series of sine wave partials. The first float +; value specifies the amplitude of the first partial, the second float +; value specifies the amplitude of the second partial, and so on. + +; sine2 +; int - flags, see above +; [ +; float - partial frequency (in cycles per buffer) +; float - partial amplitude +; ] * N + +; Similar to sine1 except that each partial frequency is specified +; explicitly instead of being an integer series of +; partials. Non-integer partial frequencies are possible. + +; sine3 +; int - flags, see above +; [ +; float - partial frequency (in cycles per buffer) +; float - partial amplitude +; float - partial phase +; ] * N + +; Similar to sine2 except that each partial may have a nonzero +; starting phase. + +; cheby +; int - flags, see above +; [ +; float - amplitude +; ] * N + +; Fills a buffer with a series of chebyshev polynomials, which can be +; defined as: cheby(n) = amplitude * cos(n * acos(x)). The first +; float value specifies the amplitude for n = 1, the second float +; value specifies the amplitude for n = 2, and so on. To eliminate a +; DC offset when used as a waveshaper, the wavetable is offset so that +; the center value is zero. + +; copy +; int - sample position in destination +; int - source buffer number +; int - sample position in source +; int - number of samples to copy + +; Copy samples from the source buffer to the destination buffer +; specified in the b_gen command. If the number of samples to copy is +; negative, the maximum number of samples possible is copied. +; Asynchronous. Replies to sender with /done when complete. + diff --git a/rsc3/examples/server-command/b-get.help.scm b/rsc3/examples/server-command/b-get.help.scm new file mode 100644 index 0000000..9956153 --- /dev/null +++ b/rsc3/examples/server-command/b-get.help.scm @@ -0,0 +1,8 @@ +; /b_get Get sample value(s) + +; int - buffer number +; [ +; int - a sample index +; ] * N + +; Replies to sender with the corresponding /b_set command. diff --git a/rsc3/examples/server-command/b-getn.help.scm b/rsc3/examples/server-command/b-getn.help.scm new file mode 100644 index 0000000..95e4432 --- /dev/null +++ b/rsc3/examples/server-command/b-getn.help.scm @@ -0,0 +1,11 @@ +; /b_getn Get ranges of sample value(s) + +; int - buffer number +; [ +; int - starting sample index +; int - number of sequential samples to get (M) +; ] * N + +; Get contiguous ranges of samples. Replies to sender with the +; corresponding /b_setn command. This is only meant for getting a few +; samples, not whole buffers or large sections. diff --git a/rsc3/examples/server-command/b-query.help.scm b/rsc3/examples/server-command/b-query.help.scm new file mode 100644 index 0000000..579b5fb --- /dev/null +++ b/rsc3/examples/server-command/b-query.help.scm @@ -0,0 +1,20 @@ +; /b_query + +; [ +; int - buffer number +; ] * N + +; Responds to the sender with a /b_info message. The arguments to +; /b_info are as follows: + +; [ +; int - buffer number +; int - number of frames +; int - number of channels +; float - sample rate +; ] * N + +(with-sc3 + (lambda (fd) + (async fd (/b_alloc 10 6 1)) + (async fd (/b_query 10)))) diff --git a/rsc3/examples/server-command/b-read.help.scm b/rsc3/examples/server-command/b-read.help.scm new file mode 100644 index 0000000..0574299 --- /dev/null +++ b/rsc3/examples/server-command/b-read.help.scm @@ -0,0 +1,17 @@ +; /b_read Read sound file data into an existing buffer. + +; int - buffer number +; string - path name of a sound file. +; int - starting frame in file (optional. default = 0) +; int - number of frames to read (optional. default = -1, see below) +; int - starting frame in buffer (optional. default = 0) +; int - leave file open (optional. default = 0) +; bytes - an OSC message to execute upon completion. (optional) + +; Reads sound file data from the given starting frame in the file and +; writes it to the given starting frame in the buffer. If number of +; frames is less than zero, the entire file is read. If reading a +; file to be used by DiskIn ugen then you will want to set "leave file +; open" to one, otherwise set it to zero. + +; Asynchronous. Replies to sender with /done when complete. diff --git a/rsc3/examples/server-command/b-set.help.scm b/rsc3/examples/server-command/b-set.help.scm new file mode 100644 index 0000000..7fa41ac --- /dev/null +++ b/rsc3/examples/server-command/b-set.help.scm @@ -0,0 +1,11 @@ +; /b_set Set sample value(s) + +; int - buffer number +; [ +; int - a sample index +; float - a sample value +; ] * N + +; Takes a list of pairs of sample indices and values and sets the +; samples to those values. + diff --git a/rsc3/examples/server-command/b-setn.help.scm b/rsc3/examples/server-command/b-setn.help.scm new file mode 100644 index 0000000..9d19863 --- /dev/null +++ b/rsc3/examples/server-command/b-setn.help.scm @@ -0,0 +1,15 @@ +; /b_setn Set ranges of sample value(s) + +; int - buffer number +; [ +; int - sample starting index +; int - number of sequential samples to change (M) +; [ +; float - a sample value +; ] * M +; ] * N + +; Set contiguous ranges of sample indices to sets of values. For each +; range, the starting sample index is given followed by the number of +; samples to change, followed by the values. + diff --git a/rsc3/examples/server-command/b-write.help.scm b/rsc3/examples/server-command/b-write.help.scm new file mode 100644 index 0000000..d3ecdcf --- /dev/null +++ b/rsc3/examples/server-command/b-write.help.scm @@ -0,0 +1,27 @@ +; /b_write Write sound file data. + +; int - buffer number +; string - path name of a sound file. +; string - header format. +; string - sample format. +; int - number of frames to write (optional. default = -1, see below) +; int - starting frame in buffer (optional. default = 0) +; int - leave file open (optional. default = 0) +; bytes - an OSC message to execute upon completion. (optional) + +; Write a buffer as a sound file. +; Header format is one of: +; "aiff", "next", "wav", "ircam"", "raw" +; Sample format is one of: +; "int8", "int16", "int24", "int32", "float", "double", "mulaw", "alaw" + +; Not all combinations of header format and sample format are +; possible. If number of frames is less than zero, all samples from +; the starting frame to the end of the buffer are written. If opening +; a file to be used by DiskOut ugen then you will want to set "leave +; file open" to one, otherwise set it to zero. If "leave file open" is +; set to one then the file is created, but no frames are written until +; the DiskOut ugen does so. + +; Asynchronous. Replies to sender with /done when complete. + diff --git a/rsc3/examples/server-command/b-zero.help.scm b/rsc3/examples/server-command/b-zero.help.scm new file mode 100644 index 0000000..ee8fb11 --- /dev/null +++ b/rsc3/examples/server-command/b-zero.help.scm @@ -0,0 +1,8 @@ +; /b_zero Zero sample data + +; int - buffer number +; bytes - an OSC message to execute upon completion. (optional) + +; Sets all samples in the buffer to zero. + +; Asynchronous. Replies to sender with /done when complete. diff --git a/rsc3/examples/server-command/c-fill.help.scm b/rsc3/examples/server-command/c-fill.help.scm new file mode 100644 index 0000000..fbe6b04 --- /dev/null +++ b/rsc3/examples/server-command/c-fill.help.scm @@ -0,0 +1,11 @@ +; /c_fill Fill ranges of bus value(s) + +; [ +; int - starting bus index +; int - number of buses to fill (M) +; float - value +; ] * N + +; Set contiguous ranges of buses to single values. For each range, the +; starting sample index is given followed by the number of buses to +; change, followed by the value to fill. diff --git a/rsc3/examples/server-command/c-get.help.scm b/rsc3/examples/server-command/c-get.help.scm new file mode 100644 index 0000000..2a1c4fb --- /dev/null +++ b/rsc3/examples/server-command/c-get.help.scm @@ -0,0 +1,9 @@ +;/c_get Get bus value(s) + +; [ +; int - a bus index +; ] * N + +; Takes a list of buses and replies to sender with the corresponding +; /c_set command. + diff --git a/rsc3/examples/server-command/c-getn.help.scm b/rsc3/examples/server-command/c-getn.help.scm new file mode 100644 index 0000000..6ab8ed0 --- /dev/null +++ b/rsc3/examples/server-command/c-getn.help.scm @@ -0,0 +1,9 @@ +; /c_getn Get ranges of bus value(s) + +; [ +; int - starting bus index +; int - number of sequential buses to get (M) +; ] * N + +; Get contiguous ranges of buses. Replies to sender with the +; corresponding /c_setn command. diff --git a/rsc3/examples/server-command/c-setn.help.scm b/rsc3/examples/server-command/c-setn.help.scm new file mode 100644 index 0000000..618c685 --- /dev/null +++ b/rsc3/examples/server-command/c-setn.help.scm @@ -0,0 +1,13 @@ +; /c_setn Set ranges of bus value(s) + +; [ +; int - starting bus index +; int - number of sequential buses to change (M) +; [ +; float - a control value +; ] * M +; ] * N + +; Set contiguous ranges of buses to sets of values. For each range, the +; starting bus index is given followed by the number of channels to +; change, followed by the values. diff --git a/rsc3/examples/server-command/c_set.help.scm b/rsc3/examples/server-command/c_set.help.scm new file mode 100644 index 0000000..335844f --- /dev/null +++ b/rsc3/examples/server-command/c_set.help.scm @@ -0,0 +1,9 @@ +; /c_set Set bus value(s) + +; [ +; int - a bus index +; float - a control value +; ] * N + +; Takes a list of pairs of bus indices and values and sets the buses to +; those values. diff --git a/rsc3/examples/server-command/clearSched.help.scm b/rsc3/examples/server-command/clearSched.help.scm new file mode 100644 index 0000000..ce4eaa7 --- /dev/null +++ b/rsc3/examples/server-command/clearSched.help.scm @@ -0,0 +1,3 @@ +; /clearSched Clear all scheduled bundles. + +; Removes all bundles from the scheduling queue. diff --git a/rsc3/examples/server-command/d-free.help.scm b/rsc3/examples/server-command/d-free.help.scm new file mode 100644 index 0000000..38d6e2a --- /dev/null +++ b/rsc3/examples/server-command/d-free.help.scm @@ -0,0 +1,7 @@ +;; /d_free delete synth definition + +;; [ +;; string - synth def name +;; ] * N + +;; Removes a synth definition once all synths using it have ended. diff --git a/rsc3/examples/server-command/d-load.help.scm b/rsc3/examples/server-command/d-load.help.scm new file mode 100644 index 0000000..3f23dac --- /dev/null +++ b/rsc3/examples/server-command/d-load.help.scm @@ -0,0 +1,9 @@ +; /d_load Load synth definition + +; string - pathname of file. Can be a pattern like "synthdefs/perc-*" +; bytes - an OSC message to execute upon completion. (optional) + +; Loads a file of synth definitions. Resident definitions with the same +; names are overwritten. + +; Asynchronous. Replies to sender with /done when complete. diff --git a/rsc3/examples/server-command/d-recv.help.scm b/rsc3/examples/server-command/d-recv.help.scm new file mode 100644 index 0000000..c12d8b2 --- /dev/null +++ b/rsc3/examples/server-command/d-recv.help.scm @@ -0,0 +1,9 @@ +; /d_recv Receive a synth definition file + +; bytes - buffer of data. +; bytes - an OSC message to execute upon completion. (optional) + +; Loads a file of synth definitions from a buffer in the +; message. Resident definitions with the same names are overwritten. + +; Asynchronous. Replies to sender with /done when complete. diff --git a/rsc3/examples/server-command/dumpOSC.help.scm b/rsc3/examples/server-command/dumpOSC.help.scm new file mode 100644 index 0000000..c60f425 --- /dev/null +++ b/rsc3/examples/server-command/dumpOSC.help.scm @@ -0,0 +1,12 @@ +; /dumpOSC Display incoming OSC messages + +; int - code + +; Turns on and off printing of the contents of incoming Open Sound +; Control messages. This is useful when debugging your command stream. + +; The values for the code are as follows: +; 0 - turn dumping OFF. +; 1 - print the parsed contents of the message. +; 2 - print the contents in hexadecimal. +; 3 - print both the parsed and hexadecimal representations of the contents. diff --git a/rsc3/examples/server-command/g-deepFree.help.scm b/rsc3/examples/server-command/g-deepFree.help.scm new file mode 100644 index 0000000..fabbe98 --- /dev/null +++ b/rsc3/examples/server-command/g-deepFree.help.scm @@ -0,0 +1,9 @@ +; /g_deepFree Free all synths in this group and all its sub-groups. + +; [ +; int - group ID +; ] * N + +; Traverses all groups below this group and frees all the +; synths. Sub-groups are not freed. A list of groups may be specified. + diff --git a/rsc3/examples/server-command/g-freeAll.help.scm b/rsc3/examples/server-command/g-freeAll.help.scm new file mode 100644 index 0000000..eb74600 --- /dev/null +++ b/rsc3/examples/server-command/g-freeAll.help.scm @@ -0,0 +1,7 @@ +; /g_freeAll Delete all nodes in a group. + +; [ +; int - group ID +; ] * N + +; Frees all nodes in the group. A list of groups may be specified. diff --git a/rsc3/examples/server-command/g-head.help.scm b/rsc3/examples/server-command/g-head.help.scm new file mode 100644 index 0000000..3e01f0c --- /dev/null +++ b/rsc3/examples/server-command/g-head.help.scm @@ -0,0 +1,8 @@ +; /g_head Add node to head of group + +; [ +; int - group ID +; int - node ID +; ] * N + +; Adds the node to the head (first to be executed) of the group. diff --git a/rsc3/examples/server-command/g-new.help.scm b/rsc3/examples/server-command/g-new.help.scm new file mode 100644 index 0000000..6d42a9b --- /dev/null +++ b/rsc3/examples/server-command/g-new.help.scm @@ -0,0 +1,31 @@ +; /g_new Create a new group + +; [ +; int - new group ID +; int - add action (0,1,2, 3 or 4 see below) +; int - add target ID +; ] * N + +; Create a new group and add it to the tree of nodes. + +; There are four ways to add the group to the tree as determined by +; the add action argument which is defined as follows (the same as +; for "/s_new"): + +; 0 - add the new group to the the head of the group specified by +; the add target ID. + +; 1 - add the new group to the the tail of the group specified by +; the add target ID. + +; 2 - add the new group just before the node specified by the add +; target ID. + +; 3 - add the new group just after the node specified by the add +; target ID. + +; 4 - the new node replaces the node specified by the add target +; ID. The target node is freed. + +; Multiple groups may be created in one command by adding +; arguments. diff --git a/rsc3/examples/server-command/g-new1.help.scm b/rsc3/examples/server-command/g-new1.help.scm new file mode 100644 index 0000000..d2d93ba --- /dev/null +++ b/rsc3/examples/server-command/g-new1.help.scm @@ -0,0 +1 @@ +; see g-new diff --git a/rsc3/examples/server-command/g-tail.help.scm b/rsc3/examples/server-command/g-tail.help.scm new file mode 100644 index 0000000..5091106 --- /dev/null +++ b/rsc3/examples/server-command/g-tail.help.scm @@ -0,0 +1,9 @@ +; /g_tail Add node to tail of group + +; [ +; int - group ID +; int - node ID +; ] * N + +; Adds the node to the tail (last to be executed) of the group. + diff --git a/rsc3/examples/server-command/n-after.help.scm b/rsc3/examples/server-command/n-after.help.scm new file mode 100644 index 0000000..f8e201b --- /dev/null +++ b/rsc3/examples/server-command/n-after.help.scm @@ -0,0 +1,9 @@ +; /n_after Place a node after another + +; [ +; int - the ID of the node to place (A) +; int - the ID of the node after which the above is placed (B) +; ] * N + +; Places node A in the same group as node B, to execute immediately +; after node B. diff --git a/rsc3/examples/server-command/n-before.help.scm b/rsc3/examples/server-command/n-before.help.scm new file mode 100644 index 0000000..363b9d6 --- /dev/null +++ b/rsc3/examples/server-command/n-before.help.scm @@ -0,0 +1,9 @@ +; /n_before Place a node before another + +; [ +; int - the ID of the node to place (A) +; int - the ID of the node before which the above is placed (B) +; ] * N + +; Places node A in the same group as node B, to execute immediately +; before node B. diff --git a/rsc3/examples/server-command/n-fill.help.scm b/rsc3/examples/server-command/n-fill.help.scm new file mode 100644 index 0000000..edfd0c1 --- /dev/null +++ b/rsc3/examples/server-command/n-fill.help.scm @@ -0,0 +1,13 @@ +; /n_fill Fill ranges of a node's control value(s) + +; int - node ID +; [ +; int or string - a control index or name +; int - number of values to fill (M) +; float - value +; ] * N + +; Set contiguous ranges of control indices to single values. For each +; range, the starting control index is given followed by the number of +; controls to change, followed by the value to fill. If the node is a +; group, then it sets the controls of every node in the group. diff --git a/rsc3/examples/server-command/n-free.help.scm b/rsc3/examples/server-command/n-free.help.scm new file mode 100644 index 0000000..2572e13 --- /dev/null +++ b/rsc3/examples/server-command/n-free.help.scm @@ -0,0 +1,9 @@ +; /n_free Delete a node. + +; [ +; int - node ID +; ] * N + +; Stops a node abruptly, removes it from its group, and frees its +; memory. A list of node IDs may be specified. Using this method can +; cause a click if the node is not silent at the time it is freed. diff --git a/rsc3/examples/server-command/n-map.help.scm b/rsc3/examples/server-command/n-map.help.scm new file mode 100644 index 0000000..75569ca --- /dev/null +++ b/rsc3/examples/server-command/n-map.help.scm @@ -0,0 +1,15 @@ +; /n_map Map a node's controls to read from a bus + +; int - node ID +; [ +; int or string - a control index or name +; int - control bus index +; ] * N + +; Takes a list of pairs of control names or indices and bus indices and +; causes those controls to be read continuously from a global control +; bus instead of responding to n_set, n_setn and n_fill commands. If the +; node is a group, then it maps the controls of every node in the +; group. If the control bus index is -1 then any current mapping is +; undone and control reverts to normal. + diff --git a/rsc3/examples/server-command/n-mapn.help.scm b/rsc3/examples/server-command/n-mapn.help.scm new file mode 100644 index 0000000..8052b31 --- /dev/null +++ b/rsc3/examples/server-command/n-mapn.help.scm @@ -0,0 +1,16 @@ +; /n_mapn Map a node's controls to read from buses + +; int - node ID +; [ +; int or string - a control index or name +; int - control bus index +; int - number of controls to map +; ] * N + +; Takes a list of triplets of control names or indices, bus indices, and +; number of controls to map and causes those controls to be mapped +; sequentially to buses. If the node is a group, then it maps the +; controls of every node in the group. If the control bus index is -1 +; then any current mapping is undone and control reverts to normal. + +; See also: /n_map diff --git a/rsc3/examples/server-command/n-query.help.scm b/rsc3/examples/server-command/n-query.help.scm new file mode 100644 index 0000000..0683e73 --- /dev/null +++ b/rsc3/examples/server-command/n-query.help.scm @@ -0,0 +1,10 @@ +; /n_query Get info about a node + +; [ +; int - node ID +; ] * N + +; The server sends an /n_info message for each node to registered +; clients. + +; See Node Notifications below for the format of the /n_info message. diff --git a/rsc3/examples/server-command/n-run.help.scm b/rsc3/examples/server-command/n-run.help.scm new file mode 100644 index 0000000..c542661 --- /dev/null +++ b/rsc3/examples/server-command/n-run.help.scm @@ -0,0 +1,11 @@ +; /n_run Turn node on or off + +; [ +; int - node ID +; int - run flag +; ] * N + +; If the run flag set to zero then the node will not be executed. If +; the run flag is set back to one, then it will be executed. Using +; this method to start and stop nodes can cause a click if the node is +; not silent at the time run flag is toggled. diff --git a/rsc3/examples/server-command/n-set.help.scm b/rsc3/examples/server-command/n-set.help.scm new file mode 100644 index 0000000..98cdbb4 --- /dev/null +++ b/rsc3/examples/server-command/n-set.help.scm @@ -0,0 +1,27 @@ +; /n_set Set a node's control value(s) + +; int - node ID +; [ +; int or string - a control index or name +; float - a control value +; ] * N + +; Takes a list of pairs of control indices and values and sets the +; controls to those values. If the node is a group, then it sets the +; controls of every node in the group. + +(with-sc3 + (lambda (fd) + (letc ((f 440) + (a 0.1)) + (send-synth fd "sin" (out 0 (mul (sin-osc ar f 0) a)))) + (send fd (s-new0 "sin" 1001 add-to-tail 1)))) + +(with-sc3 + (lambda (fd) + (send fd (n-set1 1001 "f" 1280)))) + +(with-sc3 + (lambda (fd) + (send fd (n-set 1001 (list (tuple2 "f" (random 60 900)) + (tuple2 "a" (random 0.05 0.25))))))) diff --git a/rsc3/examples/server-command/n-set1.help.scm b/rsc3/examples/server-command/n-set1.help.scm new file mode 100644 index 0000000..6fe6132 --- /dev/null +++ b/rsc3/examples/server-command/n-set1.help.scm @@ -0,0 +1 @@ +; see n-set diff --git a/rsc3/examples/server-command/n-setn.help.scm b/rsc3/examples/server-command/n-setn.help.scm new file mode 100644 index 0000000..b265428 --- /dev/null +++ b/rsc3/examples/server-command/n-setn.help.scm @@ -0,0 +1,15 @@ +; /n_setn Set ranges of a node's control value(s) + +; int - node ID +; [ +; int or string - a control index or name +; int - number of sequential controls to change (M) +; [ +; float - a control value +; ] * M +; ] * N + +; Set contiguous ranges of control indices to sets of values. For each +; range, the starting control index is given followed by the number of +; controls to change, followed by the values. If the node is a group, +; then it sets the controls of every node in the group. diff --git a/rsc3/examples/server-command/n-trace.help.scm b/rsc3/examples/server-command/n-trace.help.scm new file mode 100644 index 0000000..ca807c5 --- /dev/null +++ b/rsc3/examples/server-command/n-trace.help.scm @@ -0,0 +1,11 @@ +; /n_trace Trace a node + +; [ +; int - node ID +; ] * N + +; Causes a synth to print out the values of the inputs and outputs of +; its unit generators for one control period. Causes a group to print +; the node IDs and names of each node in the group for one control +; period. + diff --git a/rsc3/examples/server-command/notify.help.scm b/rsc3/examples/server-command/notify.help.scm new file mode 100644 index 0000000..fd75434 --- /dev/null +++ b/rsc3/examples/server-command/notify.help.scm @@ -0,0 +1,9 @@ +; /notify Register to receive notifications from server + +; int - one to receive notifications, zero to stop receiving them. + +; If argument is one, server will remember your return address and +; send you notifications. if argument is zero, server will stop +; sending you notifications. + +; Asynchronous. Replies to sender with /done when complete. diff --git a/rsc3/examples/server-command/nrt_end.help.scm b/rsc3/examples/server-command/nrt_end.help.scm new file mode 100644 index 0000000..f51f3f3 --- /dev/null +++ b/rsc3/examples/server-command/nrt_end.help.scm @@ -0,0 +1,10 @@ +;; /nrt_end end real time mode, close file + +;; **NOT YET IMPLEMENTED** + +;; no arguments. + +;; This message should be sent in a bundle in non real time mode. The +;; bundle timestamp will establish the ending time of the file. This +;; command will end non real time mode and close the sound file. +;; Replies to sender with /done when complete. diff --git a/rsc3/examples/server-command/quit.help.scm b/rsc3/examples/server-command/quit.help.scm new file mode 100644 index 0000000..6c215d1 --- /dev/null +++ b/rsc3/examples/server-command/quit.help.scm @@ -0,0 +1,7 @@ +; /quit Quit program + +; No arguments. + +; Exits the synthesis server. + +; Asynchronous. Replies to sender with /done just before completion. diff --git a/rsc3/examples/server-command/s-get.help.scm b/rsc3/examples/server-command/s-get.help.scm new file mode 100644 index 0000000..ad8a615 --- /dev/null +++ b/rsc3/examples/server-command/s-get.help.scm @@ -0,0 +1,8 @@ +; /s_get Get control value(s) + +; int - synth ID +; [ +; int or string - a control index or name +; ] * N + +; Replies to sender with the corresponding /n_set command. diff --git a/rsc3/examples/server-command/s-getn.help.scm b/rsc3/examples/server-command/s-getn.help.scm new file mode 100644 index 0000000..76ecc23 --- /dev/null +++ b/rsc3/examples/server-command/s-getn.help.scm @@ -0,0 +1,10 @@ +; /s_getn Get ranges of control value(s) + +; int - synth ID +; [ +; int|string - a control index or name +; int - number of sequential controls to get (M) +; ] * N + +; Get contiguous ranges of controls. Replies to sender with the +; corresponding /n_setn command. diff --git a/rsc3/examples/server-command/s-new.help.scm b/rsc3/examples/server-command/s-new.help.scm new file mode 100644 index 0000000..7007ca0 --- /dev/null +++ b/rsc3/examples/server-command/s-new.help.scm @@ -0,0 +1,47 @@ +; /s_new Create a new synth + +; string - synth definition name +; int - synth ID +; int - add action (0,1,2, 3 or 4 see below) +; int - add target ID +; [ +; int or string - a control index or name +; float - a control value +; ] * N + +; Create a new synth from a synth definition, give it an ID, and add it +; to the tree of nodes. There are four ways to add the node to the tree +; as determined by the add action argument which is defined as follows: + +; 0 - add the new node to the the head of the group specified by the +; add target ID. + +; 1 - add the new node to the the tail of the group specified by +; the add target ID. + +; 2 - add the new node just before the node specified by the add +; target ID. + +; 3 - add the new node just after the node specified by the add target +; ID. + +; 4 - the new node replaces the node specified by the add target +; ID. The target node is freed. + +; Controls may be set when creating the synth. The control arguments are +; the same as for the n_set command. + +; If you send /s_new with a synth ID of -1, then the server will +; generate an ID for you. The server reserves all negative IDs. Since +; you don't know what the ID is, you cannot talk to this node directly +; later. So this is useful for nodes that are of finite duration and +; that get the control information they need from arguments and buses or +; messages directed to their group. In addition no notifications are +; sent when there are changes of state for this node, such as /go, /end, +; /on, /off. + +; If you use a node ID of -1 for any other command, such as /n_map, then +; it refers to the most recently created node by /s_new (auto generated +; ID or not). This is how you can map the controls of a node with an +; auto generated ID. In a multi-client situation, the only way you can +; be sure what node -1 refers to is to put the messages in a bundle. diff --git a/rsc3/examples/server-command/s-new0.help.scm b/rsc3/examples/server-command/s-new0.help.scm new file mode 100644 index 0000000..c658a1e --- /dev/null +++ b/rsc3/examples/server-command/s-new0.help.scm @@ -0,0 +1 @@ +; see s-new diff --git a/rsc3/examples/server-command/s-noid.help.scm b/rsc3/examples/server-command/s-noid.help.scm new file mode 100644 index 0000000..51ff1aa --- /dev/null +++ b/rsc3/examples/server-command/s-noid.help.scm @@ -0,0 +1,11 @@ +; /s_noid Auto-reassign synth's ID to a reserved value + +; [ +; int - synth ID +; ] * N + +; This command is used when the client no longer needs to communicate +; with the synth and wants to have the freedom to reuse the ID. The +; server will reassign this synth to a reserved negative number. This +; command is purely for bookkeeping convenience of the client. No +; notification is sent when this occurs. diff --git a/rsc3/examples/server-command/status.help.scm b/rsc3/examples/server-command/status.help.scm new file mode 100644 index 0000000..fca4ce6 --- /dev/null +++ b/rsc3/examples/server-command/status.help.scm @@ -0,0 +1,18 @@ +; /status Query the status + +; No arguments. + +; Replies to sender with the following message. + +; /status.reply +; int - 1. unused. +; int - number of unit generators. +; int - number of synths. +; int - number of groups. +; int - number of loaded synth definitions. +; float - average percent CPU usage for signal processing +; float - peak percent CPU usage for signal processing +; double - nominal sample rate +; double - actual sample rate + + diff --git a/rsc3/examples/server-command/sync.help.scm b/rsc3/examples/server-command/sync.help.scm new file mode 100644 index 0000000..55e5149 --- /dev/null +++ b/rsc3/examples/server-command/sync.help.scm @@ -0,0 +1,9 @@ +; /sync Notify when async commands have completed. + +; int - a unique number identifying this command. + +; Replies with a /synced message when all asynchronous commands +; received before this one have completed. The reply will contain the +; sent unique ID. + +; Asynchronous. Replies to sender with /synced, ID when complete. diff --git a/rsc3/examples/server-command/tr.help.scm b/rsc3/examples/server-command/tr.help.scm new file mode 100644 index 0000000..64b71bc --- /dev/null +++ b/rsc3/examples/server-command/tr.help.scm @@ -0,0 +1,12 @@ +; /tr A trigger message + +; int - node ID +; int - trigger ID +; float - trigger value + +; This command is the mechanism that synths can use to trigger events +; in clients. + +; The node ID is the node that is sending the trigger. The trigger ID +; and value are determined by inputs to the SendTrig unit generator +; which is the originator of this message. diff --git a/rsc3/examples/server-command/u-cmd.help.scm b/rsc3/examples/server-command/u-cmd.help.scm new file mode 100644 index 0000000..6306290 --- /dev/null +++ b/rsc3/examples/server-command/u-cmd.help.scm @@ -0,0 +1,9 @@ +; /u_cmd send a command to a unit generator + +; int - node ID +; int - unit generator index +; string - command name +; ...any arguments + +; Sends all arguments following the command name to the unit generator +; to be performed. Commands are defined by unit generator plug ins. diff --git a/rsc3/examples/ugen/analysis/amplitude.help.scm b/rsc3/examples/ugen/analysis/amplitude.help.scm new file mode 100644 index 0000000..ec20b31 --- /dev/null +++ b/rsc3/examples/ugen/analysis/amplitude.help.scm @@ -0,0 +1,11 @@ +;; (amplitude rate in attackTime releaseTime) + +;; Amplitude follower. Tracks the peak amplitude of a signal. + +(audition + (out 0 (mul (pulse ar 90 0.3) + (amplitude kr (in 1 ar num-output-buses) 0.01 0.01)))) + +(let* ((a (amplitude kr (in 1 ar num-output-buses) 0.01 0.01)) + (f (mul-add a 1200 400))) + (audition (out 0 (mul (sin-osc ar f 0) 0.3)))) diff --git a/rsc3/examples/ugen/analysis/compander.help.scm b/rsc3/examples/ugen/analysis/compander.help.scm new file mode 100644 index 0000000..7c5cc14 --- /dev/null +++ b/rsc3/examples/ugen/analysis/compander.help.scm @@ -0,0 +1,67 @@ +;; (compander input control thresh slopeBelow slopeAbove clampTime relaxTime) + +;; Compressor, expander, limiter, gate, ducker. General purpose +;; dynamics processor. + +;; input: The signal to be compressed / expanded / gated. + +;; control: The signal whose amplitude determines the gain applied to +;; the input signal. Often the same as in (for standard +;; gating or compression) but should be different for +;; ducking. + +;; thresh: Control signal amplitude threshold, which determines the +;; break point between slopeBelow and slopeAbove. Usually +;; 0..1. The control signal amplitude is calculated using RMS. + +;; slopeBelow: slope of the amplitude curve below the threshold. If +;; this slope > 1.0, the amplitude will drop off more +;; quickly the softer the control signal gets when the +;; control signal is close to 0 amplitude, the output +;; should be exactly zero -- hence, noise gating. Values < +;; 1.0 are possible, but it means that a very low-level +;; control signal will cause the input signal to be +;; amplified, which would raise the noise floor. + +;; slopeAbove: Same thing, but above the threshold. Values < 1.0 +;; achieve compression (louder signals are attenuated) > +;; 1.0, you get expansion (louder signals are made even +;; louder). For 3:1 compression, you would use a value of +;; 1/3 here. + +;; clampTime: The amount of time it takes for the amplitude adjustment +;; to kick in fully. This is usually pretty small, not much +;; more than 10 milliseconds (the default value). + +;; relaxTime: The amount of time for the amplitude adjustment to be +;; released. Usually a bit longer than clampTime if both +;; times are too short, you can get some (possibly +;; unwanted) artifacts. + +;; Example signal to process. + +(define z + (mul (decay2 (mul (impulse ar 8 0) (mul (lf-saw kr 0.3 0) 0.3)) 0.001 0.3) + (mix (pulse ar (mce2 80 81) 0.3)))) + +(audition (out 0 z)) + +;; Noise gate + +(let ((x (mouse-x kr 0.01 1 0 0.1))) + (audition (out 0 (mce2 z (compander z z x 10 1 0.01 0.01))))) + +;; Compressor + +(let ((x (mouse-x kr 0.01 1 0 0.1))) + (audition (out 0 (mce2 z (compander z z x 1 0.5 0.01 0.01))))) + +;; limiter + +(let ((x (mouse-x kr 0.01 1 0 0.1))) + (audition (out 0 (mce2 z (compander z z x 1 0.1 0.01 0.01))))) + +;; Sustainer + +(let ((x (mouse-x kr 0.01 1 0 0.1))) + (audition (out 0 (mce2 z (compander z z x 0.1 1.0 0.01 0.01))))) diff --git a/rsc3/examples/ugen/analysis/pitch.help.scm b/rsc3/examples/ugen/analysis/pitch.help.scm new file mode 100644 index 0000000..f367678 --- /dev/null +++ b/rsc3/examples/ugen/analysis/pitch.help.scm @@ -0,0 +1,37 @@ +;; (pitch in initFreq minFreq maxFreq execFreq maxBinsPerOctave +;; median ampThreshold peakThreshold downSample) + +;; Autocorrelation pitch follower + +;; This is a better pitch follower than zero-crossing, but more costly +;; of CPU. For most purposes the default settings can be used and only +;; in needs to be supplied. pitch returns two values (via an Array of +;; outputProxys, see the outputProxy help file), a freq which is the +;; pitch estimate and hasFreq, which tells whether a pitch was +;; found. Some vowels are still problematic, for instance a wide open +;; mouth sound somewhere between a low pitched short 'a' sound as in +;; 'sat', and long 'i' sound as in 'fire', contains enough overtone +;; energy to confuse the algorithm. + +;; sclang default argument values are: in = 0.0, initFreq = 440.0, +;; minFreq = 60.0, maxFreq = 4000.0, execFreq = 100.0, +;; maxBinsPerOctave = 16, median = 1, ampThreshold = 0.01, +;; peakThreshold = 0.5, downSample = 1. + +(define (pitch* in median ampThreshold) + (pitch in 444.0 60.0 4000.0 100.0 16 median ampThreshold 0.5 1)) + +(let* ((in (mul (sin-osc ar (mouse-x kr 220 660 0 0.1) 0) + (mouse-y kr 0.05 0.25 0 0.1))) + (amp (amplitude kr in 0.05 0.05)) + (freq+ (pitch* in 7 0.02)) + (f (fdiv (car (mce-channels freq+)) 2)) + (o (mul (sin-osc ar f 0) amp))) + (audition (out 0 (mce2 in o)))) + +(let* ((in (sound-in 0)) + (amp (amplitude kr in 0.05 0.05)) + (freq+ (pitch* in 7 0.02)) + (f (car (mce-channels freq+))) + (o (mul (sin-osc ar f 0) amp))) + (audition (out 0 (mce2 in o)))) diff --git a/rsc3/examples/ugen/analysis/running-sum.help.scm b/rsc3/examples/ugen/analysis/running-sum.help.scm new file mode 100644 index 0000000..57744a1 --- /dev/null +++ b/rsc3/examples/ugen/analysis/running-sum.help.scm @@ -0,0 +1,14 @@ +;; (running-sum in numsamp) + +;; A running sum over a user specified number of samples, useful for +;; running RMS power windowing. + +;; in - input signal +;; numsamp - How many samples to take the running sum over +;; (initialisation rate) + +(let ((n 40)) + (audition + (out 0 (foldl1 mul (list (sin-osc ar 440 0) + (running-sum (sound-in (mce2 0 1)) n) + (recip n)))))) diff --git a/rsc3/examples/ugen/analysis/slope.help.scm b/rsc3/examples/ugen/analysis/slope.help.scm new file mode 100644 index 0000000..2c86bba --- /dev/null +++ b/rsc3/examples/ugen/analysis/slope.help.scm @@ -0,0 +1,19 @@ +;; (slope in) + +;; slope of signal. Measures the rate of change per second of a +;; signal. Formula implemented is: + +;; out[i] = (in[i] - in[i-1]) * sampling_rate + +;; in - input signal to measure. + +;; a = quadratic noise, b = first derivative line segments, c = second +;; derivative constant segments + +(let* ((r 2) + (a (lf-noise2 kr r)) + (scale (recip r)) + (b (mul (slope a) scale)) + (c (mul (slope b) (squared scale))) + (o (sin-osc ar (mul-add (mce3 a b c) 220 220) 0))) + (audition (out 0 (mix (mul o 1/3))))) diff --git a/rsc3/examples/ugen/analysis/zero-crossing.help.scm b/rsc3/examples/ugen/analysis/zero-crossing.help.scm new file mode 100644 index 0000000..51fedaa --- /dev/null +++ b/rsc3/examples/ugen/analysis/zero-crossing.help.scm @@ -0,0 +1,15 @@ +;; (zero-crossing in) + +;; Zero crossing frequency follower. + +;; outputs a frequency based upon the distance between interceptions +;; of the X axis. The X intercepts are determined via linear +;; interpolation so this gives better than just integer wavelength +;; resolution. This is a very crude pitch follower, but can be useful +;; in some situations. + +;; in - input signal. + +(let* ((a (mul (sin-osc ar (mul-add (sin-osc kr 1 0) 600 700) 0) 0.1)) + (b (mul (impulse ar (zero-crossing a) 0) 0.25))) + (audition (out 0 (mce2 a b)))) diff --git a/rsc3/examples/ugen/binary-ops/abs-dif.help.scm b/rsc3/examples/ugen/binary-ops/abs-dif.help.scm new file mode 100644 index 0000000..0b51cf7 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/abs-dif.help.scm @@ -0,0 +1,8 @@ +;; (abs-dif a b) + +;; Calculates the value of (abs (- a b). Finding the magnitude of the +;; difference of two values is a common operation. + +(audition + (out 0 (mul (f-sin-osc ar 440 0) + (abs-dif 0.2 (mul (f-sin-osc ar 2 0) 0.5))))) diff --git a/rsc3/examples/ugen/binary-ops/add.help.scm b/rsc3/examples/ugen/binary-ops/add.help.scm new file mode 100644 index 0000000..7cc1d6f --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/add.help.scm @@ -0,0 +1,12 @@ +;; (add a b) + +;; addition, written '+' in sclang. + +(audition + (out 0 (add (mul (f-sin-osc ar 800 0) 0.1) + (mul (pink-noise ar) 0.1)))) + +;; DC offset. + +(audition + (out 0 (add (f-sin-osc ar 440 0) 0.1))) diff --git a/rsc3/examples/ugen/binary-ops/am-clip.help.scm b/rsc3/examples/ugen/binary-ops/am-clip.help.scm new file mode 100644 index 0000000..b350f1b --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/am-clip.help.scm @@ -0,0 +1,7 @@ +;; (am-clip a b) + +;; Two quadrant multiply, 0 when b <= 0, a*b when b > 0 + +(audition + (out 0 (am-clip (white-noise ar) + (mul (f-sin-osc kr 1 0) 0.2)))) diff --git a/rsc3/examples/ugen/binary-ops/atan2.help.scm b/rsc3/examples/ugen/binary-ops/atan2.help.scm new file mode 100644 index 0000000..966fd0c --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/atan2.help.scm @@ -0,0 +1,21 @@ +;; (Atan2 x y) + +;; Returns the arctangent of y/x. + +;; See also hypot. + +;; add a pan to the hypot doppler examples by using atan2 to find the +;; azimuth, or direction angle, of the sound source. Assume speakers +;; at +/- 45 degrees and clip the direction to between those. + +(let* ((x 10) + (y (mul (lf-saw kr 1/6 0) 100)) + (distance (hypot x y)) + (amplitude (fdiv 40 (squared distance))) + (sound (rlpf (mul (f-sin-osc ar 200 0) (lf-pulse ar 31.3 0 0.4)) 400 0.3)) + (azimuth (atan2 y x)) + (loc (clip2 (fdiv azimuth (/ pi 2)) 1))) + (audition + (out 0 (pan2 (delay-l sound 110/344 (fdiv distance 344)) + loc + amplitude)))) diff --git a/rsc3/examples/ugen/binary-ops/clip2.help.scm b/rsc3/examples/ugen/binary-ops/clip2.help.scm new file mode 100644 index 0000000..9fa51c3 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/clip2.help.scm @@ -0,0 +1,9 @@ +;; (clip2 a b) + +;; Bilateral clipping. clips a to +/- b + +(audition + (out 0 (clip2 (f-sin-osc ar 400 0) 0.2))) + +(audition + (out 0 (clip2 (f-sin-osc ar 400 0) (line kr 0 1 8 remove-synth)))) diff --git a/rsc3/examples/ugen/binary-ops/dif-sqr.help.scm b/rsc3/examples/ugen/binary-ops/dif-sqr.help.scm new file mode 100644 index 0000000..53d5b17 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/dif-sqr.help.scm @@ -0,0 +1,15 @@ +;; (dif-sqr a b) + +;; Difference of squares. Return the value of (a*a) - (b*b). This is +;; more efficient than using separate unit generators for each +;; operation. + +(audition + (out 0 (mul (dif-sqr (f-sin-osc ar 800 0) + (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0)) + 0.125))) + +(audition + (out 0 (let ((a (f-sin-osc ar 800 0)) + (b (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0))) + (mul (sub (mul a a) (mul b b)) 0.125)))) diff --git a/rsc3/examples/ugen/binary-ops/eq.help.scm b/rsc3/examples/ugen/binary-ops/eq.help.scm new file mode 100644 index 0000000..4fa61ba --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/eq.help.scm @@ -0,0 +1 @@ +;; See gt \ No newline at end of file diff --git a/rsc3/examples/ugen/binary-ops/excess.help.scm b/rsc3/examples/ugen/binary-ops/excess.help.scm new file mode 100644 index 0000000..e05422f --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/excess.help.scm @@ -0,0 +1,12 @@ +;; (excess a b) + +;; clipping residual. Returns the difference of the original signal +;; and its clipped form: (a - clip2(a,b)). + +(audition + (out 0 (excess (f-sin-osc ar 1000 0) (line kr 0 1 8 do-nothing)))) + +(audition + (out 0 (let ((a (f-sin-osc ar 1000 0)) + (b (line kr 0 1 8 do-nothing))) + (sub a (clip2 a b))))) diff --git a/rsc3/examples/ugen/binary-ops/fdiv.help.scm b/rsc3/examples/ugen/binary-ops/fdiv.help.scm new file mode 100644 index 0000000..2a35579 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/fdiv.help.scm @@ -0,0 +1,9 @@ +;; (fdiv a b) + +;; Division, written '/' in sclang. + +;; Division can be tricky with signals because of division by zero. + +(audition + (out 0 (fdiv (mul (pink-noise ar) 0.1) + (mul (f-sin-osc kr 10 0.5) 0.75)))) diff --git a/rsc3/examples/ugen/binary-ops/fold2.help.scm b/rsc3/examples/ugen/binary-ops/fold2.help.scm new file mode 100644 index 0000000..ca05563 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/fold2.help.scm @@ -0,0 +1,7 @@ +;; (fold2 a b) + +;; Bilateral folding. folds a to +/- b. + +(audition + (out 0 (fold2 (f-sin-osc ar 1000 0) + (line kr 0 1 8 do-nothing)))) diff --git a/rsc3/examples/ugen/binary-ops/ge.help.scm b/rsc3/examples/ugen/binary-ops/ge.help.scm new file mode 100644 index 0000000..90864ba --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/ge.help.scm @@ -0,0 +1,3 @@ +;; (ge a b) + +;; See gt diff --git a/rsc3/examples/ugen/binary-ops/gt.help.scm b/rsc3/examples/ugen/binary-ops/gt.help.scm new file mode 100644 index 0000000..3639615 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/gt.help.scm @@ -0,0 +1,22 @@ +;; (gt a b) + +;; Greater than, written '>' in sclang. Signal is 1.0 if a > b, +;; otherwise it is 0.0. Similarly LT is <, GE >=, LE <= and EQ ==. +;; These can be useful for triggering purposes, among other things. + +(let* ((o (sin-osc kr 1 0)) + (t (list (gt o 0) + (ge o 0) + (lt o 0) + (le o 0) + (eq o 0) + (mul (lt o 0.001) (gt o -0.001)))) + (f (list 220 + 330 + 440 + 550 + 660 + 770)) + (p (env-perc 0.01 1 1 (list -4 -4))) + (e (env-gen kr (make-mce t) 0.1 0 1 do-nothing p))) + (audition (out 0 (mix (mul (sin-osc ar (make-mce f) 0) e))))) diff --git a/rsc3/examples/ugen/binary-ops/hypot.help.scm b/rsc3/examples/ugen/binary-ops/hypot.help.scm new file mode 100644 index 0000000..d4e31f8 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/hypot.help.scm @@ -0,0 +1,31 @@ +;; (hypot x y) + +;; Returns the square root of the sum of the squares of a and b. Or +;; equivalently, the distance from the origin to the point (x, y). + +(audition + (out 0 (mul (sin-osc ar 440 0) + (hypot (mouse-x kr 0 0.1 0 0.1) + (mouse-y kr 0 0.1 0 0.1))))) + +;; Object travels 200 meters in 6 secs (=120kph) passing 10 meters +;; from the listener. The speed of sound is 344 meters/sec. + +(let* ((x 10) + (y (mul (lf-saw kr 1/6 0) 100)) + (distance (hypot x y)) + (velocity (slope distance)) + (pitch-ratio (fdiv (sub 344 velocity) 344)) + (amplitude (fdiv 10 (squared distance)))) + (audition + (out 0 (mul (f-sin-osc ar (mul 1000 pitch-ratio) 0) + amplitude)))) + +(let* ((x 10) + (y (mul (lf-saw kr 1/6 0) 100)) + (distance (hypot x y)) + (amplitude (fdiv 40 (squared distance))) + (sound (rlpf (mul (f-sin-osc ar 200 0) (lf-pulse ar 31.3 0 0.4)) 400 0.3))) + (audition + (out 0 (mul (delay-l sound 110/344 (fdiv distance 344)) + amplitude)))) diff --git a/rsc3/examples/ugen/binary-ops/le.help.scm b/rsc3/examples/ugen/binary-ops/le.help.scm new file mode 100644 index 0000000..0b21a40 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/le.help.scm @@ -0,0 +1,3 @@ +;; (le a b) + +;; See gt diff --git a/rsc3/examples/ugen/binary-ops/lt.help.scm b/rsc3/examples/ugen/binary-ops/lt.help.scm new file mode 100644 index 0000000..5168390 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/lt.help.scm @@ -0,0 +1,3 @@ +;; (lt a b) + +;; See gt diff --git a/rsc3/examples/ugen/binary-ops/max.help.scm b/rsc3/examples/ugen/binary-ops/max.help.scm new file mode 100644 index 0000000..b3f6374 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/max.help.scm @@ -0,0 +1,7 @@ +;; (max a b) + +;; Maximum. + +(audition + (out 0 (let ((z (f-sin-osc ar 500 0))) + (u:max z (f-sin-osc ar 0.1 0))))) diff --git a/rsc3/examples/ugen/binary-ops/min.help.scm b/rsc3/examples/ugen/binary-ops/min.help.scm new file mode 100644 index 0000000..6dc5301 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/min.help.scm @@ -0,0 +1,7 @@ +;; (min a b) + +;; Minimum. + +(audition + (out 0 (let ((z (f-sin-osc ar 500 0))) + (u:min z (f-sin-osc ar 0.1 0))))) diff --git a/rsc3/examples/ugen/binary-ops/mod.help.scm b/rsc3/examples/ugen/binary-ops/mod.help.scm new file mode 100644 index 0000000..6ac0080 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/mod.help.scm @@ -0,0 +1,6 @@ +;; (Mod a b) + +;; Modulo, written % in sclang. outputs a modulo b. + +(audition + (out 0 (u:mod (f-sin-osc ar 100 4) 1))) diff --git a/rsc3/examples/ugen/binary-ops/mul.help.scm b/rsc3/examples/ugen/binary-ops/mul.help.scm new file mode 100644 index 0000000..a9ac8de --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/mul.help.scm @@ -0,0 +1,20 @@ +;; (mul a b) + +;; multiplication, written '*' in sclang. + +(audition + (out 0 (mul (sin-osc ar 440 0) 0.5))) + +;; Creates a beating effect (subaudio rate). + +(audition + (out 0 (mul3 (f-sin-osc kr 10 0) + (pink-noise ar) + 0.5))) + +;; Ring modulation. + +(audition + (out 0 (mul3 (sin-osc ar (x-line kr 100 1001 10 do-nothing) 0) + (sync-saw ar 100 200) + 0.25))) diff --git a/rsc3/examples/ugen/binary-ops/pow.help.scm b/rsc3/examples/ugen/binary-ops/pow.help.scm new file mode 100644 index 0000000..2df14a8 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/pow.help.scm @@ -0,0 +1,22 @@ +;; (pow a b) + +;; Exponentiation, written ** in sclang. When the signal is negative +;; this function extends the usual definition of exponentiation and +;; returns neg(neg(a) ** b). This allows exponentiation of negative +;; signal values by noninteger exponents. + +(audition + (out 0 (let ((a (mul (f-sin-osc ar 100 0) 0.1))) + (mce2 a (pow a 10))))) + +;; http://create.ucsb.edu/pipermail/sc-users/2006-December/029998.html + +(let* ((n0 (mul-add (lf-noise2 kr 8) 200 300)) + (n1 (mul-add (lf-noise2 kr 3) 10 20)) + (s (blip ar n0 n1)) + (x (mouse-x kr 1000 (mul sample-rate 0.5) 1 0.1)) + (y (mouse-y kr 1 24 1 0.1)) + (d (latch s (impulse ar x 0))) + (b (u:round d (pow 0.5 y)))) + (audition + (out 0 (mce2 d b)))) diff --git a/rsc3/examples/ugen/binary-ops/ring1.help.scm b/rsc3/examples/ugen/binary-ops/ring1.help.scm new file mode 100644 index 0000000..871ff4d --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/ring1.help.scm @@ -0,0 +1,17 @@ +;; (ring1 a b) + +;; Ring modulation plus first source. Return the value of ((a*b) + +;; a). This is more efficient than using separate unit generators for +;; the multiply and add. + +;; See also mul, Ring1, Ring2, Ring3, Ring4. + +(audition + (out 0 (mul (ring1 (f-sin-osc ar 800 0) + (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0)) + 0.125))) + +(let ((a (f-sin-osc ar 800 0)) + (b (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0))) + (audition + (out 0 (mul (add (mul a b) a) 0.125)))) diff --git a/rsc3/examples/ugen/binary-ops/ring2.help.scm b/rsc3/examples/ugen/binary-ops/ring2.help.scm new file mode 100644 index 0000000..9ac9492 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/ring2.help.scm @@ -0,0 +1,17 @@ +;; (ring2 a b) + +;; Ring modulation plus both sources. Return the value of ((a*b) + a +;; + b). This is more efficient than using separate unit generators +;; for the multiply and add. + +;; See also mul, Ring1, Ring3, Ring4. + +(audition + (out 0 (mul (ring2 (f-sin-osc ar 800 0) + (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0)) + 0.125))) + +(let ((a (f-sin-osc ar 800 0)) + (b (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0))) + (audition + (out 0 (mul (add3 (mul a b) a b) 0.125)))) diff --git a/rsc3/examples/ugen/binary-ops/ring3.help.scm b/rsc3/examples/ugen/binary-ops/ring3.help.scm new file mode 100644 index 0000000..bbd77c7 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/ring3.help.scm @@ -0,0 +1,17 @@ +;; (ring3 a b) + +;; Ring modulation variant. Return the value of (a * a * b). This is +;; more efficient than using separate unit generators for the +;; multiplies. + +;; See also mul, ring1, ring2, ring4. + +(audition + (out 0 (mul (ring3 (f-sin-osc ar 800 0) + (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0)) + 0.125))) + +(let ((a (f-sin-osc ar 800 0)) + (b (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0))) + (audition + (out 0 (mul4 a a b 0.125)))) diff --git a/rsc3/examples/ugen/binary-ops/ring4.help.scm b/rsc3/examples/ugen/binary-ops/ring4.help.scm new file mode 100644 index 0000000..c60feef --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/ring4.help.scm @@ -0,0 +1,18 @@ +;; (ring4 a b) + +;; Ring modulation variant. Return the value of ((a*a *b) - +;; (a*b*b)). This is more efficient than using separate unit +;; generators for the multiplies. + +;; See also mul, ring1, ring2, ring3. + +(audition + (out 0 (mul (ring4 (f-sin-osc ar 800 0) + (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0)) + 0.125))) + +(let ((a (f-sin-osc ar 800 0)) + (b (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0))) + (audition + (out 0 (mul (sub (mul3 a a b) (mul3 a b b)) + 0.125)))) diff --git a/rsc3/examples/ugen/binary-ops/round-up.help.scm b/rsc3/examples/ugen/binary-ops/round-up.help.scm new file mode 100644 index 0000000..a104f0c --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/round-up.help.scm @@ -0,0 +1,12 @@ +;; (round-up a b) + +;; Rounds a up to the nearest multiple of b. + +(let* ((x (mouse-x kr 60 4000 0 0.1)) + (f (round-up x 100))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) + +(let ((n (line kr 24 108 6 remove-synth))) + (audition + (out 0 (mul (saw ar (midi-cps (round-up n 1))) 0.2)))) diff --git a/rsc3/examples/ugen/binary-ops/round.help.scm b/rsc3/examples/ugen/binary-ops/round.help.scm new file mode 100644 index 0000000..96b9f7f --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/round.help.scm @@ -0,0 +1,12 @@ +;; (round a b) + +;; Rounds a to the nearest multiple of b. + +(let* ((x (mouse-x kr 60 4000 0 0.1)) + (f (u:round x 100))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) + +(let ((n (line kr 24 108 6 remove-synth))) + (audition + (out 0 (mul (saw ar (midi-cps (u:round n 1))) 0.2)))) diff --git a/rsc3/examples/ugen/binary-ops/scale-neg.help.scm b/rsc3/examples/ugen/binary-ops/scale-neg.help.scm new file mode 100644 index 0000000..93a696e --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/scale-neg.help.scm @@ -0,0 +1,7 @@ +;; (scale-neg a b) + +;; Scale negative part of input wave. a * b when a < 0, otherwise a. + +(audition + (out 0 (scale-neg (f-sin-osc ar 500 0) (line ar 1 -1 4 remove-synth)))) + diff --git a/rsc3/examples/ugen/binary-ops/sqr-dif.help.scm b/rsc3/examples/ugen/binary-ops/sqr-dif.help.scm new file mode 100644 index 0000000..94ec23f --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/sqr-dif.help.scm @@ -0,0 +1,16 @@ +;; (sqr-dif a b) + +;; Square of the difference. Return the value of (a - b)**2. This is +;; more efficient than using separate unit generators for each +;; operation. + +(audition + (out 0 (mul (sqr-dif (f-sin-osc ar 800 0) + (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0)) + 0.125))) + +(let ((a (f-sin-osc ar 800 0)) + (b (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0))) + (audition + (out 0 (mul (mul (sub a b) (sub a b)) + 0.125)))) diff --git a/rsc3/examples/ugen/binary-ops/sqr-sum.help.scm b/rsc3/examples/ugen/binary-ops/sqr-sum.help.scm new file mode 100644 index 0000000..57aa708 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/sqr-sum.help.scm @@ -0,0 +1,17 @@ +;; (sqr-sum a b) + +;; Square of the difference. Return the value of (a + b)**2. This is +;; more efficient than using separate unit generators for each +;; operation. + +(audition + (out 0 (mul (sqr-sum (f-sin-osc ar 800 0) + (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0)) + 0.125))) + +(let ((a (f-sin-osc ar 800 0)) + (b (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0))) + (audition + (out 0 (mul (mul (add a b) (add a b)) + 0.125)))) + \ No newline at end of file diff --git a/rsc3/examples/ugen/binary-ops/sub.help.scm b/rsc3/examples/ugen/binary-ops/sub.help.scm new file mode 100644 index 0000000..866fdfa --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/sub.help.scm @@ -0,0 +1,11 @@ +;; (sub a b) + +;; subtraction, written '-' in sclang. + +;; Silence. + +(let ((z (f-sin-osc ar 800 0))) + (audition + (out 0 (sub z z)))) + + diff --git a/rsc3/examples/ugen/binary-ops/sum-sqr.help.scm b/rsc3/examples/ugen/binary-ops/sum-sqr.help.scm new file mode 100644 index 0000000..961c2fa --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/sum-sqr.help.scm @@ -0,0 +1,14 @@ +;; (sum-sqr a b) + +;; Return the value of (a*a) + (b*b). This is more efficient than +;; using separate unit generators for each operation. + +(audition + (out 0 (mul (sum-sqr (f-sin-osc ar 800 0) + (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0)) + 0.125))) + +(let ((a (f-sin-osc ar 800 0)) + (b (f-sin-osc ar (x-line kr 200 500 5 do-nothing) 0))) + (audition + (out 0 (mul (add (mul a a) (mul b b)) 0.125)))) diff --git a/rsc3/examples/ugen/binary-ops/thresh.help.scm b/rsc3/examples/ugen/binary-ops/thresh.help.scm new file mode 100644 index 0000000..4940c8a --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/thresh.help.scm @@ -0,0 +1,6 @@ +;; (thresh a b) + +;; Signal thresholding. 0 when a < b, otherwise a. + +(audition + (out 0 (thresh (mul (lf-noise0 ar 50) 0.5) 0.45))) diff --git a/rsc3/examples/ugen/binary-ops/trunc.help.scm b/rsc3/examples/ugen/binary-ops/trunc.help.scm new file mode 100644 index 0000000..fdbc448 --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/trunc.help.scm @@ -0,0 +1,8 @@ +;; (trunc a b) + +;; Truncate a to a multiple of b. + +(let* ((x (mouse-x kr 60 4000 0 0.1)) + (f (trunc x 100))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/binary-ops/wrap2.help.scm b/rsc3/examples/ugen/binary-ops/wrap2.help.scm new file mode 100644 index 0000000..565916a --- /dev/null +++ b/rsc3/examples/ugen/binary-ops/wrap2.help.scm @@ -0,0 +1,7 @@ +;; (wrap2 a b) + +;; Bilateral wrapping. wraps input wave to +/- b. + +(audition + (out 0 (wrap2 (f-sin-osc ar 1000 0) + (line kr 0 1.01 8 do-nothing)))) diff --git a/rsc3/examples/ugen/chaos/crackle.help.scm b/rsc3/examples/ugen/chaos/crackle.help.scm new file mode 100644 index 0000000..8946019 --- /dev/null +++ b/rsc3/examples/ugen/chaos/crackle.help.scm @@ -0,0 +1,14 @@ +;; (crackle rate chaosParam) + +;; A noise generator based on a chaotic function. The parameter of +;; the chaotic function has useful values from just below 1.0 to just +;; above 2.0. Towards 2.0 the sound crackles. + +;; The equation implemented is: y0 = fabs(y1 * param - y2 - 0.05f) + +(audition (out 0 (mul (crackle ar 1.95) 0.5))) + +;; Modulate chaos parameter + +(let ((p (line kr 1.0 2.0 3 remove-synth))) + (audition (out 0 (mul (crackle ar p) 0.5)))) diff --git a/rsc3/examples/ugen/chaos/cusp-l.help.scm b/rsc3/examples/ugen/chaos/cusp-l.help.scm new file mode 100644 index 0000000..1a073ed --- /dev/null +++ b/rsc3/examples/ugen/chaos/cusp-l.help.scm @@ -0,0 +1 @@ +;; See cusp-n diff --git a/rsc3/examples/ugen/chaos/cusp-n.help.scm b/rsc3/examples/ugen/chaos/cusp-n.help.scm new file mode 100644 index 0000000..91260e3 --- /dev/null +++ b/rsc3/examples/ugen/chaos/cusp-n.help.scm @@ -0,0 +1,31 @@ +;; (cusp-n rate freq a b xi) +;; (cusp-l rate freq a b xi) + +;; freq - iteration frequency in Hertz +;; a, b - equation variables +;; xi - initial value of x + +;; Cusp map chaotic generator. Non- and linear- interpolating sound +;; generator based on the difference equation: + +;; xn+1 = a - b*sqrt(|xn|) + +(define cusp_ cusp-l) + +;; vary frequency + +(let ((x (mouse-x kr 20 sample-rate 0 0.1))) + (audition (out 0 (mul (cusp_ ar x 1.0 1.99 0) 0.3)))) + +;; mouse-controlled params + +(let ((x (mouse-x kr 0.9 1.1 1 0.1)) + (y (mouse-y kr 1.8 2 1 0.1))) + (audition (out 0 (mul (cusp_ ar (fdiv sample-rate 4) x y 0) 0.3)))) + +;; as a frequency control + +(let* ((x (mouse-x kr 0.9 1.1 1 0.1)) + (y (mouse-y kr 1.8 2 1 0.1)) + (f (mul-add (cusp_ ar 40 x y 0) 800 900))) + (audition (out 0 (mul (sin-osc ar f 0.0) 0.4)))) diff --git a/rsc3/examples/ugen/chaos/fb-sine-c.help.scm b/rsc3/examples/ugen/chaos/fb-sine-c.help.scm new file mode 100644 index 0000000..d53156a --- /dev/null +++ b/rsc3/examples/ugen/chaos/fb-sine-c.help.scm @@ -0,0 +1,54 @@ +;; (fb-sine-c rate freq im fb a c xi yi) + +;; Feedback sine with chaotic phase indexing. + +;; freq - iteration frequency in Hz - 22050 +;; im - index multiplier amount - 1 +;; fb - feedback amount - 0.1 +;; a - phase multiplier amount - 1.1 +;; c - phase increment amount - 0.5 +;; xi - initial value of x - 0.1 +;; yi - initial value of y - 0.1 + +;; A cubic-interpolating sound generator based on the difference +;; equations: + +;; xn+1 = sin(im*yn + fb*xn) +;; yn+1 = (ayn + c) % 2pi + +;; This uses a linear congruential function to drive the phase +;; indexing of a sine wave. For im = 1, fb = 0, and a = 1 a normal +;; sinewave results. + +;; sclang default values + +(audition + (out 0 (mul (fb-sine-c ar (fdiv sample-rate 4) 1 0.1 1.1 0.5 0.1 0.1) + 0.2))) + +;; increase feedback + +(let ((fb (line kr 0.01 4 10 do-nothing))) + (audition + (out 0 (mul (fb-sine-c ar sample-rate 1 fb 1.1 0.5 0.1 0.1) 0.2)))) + +;; increase phase multiplier + +(let ((a (line kr 1 2 10 do-nothing))) + (audition + (out 0 (mul (fb-sine-c ar sample-rate 1 0 a 0.5 0.1 0.1) 0.2)))) + +;; randomly modulate parameters + +(let* ((x (mouse-x kr 1 12 0 0.1)) + (f (lambda (m a) (mul-add (lf-noise2 kr x) m a)))) + (audition + (out 0 (mul (fb-sine-c ar + (f 1e4 1e4) + (f 32 33) + (f 0.5 0) + (f 0.05 1.05) + (f 0.3 0.3) + 0.1 + 0.1) + 0.2)))) \ No newline at end of file diff --git a/rsc3/examples/ugen/chaos/fb-sine-l.help.scm b/rsc3/examples/ugen/chaos/fb-sine-l.help.scm new file mode 100644 index 0000000..ed5b449 --- /dev/null +++ b/rsc3/examples/ugen/chaos/fb-sine-l.help.scm @@ -0,0 +1 @@ +;; See fb-sine-c diff --git a/rsc3/examples/ugen/chaos/fb-sine-n.help.scm b/rsc3/examples/ugen/chaos/fb-sine-n.help.scm new file mode 100644 index 0000000..ed5b449 --- /dev/null +++ b/rsc3/examples/ugen/chaos/fb-sine-n.help.scm @@ -0,0 +1 @@ +;; See fb-sine-c diff --git a/rsc3/examples/ugen/chaos/gbman-c.help.scm b/rsc3/examples/ugen/chaos/gbman-c.help.scm new file mode 100644 index 0000000..7f42dfd --- /dev/null +++ b/rsc3/examples/ugen/chaos/gbman-c.help.scm @@ -0,0 +1 @@ +;; See GbmanL. diff --git a/rsc3/examples/ugen/chaos/gbman-l.help.scm b/rsc3/examples/ugen/chaos/gbman-l.help.scm new file mode 100644 index 0000000..11ad0b3 --- /dev/null +++ b/rsc3/examples/ugen/chaos/gbman-l.help.scm @@ -0,0 +1,42 @@ +;; (gbman-c rate freq xi yi) +;; (gbman-l rate freq xi yi) +;; (gbman-n rate freq xi yi) + +;; Gingerbreadman map chaotic generator. Cubic, linear and +;; non-interpolating variants. + +;; freq - iteration frequency in Hertz +;; xi - initial value of x +;; yi - initial value of y + +;; A linear-interpolating sound generator based on the difference +;; equations: + +;; xn+1 = 1 - yn + |xn| +;; yn+1 = xn + +;; The behavior of the system is dependent only on its initial conditions +;; qand cannot be changed once it's started. + +;; Reference: Devaney, R. L. "The Gingerbreadman." Algorithm 3, 15-16, +;; Jan. 1992. + +;; sclang default initial parameters. + +(audition + (out 0 (mul (gbman-l ar (mouse-x kr 20 sample-rate 0 0.1) 1.2 2.1) 0.1))) + +;; Different initial parameters. + +(audition + (out 0 (mul (gbman-l ar (mouse-x kr 20 sample-rate 0 0.1) -0.7 -2.7) 0.1))) + +;; Wait for it... + +(audition + (out 0 (mul (gbman-l ar (mouse-x kr 20 sample-rate 0 0.1) 1.2 2.0002) 0.1))) + +;; As a frequency control + +(audition + (out 0 (mul (sin-osc ar (mul-add (gbman-l ar 40 1.2 2.1) 400 500) 0) 0.4))) diff --git a/rsc3/examples/ugen/chaos/gbman-n.help.scm b/rsc3/examples/ugen/chaos/gbman-n.help.scm new file mode 100644 index 0000000..7f42dfd --- /dev/null +++ b/rsc3/examples/ugen/chaos/gbman-n.help.scm @@ -0,0 +1 @@ +;; See GbmanL. diff --git a/rsc3/examples/ugen/chaos/henon-c.help.scm b/rsc3/examples/ugen/chaos/henon-c.help.scm new file mode 100644 index 0000000..71b4724 --- /dev/null +++ b/rsc3/examples/ugen/chaos/henon-c.help.scm @@ -0,0 +1 @@ +;; See henon-n diff --git a/rsc3/examples/ugen/chaos/henon-l.help.scm b/rsc3/examples/ugen/chaos/henon-l.help.scm new file mode 100644 index 0000000..71b4724 --- /dev/null +++ b/rsc3/examples/ugen/chaos/henon-l.help.scm @@ -0,0 +1 @@ +;; See henon-n diff --git a/rsc3/examples/ugen/chaos/henon-n.help.scm b/rsc3/examples/ugen/chaos/henon-n.help.scm new file mode 100644 index 0000000..d109cb3 --- /dev/null +++ b/rsc3/examples/ugen/chaos/henon-n.help.scm @@ -0,0 +1,54 @@ +;; (henon-n rate freq a b x0 x1) +;; (henon-l rate freq a b x0 x1) +;; (henon-c rate freq a b x0 x1) + +;; Henon map chaotic generator. + +;; freq - iteration frequency in Hertz -- 22050 +;; a, b - equation variables -- 1.4, 0.3 +;; x0, x1 - initial and second values of x -- 0, 0 + +;; A non-interpolating sound generator based on the difference +;; equation: + +;; xn + 2 = 1 - axn + 12 + bxn + +;; This equation was discovered by French astronomer Michel Henon +;; while studying the orbits of stars in globular clusters. + +;; With default initial parameters. + +(audition + (out 0 (mul (henon-n ar (mouse-x kr 20 sample-rate 0 0.1) 1.4 0.3 0 0) + 0.1))) + +;; With mouse-control of parameters. + +(audition + (out 0 (mul (henon-n ar + (fdiv sample-rate 4) + (mouse-x kr 1 1.4 0 0.1) + (mouse-y kr 0 0.3 0 0.1) + 0 + 0) + 0.1))) + +;; With randomly modulate parameters. + +(audition + (out 0 (mul (henon-n ar + (fdiv sample-rate 8) + (mul-add (lf-noise2 kr 1) 0.20 1.20) + (mul-add (lf-noise2 kr 1) 0.15 0.15) + 0 + 0) + 0.1))) + +;; As a frequency control. + +(let ((x (mouse-x kr 1 1.4 0 0.1)) + (y (mouse-y kr 0 0.3 0 0.1)) + (f 40)) + (audition + (out 0 (mul (sin-osc ar (mul-add (henon-n ar f x y 0 0) 800 900) 0) + 0.4)))) diff --git a/rsc3/examples/ugen/chaos/latoocarfian-c.help.scm b/rsc3/examples/ugen/chaos/latoocarfian-c.help.scm new file mode 100644 index 0000000..9f6483b --- /dev/null +++ b/rsc3/examples/ugen/chaos/latoocarfian-c.help.scm @@ -0,0 +1,40 @@ +;; (latoocarfian-c rate freq a b c d xi yi) +;; (latoocarfian-l rate freq a b c d xi yi) +;; (latoocarfian-n rate freq a b c d xi yi) + +;; This is a function given in Clifford Pickover's book Chaos in +;; Wonderland, pg 26. The function has four parameters a, b, c, and +;; d. The function is: + +;; xnew = sin(y * b) + c * sin(x * b); +;; ynew = sin(x * a) + d * sin(y * a); +;; x = xnew; +;; y = ynew; +;; output = x; + +;; According to Pickover, parameters a and b should be in the range +;; from -3 to +3, and parameters c and d should be in the range from +;; 0.5 to 1.5. The function can, depending on the parameters given, +;; give continuous chaotic output, converge to a single value +;; (silence) or oscillate in a cycle (tone). This UGen is +;; experimental and not optimized currently, so is rather hoggish of +;; CPU. + +;; Default initial parameters. + +(let ((x (mouse-x kr 20 sample-rate 0 0.1))) + (audition + (out 0 (mul (latoocarfian-c ar x 1 3 0.5 0.5 0.5 0.5) 0.2)))) + +;; randomly modulate all parameters. + +(audition + (out 0 (mul (latoocarfian-c ar + (fdiv sample-rate 4) + (mul-add (lf-noise2 kr 2) 1.5 1.5) + (mul-add (lf-noise2 kr 2) 1.5 1.5) + (mul-add (lf-noise2 kr 2) 0.5 1.5) + (mul-add (lf-noise2 kr 2) 0.5 1.5) + 0.5 + 0.5) + 0.2))) diff --git a/rsc3/examples/ugen/chaos/latoocarfian-l.help.scm b/rsc3/examples/ugen/chaos/latoocarfian-l.help.scm new file mode 100644 index 0000000..4bfddbd --- /dev/null +++ b/rsc3/examples/ugen/chaos/latoocarfian-l.help.scm @@ -0,0 +1 @@ +;; See latoocarfian-c. diff --git a/rsc3/examples/ugen/chaos/latoocarfian-n.help.scm b/rsc3/examples/ugen/chaos/latoocarfian-n.help.scm new file mode 100644 index 0000000..4bfddbd --- /dev/null +++ b/rsc3/examples/ugen/chaos/latoocarfian-n.help.scm @@ -0,0 +1 @@ +;; See latoocarfian-c. diff --git a/rsc3/examples/ugen/chaos/lin-cong-c.help.scm b/rsc3/examples/ugen/chaos/lin-cong-c.help.scm new file mode 100644 index 0000000..d2a8b27 --- /dev/null +++ b/rsc3/examples/ugen/chaos/lin-cong-c.help.scm @@ -0,0 +1,49 @@ +;; (lin-cong-c rate freq a c m xi) +;; (lin-cong-l rate freq a c m xi) +;; (lin-cong-n rate freq a c m xi) + +;; linear congruential chaotic generator. + +;; freq - iteration frequency in Hertz +;; a - multiplier amount +;; c - increment amount +;; m - modulus amount +;; xi - initial value of x + +;; A cubic-interpolating sound generator based on the difference +;; equation: + +;; xn+1 = (axn + c) % m + +;; The output signal is automatically scaled to a range of [-1, 1]. + + +;; Default initial parameters. + +(audition + (out 0 (let ((x (mouse-x kr 20 sample-rate 0 0.1))) + (mul (lin-cong-c ar x 1.1 0.13 1 0) 0.2)))) + + +;; randomly modulate parameters. + +(audition + (out 0 (mul (lin-cong-c ar + (mul-add (lf-noise2 kr 1.0) 1e4 1e4) + (mul-add (lf-noise2 kr 0.1) 0.5 1.4) + (mul-add (lf-noise2 kr 0.1) 0.1 0.1) + (lf-noise2 kr 0.1) + 0) + 0.2))) + +;; As frequency control... + +(audition + (out 0 (mul (sin-osc ar (mul-add (lin-cong-c ar + 40 + (mul-add (lf-noise2 kr 0.1) 0.1 1.0) + (mul-add (lf-noise2 kr 0.1) 0.1 0.1) + (lf-noise2 kr 0.1) + 0) + 500 600) 0) + 0.4))) diff --git a/rsc3/examples/ugen/chaos/lin-cong-l.help.scm b/rsc3/examples/ugen/chaos/lin-cong-l.help.scm new file mode 100644 index 0000000..689e04f --- /dev/null +++ b/rsc3/examples/ugen/chaos/lin-cong-l.help.scm @@ -0,0 +1 @@ +;; See lin-cong-c. diff --git a/rsc3/examples/ugen/chaos/lin-cong-n.help.scm b/rsc3/examples/ugen/chaos/lin-cong-n.help.scm new file mode 100644 index 0000000..689e04f --- /dev/null +++ b/rsc3/examples/ugen/chaos/lin-cong-n.help.scm @@ -0,0 +1 @@ +;; See lin-cong-c. diff --git a/rsc3/examples/ugen/chaos/logistic.help.scm b/rsc3/examples/ugen/chaos/logistic.help.scm new file mode 100644 index 0000000..2e037fe --- /dev/null +++ b/rsc3/examples/ugen/chaos/logistic.help.scm @@ -0,0 +1,8 @@ +;; (logistic rate chaosParam freq) + +;; UNDOCUMENTED. + +;; Implements the equation: y1 = param * y1 * (1.0 - y1) + +(audition + (out 0 (mul (logistic ar 2.9 1000) 0.2))) diff --git a/rsc3/examples/ugen/chaos/lorenz-l.help.scm b/rsc3/examples/ugen/chaos/lorenz-l.help.scm new file mode 100644 index 0000000..a7498aa --- /dev/null +++ b/rsc3/examples/ugen/chaos/lorenz-l.help.scm @@ -0,0 +1,58 @@ +;; (lorenz-l rate freq s r b h xi yi zi) + +;; freq - iteration frequency in Hertz +;; s, r, b - equation variables +;; h - integration time step +;; xi - initial value of x +;; yi - initial value of y +;; zi - initial value of z + +;; Lorenz chaotic generator. A strange attractor discovered by Edward +;; N. Lorenz while studying mathematical models of the atmosphere. +;; The system is composed of three ordinary differential equations: + +;; x' = s(y - x) +;; y' = x(r - z) - y +;; z' = xy - bz + +;; The time step amount h determines the rate at which the ODE is +;; evaluated. Higher values will increase the rate, but cause more +;; instability. A safe choice is the default amount of 0.05. + +;; vary frequency + +(audition + (out 0 (mul (lorenz-l ar (mouse-x kr 20 sample-rate 0 0.1) + 10 28 2.667 0.05 0.1 0 0) + 0.3))) + +;; randomly modulate params + +(audition + (out 0 (mul (lorenz-l ar sample-rate + (mul-add (lf-noise0 kr 1) 2 10) + (mul-add (lf-noise0 kr 1) 20 38) + (mul-add (lf-noise0 kr 1) 1.5 2) + 0.05 + 0.1 0.0 0.0) + 0.2))) + +;; as a frequency control + +(audition + (out 0 (mul + (sin-osc ar (mul-add + (lag + (lorenz-l ar + (mouse-x kr 1 200 0 0.1) + 10 + 28 + 2.667 + 0.05 + 0.1 + 0 + 0) + 0.003) + 800 900) + 0) + 0.4))) diff --git a/rsc3/examples/ugen/chaos/quad-c.help.scm b/rsc3/examples/ugen/chaos/quad-c.help.scm new file mode 100644 index 0000000..08f244f --- /dev/null +++ b/rsc3/examples/ugen/chaos/quad-c.help.scm @@ -0,0 +1 @@ +;; See quad-n diff --git a/rsc3/examples/ugen/chaos/quad-l.help.scm b/rsc3/examples/ugen/chaos/quad-l.help.scm new file mode 100644 index 0000000..08f244f --- /dev/null +++ b/rsc3/examples/ugen/chaos/quad-l.help.scm @@ -0,0 +1 @@ +;; See quad-n diff --git a/rsc3/examples/ugen/chaos/quad-n.help.scm b/rsc3/examples/ugen/chaos/quad-n.help.scm new file mode 100644 index 0000000..10a885a --- /dev/null +++ b/rsc3/examples/ugen/chaos/quad-n.help.scm @@ -0,0 +1,25 @@ +;; (quad-n rate freq a b c xi) +;; (quad-l rate freq a b c xi) +;; (quad-c rate freq a b c xi) + +;; freq - iteration frequency in Hertz +;; a, b, c - equation variables +;; xi - initial value of x + +;; General quadratic map chaotic generator. Non-, linear- and cubic- +;; interpolating sound generators based on the difference equation: +;; xn+1 = axn2 + bxn + c + +(define quad_ quad-c) + +(audition + (out 0 (mul (quad_ ar 4000 1 -1 -0.75 0) 0.2))) + +(let ((r (mouse-x kr 3.5441 4 0 0.1))) + (audition + (out 0 (mul (quad_ ar 4000.0 (neg r) r 0 0.1) 0.4)))) + +(let ((r (mouse-x kr 3.5441 4 0 0.1))) + (audition + (out 0 (mul (sin-osc ar (mul-add (quad_ ar 4 (neg r) r 0 0.1) 800 900) 0) + 0.4)))) diff --git a/rsc3/examples/ugen/chaos/rossler.help.scm b/rsc3/examples/ugen/chaos/rossler.help.scm new file mode 100644 index 0000000..9f266b9 --- /dev/null +++ b/rsc3/examples/ugen/chaos/rossler.help.scm @@ -0,0 +1,8 @@ +;; (rossler rate chaosParam dt) + +;; The Rossler attractor is a well known chaotic function. The +;; chaosParam can be varied from 1.0 to 25.0 with a dt of 0.04. Valid +;; ranges for chaosParam vary depending on dt. + +(audition + (out 0 (mul (rossler ar 4 0.08) 0.1))) diff --git a/rsc3/examples/ugen/chaos/standard-l.help.scm b/rsc3/examples/ugen/chaos/standard-l.help.scm new file mode 100644 index 0000000..0b35745 --- /dev/null +++ b/rsc3/examples/ugen/chaos/standard-l.help.scm @@ -0,0 +1,37 @@ +;; (standard-l rate freq k xi yi) +;; (standard-n rate freq k xi yi) + +;; Standard map chaotic generator. + +;; freq - iteration frequency in Hertz +;; k - perturbation amount +;; xi - initial value of x +;; yi - initial value of y + +;; A linear-interpolating sound generator based on the difference +;; equations: + +;; xn+1 = (xn + yn+1) % 2pi +;; yn+1 = (yn + ksin(xn)) % 2pi + +;; The standard map is an area preserving map of a cylinder discovered by +;; the plasma physicist Boris Chirikov. + +;; Vary frequency + +(audition + (out 0 (mul (standard-l ar (mouse-x kr 20 sample-rate 0 0.1) 1 0.5 0) 0.3))) + +;; Mouse-controlled parameter. + +(let ((f (fdiv sample-rate 2)) + (x (mouse-x kr 0.9 4 0 0.1))) + (audition + (out 0 (mul (standard-l ar f x 0.5 0) 0.3)))) + +;; As a frequency control + +(let* ((x (mouse-x kr 0.9 4 0 0.1)) + (f (mul-add (standard-l ar 40 x 0.5 0) 800 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.4)))) diff --git a/rsc3/examples/ugen/chaos/standard-n.help.scm b/rsc3/examples/ugen/chaos/standard-n.help.scm new file mode 100644 index 0000000..39c4d0f --- /dev/null +++ b/rsc3/examples/ugen/chaos/standard-n.help.scm @@ -0,0 +1 @@ +;; See standard-l. diff --git a/rsc3/examples/ugen/composite/mix-fill.help.scm b/rsc3/examples/ugen/composite/mix-fill.help.scm new file mode 100644 index 0000000..aaa9776 --- /dev/null +++ b/rsc3/examples/ugen/composite/mix-fill.help.scm @@ -0,0 +1,5 @@ +;; (mix-fill n f) + +(let ((n 6) + (o (lambda (_) (mul (f-sin-osc ar (rand 200 700) 0) 0.1)))) + (audition (out 0 (mix-fill n o)))) diff --git a/rsc3/examples/ugen/composite/mix.help.scm b/rsc3/examples/ugen/composite/mix.help.scm new file mode 100644 index 0000000..ca44ff3 --- /dev/null +++ b/rsc3/examples/ugen/composite/mix.help.scm @@ -0,0 +1,12 @@ +;; (mix UGen) + +;; Force multiple channel expansion and sum signals. + +(let ((f (make-mce (list 600.2 622.0 641.3 677.7)))) + (audition (out 0 (mul (mix (f-sin-osc ar f 0)) 0.1)))) + +;; Expansion nests. + +(let ((l (f-sin-osc ar (mce2 100 500) 0)) + (r (f-sin-osc ar (mce2 5000 501) 0))) + (audition (out 0 (mul 0.05 (mix (mce2 l r)))))) diff --git a/rsc3/examples/ugen/controls/decay.help.scm b/rsc3/examples/ugen/controls/decay.help.scm new file mode 100644 index 0000000..2b1dc66 --- /dev/null +++ b/rsc3/examples/ugen/controls/decay.help.scm @@ -0,0 +1,13 @@ +;; (decay in decayTime) + +;; Exponential decay. This is essentially the same as integrator +;; except that instead of supplying the coefficient directly, it is +;; caculated from a 60 dB decay time. This is the time required for +;; the integrator to lose 99.9 % of its value or -60dB. This is useful +;; for exponential decaying envelopes triggered by impulses. + +;; Used as an envelope. + +(audition + (out 0 (mul (decay (impulse ar (x-line kr 1 50 20 remove-synth) 0.25) 0.2) + (pink-noise ar)))) diff --git a/rsc3/examples/ugen/controls/decay2.help.scm b/rsc3/examples/ugen/controls/decay2.help.scm new file mode 100644 index 0000000..db6e3bd --- /dev/null +++ b/rsc3/examples/ugen/controls/decay2.help.scm @@ -0,0 +1,22 @@ +;; (decay2 in attackTime decayTime) + +;; Exponential decay. decay has a very sharp attack and can produce +;; clicks. decay2 rounds off the attack by subtracting one decay from +;; another. + +;; (decay2 in a d) is equivalent to (sub (decay in d) (Decay in a)). + +;; Used as an envelope + +(audition + (out 0 (mul (decay2 (impulse ar (x-line kr 1 50 20 remove-synth) 0.25) + 0.01 + 0.2) + (mul (f-sin-osc ar 600 0) 0.25)))) + +;; Compare the above with decay used as the envelope. + +(audition + (out 0 (mul (decay (impulse ar (x-line kr 1 50 20 remove-synth) 0.25) + 0.01) + (mul (f-sin-osc ar 600 0) 0.25)))) diff --git a/rsc3/examples/ugen/controls/degree-to-key.help.scm b/rsc3/examples/ugen/controls/degree-to-key.help.scm new file mode 100644 index 0000000..b98e9ed --- /dev/null +++ b/rsc3/examples/ugen/controls/degree-to-key.help.scm @@ -0,0 +1,32 @@ +;; (degree-to-key bufnum in octave) + +;; Convert signal to modal pitch + +;; The input signal value is truncated to an integer value and used as +;; an index into an octave repeating table of note values. indices +;; wrap around the table and shift octaves as they do. + +;; bufnum - index of the buffer which contains the steps for each +;; scale degree. + +;; in - the input signal. + +;; octave - the number of steps per octave in the scale. + +(let* ((b 0) + (p (list 0 2 3.2 5 7 9 10)) + (x (mouse-x kr 0 15 0 0.1)) + (k (degree-to-key 0 x 12)) + (c (lambda (n r) + (let* ((o (mul (sin-osc ar (midi-cps (add3 r k n)) 0) 0.1)) + (t (lf-pulse ar (midi-cps (mce2 48 55)) 0.15 0.5)) + (f (midi-cps (mul-add (sin-osc kr 0.1 0) 10 r))) + (d (mul (rlpf t f 0.1) 0.1)) + (m (add o d))) + (add (comb-n m 0.31 0.31 2) m))))) + (with-sc3 + (lambda (fd) + (async fd (b-alloc 0 7 1)) + (send fd (b-setn1 0 0 p)) + (let ((n (mul (lf-noise1 kr (mce2 3 3.05)) 0.04))) + (play fd (out 0 (mul (add (c n 48) (c n 72)) 0.25))))))) diff --git a/rsc3/examples/ugen/controls/k2a.help.scm b/rsc3/examples/ugen/controls/k2a.help.scm new file mode 100644 index 0000000..f257aa8 --- /dev/null +++ b/rsc3/examples/ugen/controls/k2a.help.scm @@ -0,0 +1,23 @@ +;; (k2a in) + +;; Control rate to audio rate converter. + +;; To be able to play a control rate UGen into an audio rate UGen, +;; sometimes the rate must be converted. k2a converts via linear +;; interpolation. + +;; in - input signal + +(audition + (out 0 (k2a (mul (white-noise kr) 0.3)))) + +(audition + (out 0 (mce2 (k2a (mul (white-noise kr) 0.3)) + (mul (white-noise ar) 0.3)))) + +(let* ((block-size 64) ;; no ugen for this? + (freq (mul (fdiv (mouse-x kr 0.1 40 1 0.1) block-size) sample-rate))) + (audition + (out 0 (mul (mce2 (k2a (lf-noise0 kr freq)) + (lf-noise0 ar freq)) + 0.3)))) diff --git a/rsc3/examples/ugen/controls/key-state.help.scm b/rsc3/examples/ugen/controls/key-state.help.scm new file mode 100644 index 0000000..fb5cbd9 --- /dev/null +++ b/rsc3/examples/ugen/controls/key-state.help.scm @@ -0,0 +1,11 @@ +;; (key-state rate keynum minval maxval lag) + +;; Report the status of a particular key. A key is either pressed, +;; or not pressed. + +;; The keycode 38 is the A key on my keyboard. Under X the xev(1) +;; command is useful in determining your keyboard layout. + +(audition + (out 0 (mul (sin-osc ar 800 0) + (key-state kr 38 0 0.1 0.5)))) diff --git a/rsc3/examples/ugen/controls/latch.help.scm b/rsc3/examples/ugen/controls/latch.help.scm new file mode 100644 index 0000000..c655140 --- /dev/null +++ b/rsc3/examples/ugen/controls/latch.help.scm @@ -0,0 +1,27 @@ +;; (latch in trig) + +;; Sample and hold. Holds input signal value when triggered. + +;; in - input signal. +;; trig - trigger. The trigger can be any signal. A trigger happens when the +;; signal changes from non-positive to positive. + +(audition + (out 0 (mul (blip ar (mul-add (latch (white-noise ar) (impulse ar 9 0)) + 400 500) 4) + 0.2))) + +;; The above is just meant as example. lf-noise0 is a faster way to +;; generate random steps : + +(audition + (out 0 (mul (blip ar (mul-add (lf-noise0 kr 9) 400 500) 4) 0.2))) + +;; http://create.ucsb.edu/pipermail/sc-users/2006-December/029991.html + +(let* ((n0 (mul-add (lf-noise2 kr 8) 200 300)) + (n1 (mul-add (lf-noise2 kr 3) 10 20)) + (s (blip ar n0 n1)) + (x (mouse-x kr 1000 (mul sample-rate 0.1) 1 0.1))) + (audition + (out 0 (latch s (impulse ar x 0))))) diff --git a/rsc3/examples/ugen/controls/mouse-button.help.scm b/rsc3/examples/ugen/controls/mouse-button.help.scm new file mode 100644 index 0000000..cbcafab --- /dev/null +++ b/rsc3/examples/ugen/controls/mouse-button.help.scm @@ -0,0 +1,8 @@ +;; (mouse-button rate minval maxval lag) + +;; Report the status of the first pointer button. The button is +;; either pressed, or not pressed. + +(audition + (out 0 (mul (sin-osc ar 800 0) + (mouse-button kr 0 0.1 0.1)))) diff --git a/rsc3/examples/ugen/controls/mouse-x.help.scm b/rsc3/examples/ugen/controls/mouse-x.help.scm new file mode 100644 index 0000000..e7d1a4b --- /dev/null +++ b/rsc3/examples/ugen/controls/mouse-x.help.scm @@ -0,0 +1,20 @@ +;; (mouse-x rate minval maxval warp lag) + +;; Cursor UGen. Report mouse location on root window of the machine +;; that the synthesis server is running on. For a linear mapping set +;; warp to 0, for an exponential mapping set warp to 1. + +(import (rsc3)) + +(audition + (out 0 (mul (sin-osc ar (mouse-x kr 40 10000 1 0.1) 0) 0.1))) + +(audition + (out 0 (mce2 (mul (sin-osc ar (mouse-x kr 20 2000 1 0.1) 0) + (mouse-y kr 0.01 0.1 0 0.1)) + (mul (sin-osc ar (mouse-y kr 20 2000 1 0.1) 0) + (mouse-x kr 0.01 0.1 0 0.1))))) + +;; Auto-pilot variant +(audition + (out 0 (mul (sin-osc ar (mouse-x* kr 40 10000 1 0.1) 0) 0.1))) diff --git a/rsc3/examples/ugen/controls/mouse-y.help.scm b/rsc3/examples/ugen/controls/mouse-y.help.scm new file mode 100644 index 0000000..c51ca64 --- /dev/null +++ b/rsc3/examples/ugen/controls/mouse-y.help.scm @@ -0,0 +1,9 @@ +;; (mouse-y rate minval maxval warp lag) + +;; Report mouse location on root window of the machine that the +;; synthesis server is running on. For a linear mapping set warp to +;; 0, for an exponential mapping set warp to 1. + +(audition + (out 0 (mul (sin-osc ar (mouse-x kr 20 2000 0 0.1) 0) + (mouse-y kr 0.01 0.1 0 0.1)))) diff --git a/rsc3/examples/ugen/controls/mrg2.help.scm b/rsc3/examples/ugen/controls/mrg2.help.scm new file mode 100644 index 0000000..db824c3 --- /dev/null +++ b/rsc3/examples/ugen/controls/mrg2.help.scm @@ -0,0 +1,28 @@ +;; (mrg2 left right) + +;; mrg2 defines a node indicating a multiple root graph. + +(let ((l (out 0 (mul (sin-osc ar 300 0) 0.1))) + (r (out 1 (mul (sin-osc ar 900 0) 0.1)))) + (audition + (mrg2 l r))) + +;; there is a leftmost rule, so that mrg nodes need not +;; be terminal. + +(let ((l (mul (sin-osc ar 300 0) 0.1)) + (r (out 1 (mul (sin-osc ar 900 0) 0.1)))) + (audition (out 0 (mrg2 l r)))) + +;; the leftmost node may be an mce node + +(let ((l (mul (sin-osc ar (mce2 300 400) 0) 0.1)) + (r (out 1 (mul (sin-osc ar 900 0) 0.1)))) + (audition (out 0 (mrg2 l r)))) + +;; the implementation is not thorough + +(let ((l (mul (sin-osc ar (mce2 300 400) 0) 0.1)) + (r (out 1 (mul (sin-osc ar 900 0) 0.1)))) + (audition (out 0 (add (mrg2 l r) + (mrg2 l r))))) diff --git a/rsc3/examples/ugen/controls/slew.help.scm b/rsc3/examples/ugen/controls/slew.help.scm new file mode 100644 index 0000000..de983d1 --- /dev/null +++ b/rsc3/examples/ugen/controls/slew.help.scm @@ -0,0 +1,6 @@ +;; (slew in up dn) + +;; Has the effect of removing transients and higher frequencies. + +(audition + (out 0 (slew (mul (saw ar 800) 0.2) 400 400))) diff --git a/rsc3/examples/ugen/controls/wrap-index.help.scm b/rsc3/examples/ugen/controls/wrap-index.help.scm new file mode 100644 index 0000000..225e107 --- /dev/null +++ b/rsc3/examples/ugen/controls/wrap-index.help.scm @@ -0,0 +1,17 @@ +;; (wrap-index bufnum in) + +;; index into a table with a signal. + +;; The input signal value is truncated to an integer value and used as +;; an index into the table. out of range index values are wrapped +;; cyclically to the valid range. + +;; bufnum - index of the buffer +;; in - the input signal. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 6 1)) + (send fd (b-setn1 0 0 (list 200 300 400 500 600 800))) + (let ((f (wrap-index 0 (mouse-x kr 0 18 0 0.1)))) + (play fd (out 0 (mul (sin-osc ar f 0) 0.5)))))) diff --git a/rsc3/examples/ugen/delays/allpass-c.help.scm b/rsc3/examples/ugen/delays/allpass-c.help.scm new file mode 100644 index 0000000..83759d8 --- /dev/null +++ b/rsc3/examples/ugen/delays/allpass-c.help.scm @@ -0,0 +1 @@ +;; See allpass-n diff --git a/rsc3/examples/ugen/delays/allpass-l.help.scm b/rsc3/examples/ugen/delays/allpass-l.help.scm new file mode 100644 index 0000000..83759d8 --- /dev/null +++ b/rsc3/examples/ugen/delays/allpass-l.help.scm @@ -0,0 +1 @@ +;; See allpass-n diff --git a/rsc3/examples/ugen/delays/allpass-n.help.scm b/rsc3/examples/ugen/delays/allpass-n.help.scm new file mode 100644 index 0000000..bb9edcd --- /dev/null +++ b/rsc3/examples/ugen/delays/allpass-n.help.scm @@ -0,0 +1,34 @@ +;; (allpass-n in maxDelayTime delayTime decayTime) + +;; All pass delay line. allpass-n uses no interpolation, allpass-l uses +;; linear interpolation, allpass-c uses all pass interpolation. All +;; time values are in seconds. The decay time is the time for the +;; echoes to decay by 60 decibels. If this time is negative then the +;; feedback coefficient will be negative, thus emphasizing only odd +;; harmonics at an octave lower. + +;; Since the allpass delay has no audible effect as a resonator on +;; steady state sound ... + +(define z (mul (white-noise ar) 0.1)) + +(audition (out 0 (allpass-c z 0.01 (x-line kr 0.0001 0.01 20 do-nothing) 0.2))) + +;; ...these examples add the input to the effected sound so that you +;; can hear the effect of the phase comb. + +(audition + (out 0 (add z (allpass-n z 0.01 (x-line kr 0.0001 0.01 20 do-nothing) 0.2)))) + +(audition + (out 0 (add z (allpass-l z 0.01 (x-line kr 0.0001 0.01 20 do-nothing) 0.2)))) + +(audition + (out 0 (add z (allpass-c z 0.01 (x-line kr 0.0001 0.01 20 do-nothing) 0.2)))) + +;; Used as an echo - doesn't really sound different than Comb, but it +;; outputs the input signal immediately (inverted) and the echoes are +;; lower in amplitude. + +(audition + (out 0 (allpass-n (mul (decay (dust ar 1) 0.2) z) 0.2 0.2 3))) diff --git a/rsc3/examples/ugen/delays/buf-allpass-c.help.scm b/rsc3/examples/ugen/delays/buf-allpass-c.help.scm new file mode 100644 index 0000000..15c1745 --- /dev/null +++ b/rsc3/examples/ugen/delays/buf-allpass-c.help.scm @@ -0,0 +1,29 @@ +;; (buf-allpass-c buf in delaytime decaytime) + +;; Buffer based all pass delay line with cubic interpolation + +;; All pass delay line with cubic interpolation which uses a buffer +;; for its internal memory. See also Bufallpass-n which uses no +;; interpolation, and Bufallpass-l which uses linear +;; interpolation. Cubic interpolation is more computationally +;; expensive than linear, but more accurate. + +;; See also allpass-c. + +;; buf - buffer number. + +;; in - the input signal. + +;; delaytime - delay time in seconds. + +;; decaytime - time for the echoes to decay by 60 decibels. If this +;; time is negative then the feedback coefficient will be +;; negative, thus emphasizing only odd harmonics at an +;; octave lower. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 44100 1)))) + +(let ((x (mul3 (decay (dust ar 1) 0.2) (white-noise ar) 0.5))) + (audition (out 0 (buf-allpass-n 0 x 0.25 6)))) diff --git a/rsc3/examples/ugen/delays/buf-allpass-l.help.scm b/rsc3/examples/ugen/delays/buf-allpass-l.help.scm new file mode 100644 index 0000000..60fdaf1 --- /dev/null +++ b/rsc3/examples/ugen/delays/buf-allpass-l.help.scm @@ -0,0 +1 @@ +;; See Bufallpass-c diff --git a/rsc3/examples/ugen/delays/buf-allpass-n.help.scm b/rsc3/examples/ugen/delays/buf-allpass-n.help.scm new file mode 100644 index 0000000..60fdaf1 --- /dev/null +++ b/rsc3/examples/ugen/delays/buf-allpass-n.help.scm @@ -0,0 +1 @@ +;; See Bufallpass-c diff --git a/rsc3/examples/ugen/delays/buf-comb-c.help.scm b/rsc3/examples/ugen/delays/buf-comb-c.help.scm new file mode 100644 index 0000000..baec42d --- /dev/null +++ b/rsc3/examples/ugen/delays/buf-comb-c.help.scm @@ -0,0 +1,27 @@ +;; (buf-comb-c buf in delaytime decaytime) + +;; Buffer based comb delay line with cubic interpolation + +;; All pass delay line with cubic interpolation which uses a buffer +;; for its internal memory. See also buf-comb-n which uses no +;; interpolation, and buf-comb-l which uses linear interpolation. Cubic +;; interpolation is more computationally expensive than linear, but +;; more accurate. See also comb-c. + +;; buf - buffer number. + +;; in - the input signal. + +;; delaytime - delay time in seconds. + +;; decaytime - time for the echoes to decay by 60 decibels. If this +;; time is negative then the feedback coefficient will be +;; negative, thus emphasizing only odd harmonics at an +;; octave lower. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 44100 1)))) + +(let ((x (mul3 (decay (dust ar 1) 0.2) (white-noise ar) 0.5))) + (audition (out 0 (buf-comb-n 0 x 0.25 6)))) diff --git a/rsc3/examples/ugen/delays/buf-comb-l.help.scm b/rsc3/examples/ugen/delays/buf-comb-l.help.scm new file mode 100644 index 0000000..ba9e033 --- /dev/null +++ b/rsc3/examples/ugen/delays/buf-comb-l.help.scm @@ -0,0 +1 @@ +;; See buf-comb-c diff --git a/rsc3/examples/ugen/delays/buf-comb-n.help.scm b/rsc3/examples/ugen/delays/buf-comb-n.help.scm new file mode 100644 index 0000000..ba9e033 --- /dev/null +++ b/rsc3/examples/ugen/delays/buf-comb-n.help.scm @@ -0,0 +1 @@ +;; See buf-comb-c diff --git a/rsc3/examples/ugen/delays/buf-delay-c.help.scm b/rsc3/examples/ugen/delays/buf-delay-c.help.scm new file mode 100644 index 0000000..a0c8436 --- /dev/null +++ b/rsc3/examples/ugen/delays/buf-delay-c.help.scm @@ -0,0 +1,22 @@ +;; (buf-delay-c buf in delaytime) + +;; Buffer based simple delay line with cubic interpolation. + +;; Simple delay line with cubic interpolation which uses a buffer for +;; its internal memory. See also buf-delay-n which uses no +;; interpolation, and buf-delay-l which uses linear interpolation. Cubic +;; interpolation is more computationally expensive than linear, but +;; more accurate. + +;; See also delay-c. + +;; buf - buffer number. +;; in - the input signal. +;; delaytime - delay time in seconds. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 44100 1)))) + +(let ((z (mul3 (decay (dust ar 1) 0.5) 0.3 (white-noise ar)))) + (audition (out 0 (add (buf-delay-c 0 z 0.2) z)))) diff --git a/rsc3/examples/ugen/delays/buf-delay-l.help.scm b/rsc3/examples/ugen/delays/buf-delay-l.help.scm new file mode 100644 index 0000000..0186b19 --- /dev/null +++ b/rsc3/examples/ugen/delays/buf-delay-l.help.scm @@ -0,0 +1 @@ +;; See buf-delay-c diff --git a/rsc3/examples/ugen/delays/buf-delay-n.help.scm b/rsc3/examples/ugen/delays/buf-delay-n.help.scm new file mode 100644 index 0000000..0186b19 --- /dev/null +++ b/rsc3/examples/ugen/delays/buf-delay-n.help.scm @@ -0,0 +1 @@ +;; See buf-delay-c diff --git a/rsc3/examples/ugen/delays/buf-rd.help.scm b/rsc3/examples/ugen/delays/buf-rd.help.scm new file mode 100644 index 0000000..211444b --- /dev/null +++ b/rsc3/examples/ugen/delays/buf-rd.help.scm @@ -0,0 +1,36 @@ +;; (buf-rd numChannels rate bufnum phase loop interpolation) + +;; Plays the content of a buffer. + +;; The number of channels must be a fixed integer. The architechture +;; of the SynthDef cannot change after it is compiled. NOTE: if you +;; supply a bufnum of a buffer that has a different numChannels then +;; you have specified to the buf-rd, it will fail silently. + +;; The interpolation type is an integer: 1 no interpolation, 2 linear +;; interpolation, 4 cubic interpolation. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 0 "/home/rohan/audio/metal.wav" 0 0)))) + +(audition (out 0 (buf-rd 1 ar 0 (mul (sin-osc ar 0.1 0) (buf-frames ir 0)) 0 2))) + +(let ((phase (mul (lf-noise1 ar (mouse-x kr (mce2 5 10) 100 0 0.1)) + (buf-frames ir 0)))) + (audition (out 0 (buf-rd-l 1 ar 0 phase 0)))) + +(let ((phase (add (lf-tri ar 0.1 0) + (mul (lf-tri ar 0.23 0) (buf-frames ir 0))))) + (audition (out 0 (buf-rd-l 1 ar 0 phase 0)))) + +;; Use a phasor index into the file + +(let ((phase (phasor ar + 0 + (mul (mouse-x kr 0.5 2 0 0.1) + (buf-rate-scale kr 0)) + 0 + (buf-frames kr 0) + 0))) + (audition (out 0 (buf-rd 1 ar 0 phase 1 (mouse-y kr 0 5 0 0.1))))) diff --git a/rsc3/examples/ugen/delays/comb-c.help.scm b/rsc3/examples/ugen/delays/comb-c.help.scm new file mode 100644 index 0000000..a427041 --- /dev/null +++ b/rsc3/examples/ugen/delays/comb-c.help.scm @@ -0,0 +1 @@ +;; See comb-n diff --git a/rsc3/examples/ugen/delays/comb-l.help.scm b/rsc3/examples/ugen/delays/comb-l.help.scm new file mode 100644 index 0000000..69fcc28 --- /dev/null +++ b/rsc3/examples/ugen/delays/comb-l.help.scm @@ -0,0 +1,2 @@ +;; See comb-n + diff --git a/rsc3/examples/ugen/delays/comb-n.help.scm b/rsc3/examples/ugen/delays/comb-n.help.scm new file mode 100644 index 0000000..aa44374 --- /dev/null +++ b/rsc3/examples/ugen/delays/comb-n.help.scm @@ -0,0 +1,32 @@ +;; (comb-n in maxDelayTime delayTime decayTime) +;; (comb-l in maxDelayTime delayTime decayTime) +;; (comb-c in maxDelayTime delayTime decayTime) + +;; Comb delay line. comb-n uses no interpolation, comb-l uses linear +;; interpolation, comb-c uses all pass interpolation. All times are in +;; seconds. The decay time is the time for the echoes to decay by 60 +;; decibels. If this time is negative then the feedback coefficient +;; will be negative, thus emphasizing only odd harmonics at an octave +;; lower. + +;; Comb used as a resonator. The resonant fundamental is equal to +;; reciprocal of the delay time. + +(define src (mul (white-noise ar) 0.01)) +(define ctl (x-line kr 0.0001 0.01 20 remove-synth)) +(define hear (lambda (u) (audition (out 0 u)))) + +(hear (comb-n src 0.01 ctl 0.2)) +(hear (comb-l src 0.01 ctl 0.2)) +(hear (comb-c src 0.01 ctl 0.2)) + +;; With negative feedback: + +(hear (comb-n src 0.01 ctl -0.2)) +(hear (comb-l src 0.01 ctl -0.2)) +(hear (comb-c src 0.01 ctl -0.2)) + +;; Used as an echo. + +(hear (comb-n (mul (decay (mul (dust ar 1) 0.5) 0.2) (white-noise ar)) + 0.2 0.2 3)) diff --git a/rsc3/examples/ugen/delays/delay-c.help.scm b/rsc3/examples/ugen/delays/delay-c.help.scm new file mode 100644 index 0000000..2b82d66 --- /dev/null +++ b/rsc3/examples/ugen/delays/delay-c.help.scm @@ -0,0 +1 @@ +;; See delay-n diff --git a/rsc3/examples/ugen/delays/delay-l.help.scm b/rsc3/examples/ugen/delays/delay-l.help.scm new file mode 100644 index 0000000..2b82d66 --- /dev/null +++ b/rsc3/examples/ugen/delays/delay-l.help.scm @@ -0,0 +1 @@ +;; See delay-n diff --git a/rsc3/examples/ugen/delays/delay-n.help.scm b/rsc3/examples/ugen/delays/delay-n.help.scm new file mode 100644 index 0000000..464fda5 --- /dev/null +++ b/rsc3/examples/ugen/delays/delay-n.help.scm @@ -0,0 +1,16 @@ +;; (delay-n in maxDelayTime delayTime) +;; (delay-l in maxDelayTime delayTime) +;; (delay-c in maxDelayTime delayTime) + +;; Simple delay line. There are three forms, delay-n uses no +;; interpolation, delay-l uses linear interpolation, delay-c uses cubic +;; interpolation. The maximum delay length is set at initialization +;; time and cannot be extended. + +;; dust randomly triggers decay to create an exponential decay +;; envelope for the white-noise input source. + +(let ((z (mul (decay (dust ar 1) 0.3) + (white-noise ar)))) + (audition + (out 0 (add (delay-n z 0.2 0.2) z)))) diff --git a/rsc3/examples/ugen/delays/delay1.help.scm b/rsc3/examples/ugen/delays/delay1.help.scm new file mode 100644 index 0000000..cd7de3f --- /dev/null +++ b/rsc3/examples/ugen/delays/delay1.help.scm @@ -0,0 +1,7 @@ +;; (delay1 in) + +;; Fixed Single sample delay. + +(let ((s (impulse ar 1 0))) + (audition + (out 0 (add s (delay1 s))))) diff --git a/rsc3/examples/ugen/delays/delay2.help.scm b/rsc3/examples/ugen/delays/delay2.help.scm new file mode 100644 index 0000000..c6e484b --- /dev/null +++ b/rsc3/examples/ugen/delays/delay2.help.scm @@ -0,0 +1,8 @@ +;; (delay2 in) + +;; Fixed two sample delay. + +(let ((s (impulse ar 1 0))) + (audition + (out 0 (add s (delay2 s))))) + diff --git a/rsc3/examples/ugen/delays/free-verb.help.scm b/rsc3/examples/ugen/delays/free-verb.help.scm new file mode 100644 index 0000000..8187e82 --- /dev/null +++ b/rsc3/examples/ugen/delays/free-verb.help.scm @@ -0,0 +1,24 @@ +;; (free-verb in mix room damp) +;; (free-verb2 in1 in2 mix room damp) + +;; A simple reverb. + +;; in, in1, in2 - input signal +;; mix - dry/wet balance (0,1) +;; room - room size (0,1) +;; damp - reverb high frequency damping (0,1) + +(let* ((i (impulse ar 1 0)) + (c (lf-cub ar 1200 0)) + (s (mul3 (decay i 0.25) c 0.1)) + (x (mouse-x kr 0 1 0 0.1)) + (y (mouse-y kr 0 1 0 0.1)) + (r (free-verb s y x 0.5))) + (audition (out 0 r))) + +(let* ((i (sound-in (mce2 0 1))) + (c (lambda (u n) (mce-channel u n))) + (x (mouse-x kr 0 1 0 0.1)) + (y (mouse-y kr 0 1 0 0.1)) + (r (free-verb2 (c i 0) (c i 1) y x 0.5))) + (audition (out 0 r))) diff --git a/rsc3/examples/ugen/delays/free-verb2.help.scm b/rsc3/examples/ugen/delays/free-verb2.help.scm new file mode 100644 index 0000000..7051130 --- /dev/null +++ b/rsc3/examples/ugen/delays/free-verb2.help.scm @@ -0,0 +1 @@ +;; See freeVerb diff --git a/rsc3/examples/ugen/delays/pitch-shift.help.scm b/rsc3/examples/ugen/delays/pitch-shift.help.scm new file mode 100644 index 0000000..8f53d2a --- /dev/null +++ b/rsc3/examples/ugen/delays/pitch-shift.help.scm @@ -0,0 +1,10 @@ +;; (pitch-shift in winSize pchRatio pchDispersion timeDispersion) + +;; A simple time domain pitch shifter. + +(audition + (out 0 (pitch-shift (sin-osc ar 440 0) + 0.2 + (mouse-x kr 0.5 2 0 0.1) + (mouse-y kr 0 0.1 0 0.1) + 0))) diff --git a/rsc3/examples/ugen/delays/play-buf.help.scm b/rsc3/examples/ugen/delays/play-buf.help.scm new file mode 100644 index 0000000..d0a1b7a --- /dev/null +++ b/rsc3/examples/ugen/delays/play-buf.help.scm @@ -0,0 +1,65 @@ +;; (play-buf numChannels bufnum rate trigger startPos loop) + +;; Sample playback oscillator. Plays back a memory resident sample. + +;; numChannels - number of channels that the buffer will be. This +;; must be a fixed integer. The architechture of the +;; SynthDef cannot change after it is compiled. +;; Warning: if you supply a bufnum of a buffer that has +;; a different numChannels then you have specified to +;; the play-buf, it will fail silently. + +;; bufnum - the index of the buffer to use + +;; rate - 1.0 is the server's sample rate, 2.0 is one octave up, 0.5 +;; is one octave down -1.0 is backwards normal rate +;; etc. interpolation is cubic. Note: If the buffer's sample +;; rate is different from the server's, you will need to +;; multiply the desired playback rate by (file's rate / +;; server's rate). The UGen buf-rate-scale.kr(bufnum) returns +;; this factor. See examples below. buf-rate-scale should be used +;; in virtually every case. + +;; trigger - a trigger causes a jump to the startPos. A trigger +;; occurs when a signal changes from <= 0 to > 0. + +;; startPos - sample frame to start playback. + +;; loop - 1 means true, 0 means false. This is modulate-able. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 10 "/home/rohan/audio/metal.wav" 0 0)))) + +;; Play once only. + +(audition (out 0 (play-buf 1 10 (buf-rate-scale kr 10) 1 0 0))) + +;; Play in infinite loop. + +(audition (out 0 (play-buf 1 10 (buf-rate-scale kr 10) 1 0 1))) + +;; trigger playback at each pulse. + +(audition (out 0 (play-buf 1 10 (buf-rate-scale kr 10) (impulse kr 2 0) 0 0))) + +;; trigger playback at each pulse (diminishing intervals). + +(let ((t (impulse kr (x-line kr 0.1 100 10 remove-synth) 0))) + (audition (out 0 (play-buf 1 10 (buf-rate-scale kr 10) t 0 0)))) + +;; Loop playback, accelerating pitch. + +(let ((rate (x-line kr 0.1 100 60 remove-synth))) + (audition (out 0 (play-buf 1 10 rate 1 0 1)))) + +;; Sine wave control of playback rate, negative rate plays backwards. + +(let ((r (mul-add (f-sin-osc kr (x-line kr 0.2 8 30 remove-synth) 0) 3 0.6))) + (audition (out 0 (play-buf 1 10 (mul (buf-rate-scale kr 10) r) 1 0 1)))) + +;; Release buffer. + +(with-sc3 + (lambda (fd) + (async fd (b-free 10)))) diff --git a/rsc3/examples/ugen/delays/pluck.help.scm b/rsc3/examples/ugen/delays/pluck.help.scm new file mode 100644 index 0000000..8a75fa9 --- /dev/null +++ b/rsc3/examples/ugen/delays/pluck.help.scm @@ -0,0 +1,41 @@ +;; (pluck in tr maxdelaytime delaytime decaytime coef) + +;; Karplus-Strong synthesis. + +;; in - an excitation signal + +;; tr - upon a negative to positive transition, the excitation signal +;; will be fed into the delay line + +;; maxdelaytime - the max delay time in seconds (initializes the +;; internal delay buffer). + +;; delaytime - delay time in seconds. + +;; decaytime - time for the echoes to decay by 60 decibels. Negative +;; times emphasize odd partials. + +;; coef - the coef of the internal one-pole filter. Values should be +;; between -1 and +1 (larger values will be unstable... so be +;; careful!). + +;; Excitation signal is white-noise, triggered twice a second with +;; varying one-pole coef. + +(let ((n (mul (white-noise ar) 0.1)) + (t (impulse kr 2 0)) + (x (mouse-x kr -0.999 0.999 0 0.1)) + (dl (/ 1 440))) + (audition (out 0 (pluck n t dl dl 10 x)))) + +(let* ((n 25) + (gen (lambda (n f) (mce-fill n (lambda (_) (f))))) + (f (gen n (lambda () (rand 0.05 0.2)))) + (p (gen n (lambda () (rand 0 1)))) + (x (mouse-x kr 60 1000 1 0.1)) + (o (lin-lin (sin-osc kr f p) -1 1 x 3000)) + (w (clone n (mul (white-noise ar) 0.1))) + (i (impulse kr (gen n (lambda () (rand 10 12))) 0)) + (ks (pluck w i 0.01 (fdiv 1 o) 2 (rand 0.01 0.2))) + (l (gen n (lambda () (rand -1 1))))) + (audition (out 0 (leak-dc (mix (pan2 ks l 1)) 0.995)))) diff --git a/rsc3/examples/ugen/delays/record-buf.help.scm b/rsc3/examples/ugen/delays/record-buf.help.scm new file mode 100644 index 0000000..26cd5f5 --- /dev/null +++ b/rsc3/examples/ugen/delays/record-buf.help.scm @@ -0,0 +1,73 @@ +;; (record-buf bufnum offset reclevel prelevel run loop trigger inputs) + +;; Records input into a Buffer. + +;; If recLevel is 1.0 and preLevel is 0.0 then the new input +;; overwrites the old data. If they are both 1.0 then the new data is +;; added to the existing data. (Any other settings are also valid.) + +;; bufnum - the index of the buffer to use +;; offset - an offset into the buffer in samples, default 0 +;; recLevel - value to multiply by input before mixing with +;; existing data. Default is 1.0. +;; preLevel - value to multiply to existing data in buffer before +;; mixing with input. Default is 0.0. +;; run - If zero, then recording stops, otherwise recording +;; proceeds. Default is 1. +;; loop - If zero then don't loop, otherwise do. This is +;; modulate-able. Default is 1. +;; trigger - a trigger causes a jump to the start of the Buffer. +;; A trigger occurs when a signal changes from <=0 to >0. +;; inputArray - an Array of input channels + +(with-sc3 + (lambda (fd) + (send-synth + fd + "recorder" + (letc ((in 0) + (bufnum 0) + (offset 1) + (recLevel 1) + (preLevel 0) + (run 1) + (loop 1) + (trigger 1)) + (let ((i (in 2 ar in))) + (out 0 (record-buf bufnum offset recLevel preLevel run loop trigger i))))) + (let ((b 10) + (y 1001) + (z 1002)) + (async fd (/b_alloc b 44100 2)) + (send fd (/s_new "recorder" y add-to-tail 1 "bufnum" b "in" 8)) + (send fd (/n_trace y)) + (send-synth + fd + "player" + (letc ((bufnum 0) + (rate 1) + (trigger 1) + (startPos 0) + (loop 1) + (gain 1)) + (out 0 (mul (play-buf 2 bufnum rate trigger startPos loop) gain)))) + (send fd (/s_new "player" z add-to-tail 1 "bufnum" b))))) + +(define do-send + (lambda (m) + (with-sc3 + (lambda (fd) + (send fd m))))) + +(do-send (/n_set 1001 "run" 1)) + +(do-send (/n_set 1002 "loop" 1)) +(do-send (/n_set 1002 "gain" 2)) +(do-send (/n_set 1002 "trigger" 1)) + +(do-send (/n_free 1001)) +(do-send (/n_free 1002)) + +(with-sc3 + (lambda (fd) + (async fd (/b_free 10)))) diff --git a/rsc3/examples/ugen/demand/dbrown.help.scm b/rsc3/examples/ugen/demand/dbrown.help.scm new file mode 100644 index 0000000..e7e6850 --- /dev/null +++ b/rsc3/examples/ugen/demand/dbrown.help.scm @@ -0,0 +1,20 @@ +;; (dbrown length lo hi step) +;; (dibrown length lo hi step) + +;; demand rate brownian movement generators. + +;; lo - minimum value +;; hi - maximum value +;; step - maximum step for each new value +;; length - number of values to create + +;; dbrown returns numbers in the continuous range between lo and hi, +;; dibrown returns integer values. The arguments can be a number or +;; any other ugen. + +(let ((f (lambda (u) + (let* ((a (u dinf 0 15 1)) + (t (impulse kr (mouse-x kr 1 40 1 0.1) 0)) + (f (mul-add (demand t 0 a) 30 340))) + (mul (sin-osc ar f 0) 0.1))))) + (audition (out 0 (mce2 (f dbrown) (f dibrown))))) diff --git a/rsc3/examples/ugen/demand/dbufrd.help.scm b/rsc3/examples/ugen/demand/dbufrd.help.scm new file mode 100644 index 0000000..eefccf0 --- /dev/null +++ b/rsc3/examples/ugen/demand/dbufrd.help.scm @@ -0,0 +1,39 @@ +;; (dbufrd bufnum phase loop) + +;; Buffer demand ugen. + +;; bufnum - buffer number to read from +;; phase - index into the buffer (demand ugen or any other ugen) +;; loop - loop when phase exceeds number of frames in buffer + +;; Example + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 24 1)) + (send fd (b-setn1 10 0 (replicate-m 24 (exp-random 200 500)))))) + +(let* ((q (dseq 3 (make-mce (list 0 3 5 0 3 7 0 5 9)))) + (p (dseq dinf (mce2 q (dbrown 5 0 23 1)))) + (t (dust kr 10))) + (audition (out 0 (mul (sin-osc ar (demand t 0 (dbufrd 10 p 1)) 0) 0.1)))) + +;; Buffer as a time pattern. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 11 24 1)) + (send fd (b-setn1 11 0 (replicate-m 24 (choose (list 1 0.5 0.25))))))) + +(let* ((p (dseq dinf (mce2 (dseq 3 (make-mce (list 0 3 5 0 3 7 0 5 9))) + (dbrown 5 0 23 1)))) + (d (mul (dbufrd 11 (dseries dinf 0 1) 1) 0.5)) + (l (dbufrd 10 p 1))) + (audition (out 0 (mul (sin-osc ar (duty kr d 0 do-nothing l) 0) 0.1)))) + +;; free buffers + +(with-sc3 + (lambda (fd) + (async fd (b-free 10)) + (async fd (b-free 11)))) diff --git a/rsc3/examples/ugen/demand/demand-env-gen.help.scm b/rsc3/examples/ugen/demand/demand-env-gen.help.scm new file mode 100644 index 0000000..0d4dd3b --- /dev/null +++ b/rsc3/examples/ugen/demand/demand-env-gen.help.scm @@ -0,0 +1,48 @@ +;; (demand-env-gen rate levels times shapes curves gate reset +;; levelScale levelOffset timeScale doneAction) + +;; levels - a demand ugen or any other ugen + +;; times - a demand ugen or any other ugen if one of these ends, +;; the doneAction is evaluated + +;; shapes - a demand ugen or any other ugen, the number given is +;; the shape number according to Env + +;; curves - a demand ugen or any other ugen, if shape is 5, this +;; is the curve factor some curves/shapes don't work if +;; the duration is too short. have to see how to improve +;; this. also some depend on the levels obviously, like +;; exponential cannot cross zero. + +;; gate - if gate is x >= 1, the ugen runs, if gate is 0 > x > 1, +;; the ugen is released at the next level (doneAction), if +;; gate is x < 0, the ugen is sampled end held + +;; reset - if reset crosses from nonpositive to positive, the ugen +;; is reset at the next level, if it is > 1, it is reset +;; immediately. + +;; Frequency envelope with random times. + +(let* ((l (dseq dinf (make-mce (list 204 400 201 502 300 200)))) + (t (drand dinf (make-mce (list 1.01 0.2 0.1 2.0)))) + (y (mouse-y kr 0.01 3 1 0.1)) + (f (demand-env-gen ar l (mul t y) 7 0 1 1 1 0 1 do-nothing))) + (audition (out 0 (mul (sin-osc ar (mul f (mce2 1 1.01)) 0) 0.1)))) + +;; Frequency modulation + +(let* ((x (mouse-x kr -0.01 -4 0 0.1)) + (y (mouse-y kr 1 3000 1 0.1)) + (l (lambda () (dseq dinf (clone 32 (exp-rand 200 1000))))) + (t (mul sample-dur y)) + (f (demand-env-gen ar (mce2 (l) (l)) t 5 x 1 1 1 0 1 do-nothing))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) + +;; gate. Mouse x on right side of screen toggles gate. + +(let* ((x (mouse-x kr 0 1 0 0.1)) + (l (u:round (dwhite dinf 300 1000) 100)) + (f (demand-env-gen kr l 0.1 5 0.3 (gt x 0.5) 1 1 0 1 do-nothing))) + (audition (out 0 (mul (sin-osc ar (mul f (mce2 1 1.21)) 0) 0.1)))) diff --git a/rsc3/examples/ugen/demand/demand.help.scm b/rsc3/examples/ugen/demand/demand.help.scm new file mode 100644 index 0000000..e2c1f47 --- /dev/null +++ b/rsc3/examples/ugen/demand/demand.help.scm @@ -0,0 +1,39 @@ +;; (demand trig reset ugens) + +;; demand results from demand rate ugens. + +;; When there is a trigger at the trig input, a value is demanded from +;; each ugen in the list and output. The unit generators in the list +;; should be 'demand' rate. + +;; When there is a trigger at the reset input, the demand rate ugens +;; in the list are reset. + +;; trig - trigger. trigger can be any signal. A trigger happens when +;; the signal changes from non-positive to positive. + +;; reset - trigger. Resets the list of ugens when triggered. + +(define (mirror1 l) + (append l (cdr (reverse (cdr l))))) + +(let* ((t (impulse kr 24 0)) + (s (drand dinf (mce2 (dseq 1 (make-mce (mirror1 (enum-from-to 1 5)))) + (drand 8 (make-mce (enum-from-to 4 11)))))) + (f (demand t 0 (mul s 100))) + (x (mouse-x kr -1 1 0 0.1)) + (o (sin-osc ar (mce2 f (add f 0.7)) 0))) + (audition (out 0 (mul (scale-neg (cubed (cubed o)) x) 0.1)))) + +(let* ((t (impulse kr 10 0)) + (r (dust kr 1)) + (s (dgeom dinf (midi-cps 72) (midi-ratio 1))) + (f (demand t r s)) + (o (sin-osc ar (mce2 f (add f 0.7)) 0))) + (audition (out 0 (mul (u:max (cubed o) 0) 0.1)))) + +(let* ((t (impulse kr 10 0)) + (s (midi-cps (diwhite dinf 60 72))) + (f (demand t 0 s)) + (o (sin-osc ar (mce2 f (add f 0.7)) 0))) + (audition (out 0 (mul (cubed (cubed o)) 0.1)))) diff --git a/rsc3/examples/ugen/demand/dgeom.help.scm b/rsc3/examples/ugen/demand/dgeom.help.scm new file mode 100644 index 0000000..60c949c --- /dev/null +++ b/rsc3/examples/ugen/demand/dgeom.help.scm @@ -0,0 +1,29 @@ +;; (dgeom length start grow) + +;; demand rate geometric series ugen. + +;; start - start value +;; grow - value by which to grow ( x = x[-1] * grow ) +;; length - number of values to create + +;; The arguments can be a number or any other ugen + +(let* ((a (dgeom 15 1 1.2)) + (t (impulse kr (mouse-x kr 1 40 1 0.1) 0)) + (f (mul-add (demand t 0 a) 30 340))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) + +;; demand rate UGens are not shared... + +(let* ((a (dgeom 15 1 1.2)) + (t (impulse ar (mouse-x kr 1 40 1 0.1) 0)) + (f0 (mul-add (demand (delay1 t) 0 a) 30 340)) + (f1 (mul-add (demand t 0 a) 30 340))) + (audition (out 0 (mul (sin-osc ar (mce2 f0 f1) 0) 0.1)))) + +(let* ((a0 (dgeom 15 1 1.2)) + (a1 (dgeom 15 1 1.2)) + (t (impulse ar (mouse-x kr 1 40 1 0.1) 0)) + (f0 (mul-add (demand (delay1 t) 0 a0) 30 340)) + (f1 (mul-add (demand t 0 a1) 30 340))) + (audition (out 0 (mul (sin-osc ar (mce2 f0 f1) 0) 0.1)))) diff --git a/rsc3/examples/ugen/demand/dibrown.help.scm b/rsc3/examples/ugen/demand/dibrown.help.scm new file mode 100644 index 0000000..25d1898 --- /dev/null +++ b/rsc3/examples/ugen/demand/dibrown.help.scm @@ -0,0 +1 @@ +;; See dbrown diff --git a/rsc3/examples/ugen/demand/diwhite.help.scm b/rsc3/examples/ugen/demand/diwhite.help.scm new file mode 100644 index 0000000..9179ca5 --- /dev/null +++ b/rsc3/examples/ugen/demand/diwhite.help.scm @@ -0,0 +1 @@ +;; See dwhite diff --git a/rsc3/examples/ugen/demand/drand.help.scm b/rsc3/examples/ugen/demand/drand.help.scm new file mode 100644 index 0000000..45990ef --- /dev/null +++ b/rsc3/examples/ugen/demand/drand.help.scm @@ -0,0 +1,18 @@ +;; (drand length array) +;; (dxrand length array) + +;; demand rate random sequence generators. + +;; length - number of values to return +;; array - array of values or other ugens + +;; dxrand never plays the same value twice, whereas drand chooses any +;; value in the list. + +(let ((f (lambda (u) + (let* ((a (u dinf (make-mce (list 1 3 2 7 8)))) + (t (impulse kr (mouse-x kr 1 400 1 0.1) 0)) + (f (mul-add (demand t 0 a) 30 340))) + (mul (sin-osc ar f 0) 0.1))))) + (audition (out 0 (mce2 (f drand) + (f dxrand))))) diff --git a/rsc3/examples/ugen/demand/dseq.help.scm b/rsc3/examples/ugen/demand/dseq.help.scm new file mode 100644 index 0000000..8f15db6 --- /dev/null +++ b/rsc3/examples/ugen/demand/dseq.help.scm @@ -0,0 +1,16 @@ +;; (dseq length array) + +;; demand rate sequence generator. + +;; array - array of values or other ugens +;; length - number of repeats + +(let* ((a (dseq 3 (make-mce (list 1 3 2 7 8)))) + (t (impulse kr (mouse-x kr 1 40 1 0.1) 0)) + (f (mul-add (demand t 0 a) 30 340))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) + +(let* ((a (dseq dinf (make-mce (replicate-m 32 (random 0 10))))) + (t (impulse ar (mouse-x kr 1 10000 1 0.1) 0)) + (f (mul-add (demand t 0 a) 30 340))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/demand/dser.help.scm b/rsc3/examples/ugen/demand/dser.help.scm new file mode 100644 index 0000000..505501a --- /dev/null +++ b/rsc3/examples/ugen/demand/dser.help.scm @@ -0,0 +1,12 @@ +;; (dser length array) + +;; demand rate sequence generator. + +;; array - array of values or other ugens +;; length - number of values to return + +(let* ((a (dser dinf (make-mce (list 1 3 2 7 8)))) + (x (mouse-x kr 1 40 1 0.1)) + (t (impulse kr x 0)) + (f (mul-add (demand t 0 a) 30 340))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/demand/dseries.help.scm b/rsc3/examples/ugen/demand/dseries.help.scm new file mode 100644 index 0000000..a63f9db --- /dev/null +++ b/rsc3/examples/ugen/demand/dseries.help.scm @@ -0,0 +1,14 @@ +;; (dseries length start step) + +;; demand rate arithmetic series ugen. + +;; length - number of values to create +;; start - start value +;; step - step value + +;; The arguments can be a number or any other ugen + +(let* ((a (dseries 15 0 1)) + (t (impulse kr (mouse-x kr 1 40 1 0.1) 0)) + (f (mul-add (demand t 0 a) 30 340))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/demand/dswitch.help.scm b/rsc3/examples/ugen/demand/dswitch.help.scm new file mode 100644 index 0000000..11b463d --- /dev/null +++ b/rsc3/examples/ugen/demand/dswitch.help.scm @@ -0,0 +1,32 @@ +;; (dswitch index array) + +;; demand rate generator for switching between inputs + +;; index - which of the inputs to return +;; array - array of values or other ugens + +;; In difference to dswitch1, dswitch embeds all items +;; of an input demand ugen first before looking up the +;; next index. + +(let* ((a0 (dwhite 2 3 4)) + (a1 (dwhite 2 0 1)) + (a2 (dseq 2 (make-mce (list 1 1 1 0)))) + (i (dseq 2 (make-mce (list 0 1 2 1 0)))) + (d (dswitch i (make-mce (list a0 a1 a2)))) + (t (impulse kr 4 0)) + (f (mul-add (demand t 0 d) 300 400)) + (o (mul (sin-osc ar f 0) 0.1))) + (audition (out 0 o))) + +;; compare with dswitch1 + +(let* ((a0 (dwhite 2 3 4)) + (a1 (dwhite 2 0 1)) + (a2 (dseq 2 (make-mce (list 1 1 1 0)))) + (i (dseq 2 (make-mce (list 0 1 2 1 0)))) + (d (dswitch1 i (make-mce (list a0 a1 a2)))) + (t (impulse kr 4 0)) + (f (mul-add (demand t 0 d) 300 400)) + (o (mul (sin-osc ar f 0) 0.1))) + (audition (out 0 o))) diff --git a/rsc3/examples/ugen/demand/dswitch1.help.scm b/rsc3/examples/ugen/demand/dswitch1.help.scm new file mode 100644 index 0000000..4d7eeb5 --- /dev/null +++ b/rsc3/examples/ugen/demand/dswitch1.help.scm @@ -0,0 +1,13 @@ +;; (dswitch1 index array) + +;; demand rate generator for switching between inputs + +;; index - which of the inputs to return +;; array - array of values or other ugens + +(let* ((x (mouse-x kr 0 4 0 0.1)) + (y (mouse-y kr 1 15 0 0.1)) + (a (dswitch1 x (make-mce (list 1 3 y 2 (dwhite 2 0 3))))) + (t (impulse kr 3 0)) + (f (mul-add (demand t 0 a) 30 340))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/demand/duty.help.scm b/rsc3/examples/ugen/demand/duty.help.scm new file mode 100644 index 0000000..ee554f7 --- /dev/null +++ b/rsc3/examples/ugen/demand/duty.help.scm @@ -0,0 +1,39 @@ +;; (duty rate duration reset doneAction level) + +;; demand results from demand rate ugens + +;; A value is demanded from each ugen in the list and output according +;; to a stream of duration values. The unit generators in the list +;; should be 'demand' rate. When there is a trigger at the reset +;; input, the demand rate ugens in the list and the duration are +;; reset. The reset input may also be a demand ugen, providing a +;; stream of reset times. + +;; duration: time values. Can be a demand ugen or any signal. The +;; next value is acquired after the duration provided by the last time +;; value. + +;; reset: trigger or reset time values. Resets the list of ugens and +;; the duration ugen when triggered. The reset input may also be a +;; demand ugen, providing a stream of reset times. + +;; doneAction: a doneAction that is evaluated when the duration stream +;; ends. + +;; level: demand ugen providing the output values. + +(let* ((f (duty kr + (drand dinf (mce3 0.01 0.2 0.4)) + 0 + 2 + (dseq dinf (make-mce (list 204 400 201 502 300 200))))) + (o (sin-osc ar (mul f (mce2 1 1.01)) 0))) + (audition (out 0 (mul o 0.1)))) + +(let* ((f (duty kr + (mouse-x kr 0.001 2 1 0.1) + 0 + 2 + (dseq dinf (make-mce (list 204 400 201 502 300 200))))) + (o (sin-osc ar (mul f (mce2 1 1.0)) 0))) + (audition (out 0 (mul o 0.1)))) diff --git a/rsc3/examples/ugen/demand/dwhite.help.scm b/rsc3/examples/ugen/demand/dwhite.help.scm new file mode 100644 index 0000000..93c2cd0 --- /dev/null +++ b/rsc3/examples/ugen/demand/dwhite.help.scm @@ -0,0 +1,22 @@ +;; (dwhite length lo hi) +;; (diwhite length lo hi) + +;; demand rate white noise random generators. + +;; length number of values to create +;; lo minimum value +;; hi maximum value + +;; dwhite returns numbers in the continuous range between lo and hi, +;; diwhite returns integer values. The arguments can be a number or +;; any other ugen + +(let* ((a (dwhite dinf 0 15)) + (t (impulse kr (mouse-x kr 1 40 1 0.1) 0)) + (f (mul-add (demand t 0 a) 30 340))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) + +(let* ((a (diwhite dinf 0 15)) + (t (impulse kr (mouse-x kr 1 40 1 0.1) 0)) + (f (mul-add (demand t 0 a) 30 340))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/demand/dxrand.help.scm b/rsc3/examples/ugen/demand/dxrand.help.scm new file mode 100644 index 0000000..3c9148c --- /dev/null +++ b/rsc3/examples/ugen/demand/dxrand.help.scm @@ -0,0 +1 @@ +;; See drand diff --git a/rsc3/examples/ugen/demand/t-duty.help.scm b/rsc3/examples/ugen/demand/t-duty.help.scm new file mode 100644 index 0000000..d5c34a2 --- /dev/null +++ b/rsc3/examples/ugen/demand/t-duty.help.scm @@ -0,0 +1,50 @@ +;; (t-duty rate duration reset doneAction level gap) + +;; demand results as trigger from demand rate ugens. + +;; A value is demanded each ugen in the list and output as a trigger +;; according to a stream of duration values. The unit generators in +;; the list should be 'demand' rate. When there is a trigger at the +;; reset input, the demand rate ugens in the list and the duration are +;; reset. The reset input may also be a demand ugen, providing a +;; stream of reset times. + +;; NOTE: sclang reorders the inputs to be 'duration reset level +;; doneAction', rsc does not. + +;; duration - time values. Can be a demand ugen or any signal. +;; The next trigger value is acquired after the +;; duration provided by the last time value. + +;; reset - trigger or reset time values. Resets the list of ugens +;; and the duration ugen when triggered. The reset input +;; may also be a demand ugen, providing a stream of reset +;; times. + +;; doneAction - a doneAction that is evaluated when the duration +;; stream ends. + +;; level - demand ugen providing the output values. + +;; Play a little rhythm + +(let ((s (dseq dinf (make-mce (list 0.1 0.2 0.4 0.3))))) + (audition (out 0 (t-duty ar s 0 0 1 0)))) + +;; Amplitude changes + +(let ((t (t-duty ar + (dseq dinf (make-mce (list 0.1 0.2 0.4 0.3))) + 0 + 0 + (dseq dinf (make-mce (list 0.1 0.4 0.01 0.5 1.0))) + 0))) + (audition (out 0 (ringz t 1000 0.1)))) + +(let ((t (t-duty ar + (mouse-x kr 0.001 2 1 0.1) + 0 + 0 + (dseq dinf (make-mce (list 0.1 0.4 0.01 0.5 1.0))) + 0))) + (audition (out 0 (ringz t 1000 0.1)))) diff --git a/rsc3/examples/ugen/disk-io/disk-in.help.scm b/rsc3/examples/ugen/disk-io/disk-in.help.scm new file mode 100644 index 0000000..a046d40 --- /dev/null +++ b/rsc3/examples/ugen/disk-io/disk-in.help.scm @@ -0,0 +1,25 @@ +;; (disk-in num-channels rate bufnum) + +;; Continously play a soundfile from disk. This requires a buffer to +;; be preloaded with one buffer size of sound. The buffer size must +;; be a multiple of twice the synth block size. The default block size +;; is 64. + +;; Note that disk-in reads the number of outputs to create from what +;; looks like an input, but it is not an input, and cannot be set +;; using a control. + +(let ((f "/home/rohan/audio/metal.wav") + (n 1)) + (with-sc3 + (lambda (fd) + (async fd (b-alloc 0 8192 n)) + (async fd (b-read 0 f 0 -1 0 1)) + (play fd (out 0 (disk-in n ar 0)))))) + +(with-sc3 reset) + +(with-sc3 + (lambda (fd) + (async fd (b-close 0)) + (async fd (b-free 0)))) diff --git a/rsc3/examples/ugen/disk-io/disk-out.help.scm b/rsc3/examples/ugen/disk-io/disk-out.help.scm new file mode 100644 index 0000000..ebfed5a --- /dev/null +++ b/rsc3/examples/ugen/disk-io/disk-out.help.scm @@ -0,0 +1,45 @@ +;; (disk-out bufnum channels) + +;; Note: There are constraints on the size of the buffer, it must be +;; greater than or equal to twice the size of the audio bus. There +;; must be the same number of channels at the buffer and the disk-out +;; ugen. + +(let ((bus-size 1024) + (bufferexpt 15)) + (= 0 (fxand (expt 2 bufferexpt) + (- (fxarithmetic-shift bus-size 1) 1)))) + +(let ((g (letc ((bufnum 0)) + (let ((z (clip2 + (rlpf + (lf-pulse ar + (mul-add (sin-osc kr 0.2 0) 10 21) + (mce2 0 0.1) + 0.1) + 100 + 0.1) + 0.4))) + (mrg2 (disk-out bufnum z) + (out 0 z)))))) + (with-sc3 + (lambda (fd) + (send-synth fd "disk-out-help" g) + (async fd (b-alloc 10 32768 2)) + (async fd (b-write 10 + "/tmp/test.aiff" + "aiff" + "float" + 32768 + 0 + 1)) + (send fd (s-new1 "disk-out-help" 1001 1 1 "bufnum" 10))))) + +(with-sc3 + (lambda (fd) + (send fd (n-free1 1001)) + (async fd (b-close 10)) + (async fd (b-free 10)))) + +(system "sndfile-info /tmp/test.aiff") +(system "jack.play /tmp/test.aiff") diff --git a/rsc3/examples/ugen/envelopes/detect-silence.help.scm b/rsc3/examples/ugen/envelopes/detect-silence.help.scm new file mode 100644 index 0000000..16b9ef7 --- /dev/null +++ b/rsc3/examples/ugen/envelopes/detect-silence.help.scm @@ -0,0 +1,10 @@ +;; (detect-silence in amp time doneAction) + +;; If the signal at `in' falls below `amp' for `time' seconds then +;; `doneAction' is raised. + +(let ((s (mul (sin-osc ar 440 0) (mouse-y kr 0 0.4 0 0.1)))) + (audition (mrg2 (detect-silence s 0.1 0.2 remove-synth) + (out 0 s)))) + +(with-sc3 display-server-status) diff --git a/rsc3/examples/ugen/envelopes/done.help.scm b/rsc3/examples/ugen/envelopes/done.help.scm new file mode 100644 index 0000000..f275a99 --- /dev/null +++ b/rsc3/examples/ugen/envelopes/done.help.scm @@ -0,0 +1,11 @@ +;; (done src) + +;; outputs a unit signal if the 'done' flag of the unit at `src' is +;; set, else output zero. + +(let* ((x (mouse-x kr -1 1 0 0.1)) + (e (linen x 0.1 0.1 0.5 do-nothing)) + (l (mul (sin-osc ar 880 0) 0.1)) + (r (sin-osc ar 440 0))) + (audition (out 0 (mce2 (mul (done e) l) + (mul e r))))) diff --git a/rsc3/examples/ugen/envelopes/env-gen.help.scm b/rsc3/examples/ugen/envelopes/env-gen.help.scm new file mode 100644 index 0000000..7786847 --- /dev/null +++ b/rsc3/examples/ugen/envelopes/env-gen.help.scm @@ -0,0 +1,53 @@ +;; (env-gen rate gate levelScale levelBias timeScale doneAction envelope) + +;; A segment based envelope generator. Note that the SC3 language +;; reorders the inputs to this UGen so that the envelope is the first +;; argument. + +;; There are utilities for contructing the envelope argument. + +;; The arguments for levelScale, levelBias, and timeScale are polled +;; when the env-gen is triggered and remain constant for the duration +;; of the envelope. + +;; envelope - an breakpoint set + +;; gate - this triggers the envelope and holds it open while > 0. If +;; the Env is fixed-length (e.g. Env.linen, Env.perc), the gate +;; argument is used as a simple trigger. If it is an sustaining +;; envelope (e.g. Env.adsr, Env.asr), the envelope is held open +;; until the gate becomes 0, at which point is released. + +;; levelScale - scales the levels of the breakpoints. + +;; levelBias - offsets the levels of the breakpoints. + +;; timeScale - scales the durations of the segments. + +;; doneAction - an integer representing an action to be executed when +;; the env is finished playing. This can be used to free +;; the enclosing synth, etc. + +(import (rhs) (rsc3)) + +;; Percussive envelope +(let* ((d (env-perc 0.01 1 1 (list -4 -4))) + (e (env-gen kr 1 0.1 0 1 remove-synth d))) + (audition (out 0 (mul e (sin-osc ar 440 0))))) + +;; The break-point assistant makes a static envelope from a +;; co-ordinate list. There is a duration and amplitude scalar. +(let* ((d (env-coord (list (cons 0 0) + (cons 0.75 1) + (cons 1 0)) + 1 1 (replicate 3 "linear"))) + (e (env-gen kr 1 0.1 0 1 remove-synth d))) + (audition (out 0 (mul e (sin-osc ar 440 0))))) + +;; Trapezoidal +(let* ((d (env-trapezoid 0 0.25 2 0.1)) + (e (env-gen kr 1 0.1 0 1 remove-synth d))) + (audition (out 0 (mul e (sin-osc ar 440 0))))) + +;; 0.0 3 -1 -1 0.1 0.5 1.0 0.0 0.1 0.0 1.0 0.0 0.0 1.5 1.0 0.0 +(env-trapezoid 0 0.25 2 0.1) diff --git a/rsc3/examples/ugen/envelopes/free-self-when-done.help.scm b/rsc3/examples/ugen/envelopes/free-self-when-done.help.scm new file mode 100644 index 0000000..4e6d975 --- /dev/null +++ b/rsc3/examples/ugen/envelopes/free-self-when-done.help.scm @@ -0,0 +1,12 @@ +;; (free-self-when-done src) + +;; free the synth when the 'done' flag of the unit at `src' is set. + +(let* ((x (mouse-x kr -1 1 0 0.1)) + (e (linen x 1 0.1 1 remove-synth))) + (audition (out 0 (mul (sin-osc ar 440 0) e)))) + +(let* ((x (mouse-x kr -1 1 0 0.1)) + (e (linen x 2 0.1 2 do-nothing))) + (audition (mrg2 (free-self-when-done e) + (out 0 (mul (sin-osc ar 440 0) e))))) diff --git a/rsc3/examples/ugen/envelopes/free-self.help.scm b/rsc3/examples/ugen/envelopes/free-self.help.scm new file mode 100644 index 0000000..f5bcb9d --- /dev/null +++ b/rsc3/examples/ugen/envelopes/free-self.help.scm @@ -0,0 +1,8 @@ +;; (free-self src) + +;; free enclosing synth when the input signal `src' crosses from +;; non-positive to positive. + +(audition + (mrg2 (free-self (mouse-x kr -1 1 0 0.1)) + (out 0 (mul (sin-osc ar 440 0) 0.1)))) diff --git a/rsc3/examples/ugen/envelopes/free.help.scm b/rsc3/examples/ugen/envelopes/free.help.scm new file mode 100644 index 0000000..eaa1de8 --- /dev/null +++ b/rsc3/examples/ugen/envelopes/free.help.scm @@ -0,0 +1,16 @@ +;; (free trig nodeID) + +;; When triggered frees a node. + +;; trig - when triggered, frees node +;; nodeID - node to be freed + +(with-sc3 + (lambda (fd) + (send-synth fd "a" (out 0 (mul (sin-osc ar 800 0) 0.1))) + (send-synth fd "b" (mrg2 (out 1 (mul (pink-noise ar) 0.1)) + (free (dust ar 6) 1001))) + (send fd (s-new0 "a" 1001 0 0)) + (send fd (s-new0 "b" -1 0 0)))) + +(with-sc3 reset) diff --git a/rsc3/examples/ugen/envelopes/line.help.scm b/rsc3/examples/ugen/envelopes/line.help.scm new file mode 100644 index 0000000..682ddae --- /dev/null +++ b/rsc3/examples/ugen/envelopes/line.help.scm @@ -0,0 +1,13 @@ +;; (line rate start end dur doneAction) + +;; Generates a line from the start value to the end value. + +;; start - starting value +;; end - ending value +;; dur - duration in seconds + +;; Note: The SC3 UGen reorders the mul and add inputs to precede the +;; doneAction input. + +(let ((f (line kr 200 17000 5 remove-synth))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/envelopes/linen.help.scm b/rsc3/examples/ugen/envelopes/linen.help.scm new file mode 100644 index 0000000..0297afb --- /dev/null +++ b/rsc3/examples/ugen/envelopes/linen.help.scm @@ -0,0 +1,33 @@ +;; (linen gate attackTime susLevel releaseTime doneAction) + +;; A linear envelope generator. The done flag is set when the +;; envelope reaches zero. + +;; Note that the sustain level input is consulted only at the instant +;; when the gate is opened. + +(let ((e (linen (impulse kr 2 0) 0.01 0.1 0.4 do-nothing))) + (audition (out 0 (mul (sin-osc ar 440 0) e)))) + +(let* ((y (mouse-y kr 0.1 0.5 0 0.1)) + (x (mouse-x kr -1 1 0 0.1)) + (e (linen x 1 y 1.0 do-nothing)) + (o (sin-osc ar 440 0))) + (audition (out 0 (mul o e)))) + +;; Open gate for a random interval. + +(let* ((r (rand 0.05 0.4)) + (u (letc ((gate 0)) + (let ((e (linen gate 0.1 0.2 0.1 do-nothing))) + (out 0 (mul (sin-osc ar 440 0) e))))) + (g (encode-graphdef (synthdef "linen" u)))) + (with-sc3 + (lambda (fd) + (async fd (d-recv g)) + (send fd (s-new0 "linen" 1001 1 1)) + (send fd (bundle (utc) (n-set1 1001 "gate" 1))) + (send fd (bundle (+ (utc) r) + (n-set1 1001 "gate" 0))) + (sleep (* r 4)) + (send fd (n-free1 1001))))) diff --git a/rsc3/examples/ugen/envelopes/pause-self-when-done.help.scm b/rsc3/examples/ugen/envelopes/pause-self-when-done.help.scm new file mode 100644 index 0000000..d738291 --- /dev/null +++ b/rsc3/examples/ugen/envelopes/pause-self-when-done.help.scm @@ -0,0 +1,12 @@ +;; (pause-self-when-done src) + +;; pause the synth when the 'done' flag of the unit at `src' is set. + +(let* ((x (mouse-x kr -1 1 0 0.1)) + (e (linen x 1 0.1 1 pause-synth))) + (audition (out 0 (mul (sin-osc ar 440 0) e)))) + +(let* ((x (mouse-x kr -1 1 0 0.1)) + (e (linen x 2 0.1 2 do-nothing))) + (audition (mrg2 (pause-self-when-done e) + (out 0 (mul (sin-osc ar 440 0) e))))) diff --git a/rsc3/examples/ugen/envelopes/pause-self.help.scm b/rsc3/examples/ugen/envelopes/pause-self.help.scm new file mode 100644 index 0000000..cad7b51 --- /dev/null +++ b/rsc3/examples/ugen/envelopes/pause-self.help.scm @@ -0,0 +1,9 @@ +;; (pause-self src) + +;; pause enclosing synth when input signal crosses from non-positive +;; to positive. If the synth is restarted and the gate reset the +;; synthesis *not* paused a second time. + +(audition + (mrg2 (pause-self (mouse-x kr -1 1 0 0.1)) + (out 0 (mul (sin-osc ar 440 0) 0.1)))) diff --git a/rsc3/examples/ugen/envelopes/pause.help.scm b/rsc3/examples/ugen/envelopes/pause.help.scm new file mode 100644 index 0000000..5d12be3 --- /dev/null +++ b/rsc3/examples/ugen/envelopes/pause.help.scm @@ -0,0 +1,21 @@ +;; (pause gate nodeID) + +;; When triggered pauses a node. + +;; gate - when gate is 0, node is paused, when 1 it runs +;; nodeID - node to be paused + +(with-sc3 + (lambda (fd) + (send-synth fd "a" (out 0 (mul (sin-osc ar 800 0) 0.1))) + (send-synth fd "b" (letc ((g 1)) + (Mrg (out 1 (mul (pink-noise ar) 0.05)) + (pause g 1001)))) + (send fd (/s_new "a" 1001 0 0)) + (send fd (/s_new "b" 1002 0 0)) + (sleep 1) + (send fd (/n_set 1002 "g" 0)) + (sleep 1) + (send fd (/n_set 1002 "g" 1)) + (sleep 1) + (reset fd))) diff --git a/rsc3/examples/ugen/envelopes/x-line.help.scm b/rsc3/examples/ugen/envelopes/x-line.help.scm new file mode 100644 index 0000000..bf7de63 --- /dev/null +++ b/rsc3/examples/ugen/envelopes/x-line.help.scm @@ -0,0 +1,14 @@ +;; (x-line rate start end dur doneAction) + +;; Exponential line generator. Generates an exponential curve from +;; the start value to the end value. Both the start and end values +;; must be non-zero and have the same sign. + +;; start - starting value +;; end - ending value +;; dur - duration in seconds +;; doneAction - a doneAction to be evaluated when the x-line is +;; completed. See env-gen for details. + +(let ((f (x-line kr 200 17000 10 remove-synth))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/fft/convolution.help.scm b/rsc3/examples/ugen/fft/convolution.help.scm new file mode 100644 index 0000000..9145e47 --- /dev/null +++ b/rsc3/examples/ugen/fft/convolution.help.scm @@ -0,0 +1,27 @@ +;; (convolution in kernel framesize) + +;; Strict convolution of two continuously changing inputs. Also see +;; [convolution2] for a cheaper CPU cost alternative for the case of a +;; fixed kernel which can be changed with a trigger message. + +;; in - processing target +;; kernel - processing kernel. +;; framesize - size of fft frame, must be a power of two + +(audition + (let ((input (sound-in (mce2 0 1))) + (kernel (white-noise ar))) + (out 0 (mul (convolution input kernel 2048) 0.1)))) + +(let ((a 2048) + (b 0)) + (with-sc3 + (lambda (fd) + (async fd (b-alloc b a 1)) + (send fd (b-set1 b 0 1.0)) + (replicate-m 100 (send fd (b-set1 b (random-integer a) (random 0.0 1.0)))) + (play fd (out 0 (mul (convolution + (sound-in (mce2 0 1)) + (play-buf 1 b (buf-rate-scale kr b) 1 0 1) + (* 2 a)) + 0.2)))))) diff --git a/rsc3/examples/ugen/fft/convolution2.help.scm b/rsc3/examples/ugen/fft/convolution2.help.scm new file mode 100644 index 0000000..b641d5d --- /dev/null +++ b/rsc3/examples/ugen/fft/convolution2.help.scm @@ -0,0 +1,81 @@ +;; (convolution2 in bufnum trigger framesize) + +#| + +Strict convolution with fixed kernel which can be updated using a +trigger signal. + +in - processing target +bufnum - buffer index for the fixed kernel, may be modulated in + combination with the trigger +trigger - update the kernel on a change from <=0 to >0 +framesize - size of fft frame, must be a power of two. convolution + uses twice this number internally, maximum value you + can give this argument is 2^16=65536. Note that it gets + progressively more expensive to run for higher powers! + 512, 1024, 2048, 4096 standard. + +|# + +(with-sc3 + (lambda (fd) + (for-each + (lambda (b) + (async fd (b-alloc b 2048 1))) + (list 10 11 12)) + (for-each + (lambda (n) + (send fd (b-set1 10 (+ (* 400 n) 100) 1))) + (enum-from-to 0 2)) + (for-each + (lambda (n) + (send fd (b-set1 11 (+ (* 20 n) 10) (random 0 1)))) + (enum-from-to 0 49)) + (for-each + (lambda (n) + (send fd (b-set1 12 (+ (* 40 n) 20) 1))) + (enum-from-to 0 19)) + (send-synth + fd "c" + (letc ((k 0) (t 0)) + (let ((i (impulse ar 1 0))) + (out 0 (mul (convolution2 i k t 2048) 0.5))))))) + +(define send-to + (lambda (m) + (with-sc3 + (lambda (fd) + (send fd m))))) + +(define async-to + (lambda (m) + (with-sc3 + (lambda (fd) + (async fd m))))) + +(send-to (s-new1 "c" 1001 1 1 "k" 10)) + +(send-to (n-set1 1001 "k" 11)) +(send-to (n-set1 1001 "t" 0)) +(send-to (n-set1 1001 "t" 1)) + +(send-to (n-set1 1001 "k" 12)) +(send-to (n-set1 1001 "t" 0)) +(send-to (n-set1 1001 "t" 1)) + +(async-to (b-zero 12)) + +(for-each + (lambda (n) + (send-to (b-set1 12 (+ (* 20 n) 10) 1))) + (enum-from-to 0 39)) + +(send-to (n-set1 1001 "t" 0)) +(send-to (n-set1 1001 "t" 1)) + +;; With soundfile. + +(async-to (b-alloc-read 10 "/home/rohan/audio/metal.wav" 0 0)) + +(let ((i (sound-in 0))) + (audition (out 0 (mul (convolution2 i 10 0 512) 0.5)))) diff --git a/rsc3/examples/ugen/fft/fft.help.scm b/rsc3/examples/ugen/fft/fft.help.scm new file mode 100644 index 0000000..1fa31ce --- /dev/null +++ b/rsc3/examples/ugen/fft/fft.help.scm @@ -0,0 +1,25 @@ +;; (fft buffer in hop wintype active) +;; (fft* b i) => (fft b i 0.5 0 1) + +;; Fast fourier transform. The fast fourier transform analyzes the +;; frequency content of a signal. fft uses a local buffer for holding +;; the buffered audio. The inverse transform, Ifft, reconstructs an +;; audio signal. + +;; Note that the UGens the SC3 language provides do not use rate +;; extensions, since only a single rate is valid for each UGen class. +;; The fft and PV_ UGens must run at control rate, the ifft UGen at +;; audio rate. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)))) + +(let* ((s (mul (white-noise ar) 0.05)) + (c (fft* 10 s))) + (audition (out 0 (ifft* c)))) + +(let* ((f1 (Squared (mul-add (sin-osc kr 0.08 0) 6 6.2))) + (f2 (mul-add (sin-osc kr f1 0) 100 800)) + (s (sin-osc ar f2 0))) + (audition (out 0 (ifft* (fft* 10 s))))) diff --git a/rsc3/examples/ugen/fft/ifft.help.scm b/rsc3/examples/ugen/fft/ifft.help.scm new file mode 100644 index 0000000..a527180 --- /dev/null +++ b/rsc3/examples/ugen/fft/ifft.help.scm @@ -0,0 +1,13 @@ +;; (Ifft buffer wintype) +;; (ifft* b) => (ifft b 0) + +;; inverse Fast Fourier Transform. The inverse fast fourier transform +;; converts from frequency content to a signal. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 2048 1)))) + +(let* ((s (mul (white-noise ar) 0.05)) + (c (fft 0 s 0.5 0 1))) + (audition (out 0 (Ifft c 0)))) diff --git a/rsc3/examples/ugen/fft/pack-fft.help.scm b/rsc3/examples/ugen/fft/pack-fft.help.scm new file mode 100644 index 0000000..a825014 --- /dev/null +++ b/rsc3/examples/ugen/fft/pack-fft.help.scm @@ -0,0 +1,49 @@ +;; (Packfft chain bufsize frombin tobin zeroothers magsphases) + +;; Pack separate demand-rate fft bin streams into an fft chain buffer + +;; Takes a length-prefixed array of magnitudes and phases, and packs +;; them into an fft buffer ready for transforming back into +;; time-domain audio using Ifft. + +;; Most people won't need to use this directly - instead, use +;; pvcollect, pvcalc, or pvcalc2. + +;; The input data is magsphases, which should be a flat array +;; containing magnitude and phase of all bins in ascending order. +;; e.g. [mag0, phase0, mag1, phase1, mag2, phase2, ... magN, phaseN] +;; This input is typically demand-rate. + +;; This is technically similar to demand or duty in that it calls +;; demand-rate UGens further up the graph to process the values, +;; eventually calling Unpackfft. These two ends of the process must in +;; most cases see the same chain...! Otherwise behaviour is undefined +;; and, who knows, possibly unpleasant. + +;; frombin and tobin allow you to fill the supplied data only into a +;; subset of the fft bins (i.e. a single delimited frequency band), +;; set zeroothers to 1 to zero all the magnitudes outside this band +;; (otherwise they stay intact). + +;; For usage examples, see Unpackfft, but also pvcollect, pvcalc, +;; pvcalc2. + +;; Here's an unusual example which uses Packfft without using +;; Unpackfft first - essentially creating our fft data from scratch. + +(with-sc3 + (lambda (fd) + (send fd (b-alloc 10 512 1)))) + +(let* ((n 100) + (n* (enum-from-to 1 n)) + (m1 (map (lambda (_) (range (f-sin-osc kr (exp-rand 0.1 1) 0) 0 1)) n*)) + (square (lambda (a) (* a a))) + (m2 (map mul m1 (map square (iota n 1.0 (- (/ 1.0 n)))))) + (i (map (lambda (_) (lf-pulse kr (pow 2 (i-rand -3 5)) 0 0.3)) n*)) + (m3 (map mul m2 i)) + (p (replicate n 0.0)) + (c1 (fft* 10 (f-sin-osc ar 440 0))) + (c2 (pack-fft c1 512 0 (- n 1) 1 (packfft-data m3 p))) + (s (ifft* c2))) + (audition (out 0 (mce2 s s)))) diff --git a/rsc3/examples/ugen/fft/pv-add.help.scm b/rsc3/examples/ugen/fft/pv-add.help.scm new file mode 100644 index 0000000..275335b --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-add.help.scm @@ -0,0 +1,20 @@ +;; (pv-add bufferA bufferB) + +;; Complex addition: RealA + RealB, ImagA + ImagB + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc 11 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((a (play-buf 1 12 (buf-rate-scale kr 12) 0 0 1)) + (f (fft* 10 a)) + (g (fft* 11 (mul (sin-osc ar 440 0) 0.2))) + (h (pv-add f g))) + (audition (out 0 (mul (ifft* h) 0.5)))) + +(audition + (out 0 (mul (add (play-buf 1 12 (buf-rate-scale kr 12) 0 0 1) + (mul (sin-osc ar 440 0) 0.2)) + 0.5))) diff --git a/rsc3/examples/ugen/fft/pv-bin-scramble.help.scm b/rsc3/examples/ugen/fft/pv-bin-scramble.help.scm new file mode 100644 index 0000000..87a3258 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-bin-scramble.help.scm @@ -0,0 +1,34 @@ +;; (pv-bin-scramble buffer wipe width trig) + +;; randomizes the order of the bins. The trigger will select a new +;; random ordering. + +;; buffer - fft buffer. +;; wipe - scrambles more bins as wipe moves from zero to one. +;; width - a value from zero to one, indicating the maximum randomized +;; distance of a bin from its original location in the spectrum. +;; trig - a trigger selects a new random ordering. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((a (play-buf 1 12 (buf-rate-scale kr 12) 1 0 1)) + (f (fft* 10 a)) + (g (pv-bin-scramble f + (mouse-x kr 0.0 1.0 0 0.1) + (mouse-y kr 0.0 1.0 0 0.1) + (impulse kr 4 0))) + (h (ifft* g))) + (audition (out 0 (mul 0.5 (mce2 h h))))) + +;; careful - reads adc! +(let* ((a (mul (sound-in (mce2 0 1)) 4.0)) + (f (fft* 10 a)) + (g (pv-bin-scramble f + (mouse-x kr 0.25 1.0 0 0.1) + (mouse-y kr 0.25 1.0 0 0.1) + (impulse kr (mul-add (lf-noise0 kr 2) 8 10) 0))) + (h (ifft* g))) + (audition (out 0 (pan2 h 0 0.5)))) diff --git a/rsc3/examples/ugen/fft/pv-bin-shift.help.scm b/rsc3/examples/ugen/fft/pv-bin-shift.help.scm new file mode 100644 index 0000000..32a79c3 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-bin-shift.help.scm @@ -0,0 +1,26 @@ +;; (pv-bin-shift buffer stretch shift) + +;; Shift and scale the positions of the bins. Can be used as a very +;; crude frequency shifter/scaler. Shifts the leftmost bin at +;; `buffer' by `shift' places, the distance between subsequent bins is +;; `stretch'. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)))) + +(define snd + (let* ((f1 (squared (mul-add (sin-osc kr 0.08 0) 6 6.2))) + (f2 (sin-osc kr f1 0))) + (sin-osc ar (mul-add f2 100 800) 0))) + +(audition (out 0 snd)) + +(audition + (out 0 (mul + (ifft* + (pv-bin-shift + (fft* 10 snd) + (mouse-y kr 1 4 0 0.1) + (mouse-x kr -10 100 0 0.1))) + 1/2))) diff --git a/rsc3/examples/ugen/fft/pv-bin-wipe.help.scm b/rsc3/examples/ugen/fft/pv-bin-wipe.help.scm new file mode 100644 index 0000000..2f40c83 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-bin-wipe.help.scm @@ -0,0 +1,33 @@ +;; (pv-bin-wipe bufferA bufferB wipe) + +;; Combine low and high bins from two inputs + +;; Copies low bins from one input and the high bins of the other. + +;; bufferA - fft buffer A. +;; bufferB - fft buffer B. +;; wipe - can range between -1 and +1. + +;; if wipe == 0 then the output is the same as inA. +;; if wipe > 0 then it begins replacing with bins from inB from the bottom up. +;; if wipe < 0 then it begins replacing with bins from inB from the top down. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc 11 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((a (mul (white-noise ar) 0.2)) + (b (mul (sin-osc ar 100 0) 0.2)) + (f (fft* 10 a)) + (g (fft* 11 b)) + (h (pv-bin-wipe f g (mouse-x kr -1 1 0 0.1)))) + (audition (out 0 (mul (ifft* h) 0.5)))) + +(let* ((a (mul (white-noise ar) 0.2)) + (b (play-buf 1 12 (buf-rate-scale kr 12) 0 0 1)) + (f (fft* 10 a)) + (g (fft* 11 b)) + (h (pv-bin-wipe f g (mouse-x kr -1 1 0 0.1)))) + (audition (out 0 (mul (ifft* h) 0.5)))) diff --git a/rsc3/examples/ugen/fft/pv-brick-wall.help.scm b/rsc3/examples/ugen/fft/pv-brick-wall.help.scm new file mode 100644 index 0000000..353e79f --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-brick-wall.help.scm @@ -0,0 +1,13 @@ +;; (pv-brick-wall buffer wipe) + +;; Clears bins above or below a cutoff point. `wipe' = a unit signal, +;; from -1 to 0 the UGen acts as a low-pass filter, from 0 to 1 it +;; acts as a high pass filter. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)))) + +(let ((x (mouse-x kr -1 1 0 0.1)) + (c (fft* 10 (mul (white-noise ar) 0.2)))) + (audition (out 0 (ifft* (pv-brick-wall c x))))) diff --git a/rsc3/examples/ugen/fft/pv-conformal-map.help.scm b/rsc3/examples/ugen/fft/pv-conformal-map.help.scm new file mode 100644 index 0000000..99cbe28 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-conformal-map.help.scm @@ -0,0 +1,40 @@ +;; (pv-conformal-map buffer real imag) + +;; Applies the conformal mapping z send (z-a)/(1-za*) to the phase +;; vocoder bins z with a given by the real and imag imputs to the +;; UGen. + +;; See http://mathworld.wolfram.com/ConformalMapping.html + +;; buffer - buffer number of buffer to act on, passed in through a chain +;; real - real part of a. +;; imag - imaginary part of a. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 1024 1)) + (async fd (b-alloc 0 2048 1)))) + +(audition + (out 0 (pan2 + (ifft* + (pv-conformal-map + (fft* 10 (mul (sound-in 0) 0.5)) (mouse-x kr -1 1 0 0.1) + (mouse-y kr -1 1 0 0.1))) + 0 + 1))) + +(let* ((signal (lambda (n) + (let* ((o (sin-osc kr (mix-fill n (lambda (_) (rand 0.1 0.5))) 0)) + (a (mul (make-mce (list 1 1.1 1.5 1.78 2.45 6.7)) 220)) + (f (mul-add o 10 a))) + (mix (mul (lf-saw ar f 0) 0.3))))) + (mapped (lambda (n) + (let* ((c0 (fft* 0 (signal n))) + (x (mouse-x kr 0.01 2.0 1.0 0.1)) + (y (mouse-y kr 0.01 10.0 1.0 0.1)) + (c1 (pv-conformal-map c0 x y))) + (ifft* c1)))) + (s (mapped 3)) + (t (mul-add (comb-n s 0.1 0.1 10) 0.5 s))) + (audition (out 0 (pan2 t 0 1)))) diff --git a/rsc3/examples/ugen/fft/pv-copy-phase.help.scm b/rsc3/examples/ugen/fft/pv-copy-phase.help.scm new file mode 100644 index 0000000..1b65d63 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-copy-phase.help.scm @@ -0,0 +1,23 @@ +;; (pv-copyPhase bufferA bufferB) + +;; Combines magnitudes of first input and phases of the second input. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc 11 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((a (mul (white-noise ar) 0.2)) + (b (mul (sin-osc ar 100 0) 0.2)) + (f (fft* 10 a)) + (g (fft* 11 b)) + (h (pv-copy-phase f g))) + (audition (out 0 (mul (ifft* h) 0.5)))) + +(let* ((a (mul (white-noise ar) 0.2)) + (b (play-buf 1 12 (buf-rate-scale kr 12) 0 0 1)) + (f (fft* 10 a)) + (g (fft* 11 b)) + (h (pv-copy-phase f g))) + (audition (out 0 (mul (ifft* h) 0.5)))) diff --git a/rsc3/examples/ugen/fft/pv-copy.help.scm b/rsc3/examples/ugen/fft/pv-copy.help.scm new file mode 100644 index 0000000..e5525d0 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-copy.help.scm @@ -0,0 +1,22 @@ +;; (pv-copy bufferA bufferB) + +;; Copies the spectral frame in bufferA to bufferB at that point in +;; the chain of PV UGens. This allows for parallel processing of +;; spectral data without the need for multiple fft UGens, and to copy +;; out data at that point in the chain for other purposes. bufferA and +;; bufferB must be the same size. + +;; bufferA - source buffer. +;; bufferB - destination buffer. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 2048 1)) + (async fd (b-alloc 1 2048 1)))) + +;; Proof of concept, silence + +(let* ((in (lfclip-noise ar 100)) + (c0 (fft* 0 in)) + (c1 (pv-copy c0 1))) + (audition (out 0 (sub (ifft* c0) (ifft* c1))))) diff --git a/rsc3/examples/ugen/fft/pv-diffuser.help.scm b/rsc3/examples/ugen/fft/pv-diffuser.help.scm new file mode 100644 index 0000000..d551fe3 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-diffuser.help.scm @@ -0,0 +1,17 @@ +;; (pv-diffuser buffer trig) + +;; adds a different constant random phase shift to each bin. +;; The trigger will select a new set of random phases. + +;; buffer - fft buffer. +;; trig - a trigger selects a new set of random values. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((a (play-buf 1 12 (buf-rate-scale kr 12) 0 0 1)) + (f (fft* 10 a)) + (h (pv-diffuser f (gt (mouse-x kr 0 1 0 0.1) 0.5)))) + (audition (out 0 (mul (ifft* h) 0.5)))) diff --git a/rsc3/examples/ugen/fft/pv-hainsworth-foote.help.scm b/rsc3/examples/ugen/fft/pv-hainsworth-foote.help.scm new file mode 100644 index 0000000..e7cd746 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-hainsworth-foote.help.scm @@ -0,0 +1,80 @@ +;; (pv-hainsworth-foote buffer proph propf threshold waittime) + +;; fft onset detector based on work described in + +;; Hainsworth, S. (2003) Techniques for the Automated Analysis of +;; Musical Audio. PhD, University of Cambridge engineering dept. See +;; especially p128. The Hainsworth metric is a modification of the +;; Kullback Liebler distance. + +;; The onset detector has general ability to spot spectral change, so +;; may have some ability to track chord changes aside from obvious +;; transient jolts, but there's no guarantee it won't be confused by +;; frequency modulation artifacts. + +;; Hainsworth metric on it's own gives good results but Foote might be +;; useful in some situations: experimental. + +;; buffer - fft buffer to read from + +;; proph - What strength of detection signal from Hainsworth metric to use. + +;; propf - What strength of detection signal from Foote metric to +;; use. The Foote metric is normalised to [0.0,1.0] + +;; threshold - Threshold hold level for allowing a detection + +;; waittime - If triggered, minimum wait until a further frame can +;; cause another spot (useful to stop multiple detects on +;; heavy signals) + +;; Default values in sclang are: proph=0.0, propf=0.0, threshold=1.0, +;; waittime=0.04. + +;; -- + +;; Just Hainsworth metric with low threshold + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 2048 1)))) + +(let* ((source (sound-in 0)) + (detect (pv-hainsworth-foote (fft* 0 source) + 1.0 + 0.0 + (mouse-x kr 0.01 1.0 1 0.1) + 0.04))) + (audition + (out 0 (mul3 (sin-osc ar (mce2 440 445) 0) + (decay (mul 0.1 detect) 0.1) + 0.1)))) + +;; Just Hainsworth metric, spot note transitions. + +(let* ((src (mul (lf-saw ar (mul-add (lf-noise0 kr 1) 90 400) 0) 0.5)) + (dtc (pv-hainsworth-foote (fft* 0 src) + 1.0 + 0.0 + 0.9 + 0.5)) + (cmp (mul (sin-osc ar 440 0) + (decay (mul 0.1 dtc) 0.1)))) + (audition + (out 0 (mul (mce2 src cmp) 0.1)))) + +;; Just Foote metric. Foote never triggers with threshold over 1.0, +;; threshold under mouse control. + +(let* ((src (sound-in 0)) + (dtc (pv-hainsworth-foote (fft* 0 src) + 0.0 + 1.0 + (mouse-x kr 0.0 1.1 0 0.1) + 0.02)) + (cmp (mul (sin-osc ar 440 0) + (decay (mul 0.1 dtc) 0.1)))) + (audition + (out 0 (mul (mce2 src cmp) 0.1)))) + + \ No newline at end of file diff --git a/rsc3/examples/ugen/fft/pv-jensen-anderson.help.scm b/rsc3/examples/ugen/fft/pv-jensen-anderson.help.scm new file mode 100644 index 0000000..7d7d78d --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-jensen-anderson.help.scm @@ -0,0 +1,40 @@ +;; (pv-jensen-andersen buffer propsc prophfe prophfc propsf threshold waittime) + +#| + +fft feature detector for onset detection based on work described in +Jensen,K. & Andersen, T. H. (2003). Real-time Beat Estimation Using +Feature Extraction. in Proceedings of the Computer Music Modeling and +Retrieval Symposium, Lecture Notes in Computer Science. springer +Verlag. + +First order derivatives of the features are taken. Threshold may +need to be set low to pick up on changes. + +buffer - fft buffer to read from. +propsc - Proportion of spectral centroid feature. +prophfe - Proportion of high frequency energy feature. +prophfc - Proportion of high frequency content feature. +propsf - Proportion of spectral flux feature. +threshold - Threshold level for allowing a detection +waittime - If triggered, minimum wait until a further frame can + cause another spot (useful to stop multiple detects on + heavy signals) + +Default values in sclang are: propsc=0.25, prophfe=0.25, +prophfc=0.25, propsf=0.25, threshold=1.0, waittime=0.04. + +|# + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 0 2048 1)))) + +(let* ((source (sound-in 0)) + (detect (pv-jensen-andersen (fft* 0 source) + 0.25 0.25 0.25 0.25 + (mouse-x kr 0.01 1.0 1 0.1) + 0.04))) + (audition + (out 0 (mul (sin-osc ar (mce2 440 445) 0) + (decay (mul 0.1 detect) 0.1))))) diff --git a/rsc3/examples/ugen/fft/pv-local-max.help.scm b/rsc3/examples/ugen/fft/pv-local-max.help.scm new file mode 100644 index 0000000..7f08cb0 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-local-max.help.scm @@ -0,0 +1,19 @@ +;; (pv-local-max buffer threshold) + +;; Pass bins which are a local maximum + +;; Passes only bins whose magnitude is above a threshold and above +;; their nearest neighbors. + +;; buffer - fft buffer. +;; threshold - magnitude threshold. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((a (play-buf 1 12 (buf-rate-scale kr 12) 0 0 1)) + (f (fft* 10 a)) + (h (pv-local-max f (mouse-x kr 0 100 0 0.1)))) + (audition (out 0 (mul (ifft* h) 0.5)))) diff --git a/rsc3/examples/ugen/fft/pv-mag-above.help.scm b/rsc3/examples/ugen/fft/pv-mag-above.help.scm new file mode 100644 index 0000000..9542020 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-mag-above.help.scm @@ -0,0 +1,31 @@ +;; (pv-mag-above buffer threshold) + +;; Pass only bands where the magnitude is above `threshold'. This +;; value is not normalized and is therefore dependant on the buffer +;; size. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc 11 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((a (play-buf 1 12 (buf-rate-scale kr 12) 0 0 1)) + (x (mouse-x kr 1 100 0 0.1)) + (y (mouse-y kr 0 1 0 0.1)) + (c1 (fft* 10 a)) + (c2 (pv-copy c1 11)) + (c3 (pv-mag-below c1 x)) + (c4 (pv-mag-above c2 x))) + (audition (out 0 (mul (mce2 (ifft* c3) (ifft* c4)) (mce2 y (sub 1 y)))))) + +(let* ((f1 (squared (mul-add (sin-osc kr 0.08 0) 6 6.2))) + (f2 (mul-add (sin-osc kr f1 0) 100 800)) + (s (sin-osc ar f2 0)) + (x (mouse-x kr 1 1024 0 0.1)) + (y (mouse-y kr 0 1 0 0.1)) + (c1 (fft* 10 s)) + (c2 (pv-copy c1 11)) + (c3 (pv-mag-below c1 x)) + (c4 (pv-mag-above c2 x))) + (audition (out 0 (mul (mce2 (ifft* c3) (ifft* c4)) (mce2 y (sub 1 y)))))) diff --git a/rsc3/examples/ugen/fft/pv-mag-below.help.scm b/rsc3/examples/ugen/fft/pv-mag-below.help.scm new file mode 100644 index 0000000..a162362 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-mag-below.help.scm @@ -0,0 +1,7 @@ +;; (pv-mag-below buffer threshold) + +;; Pass bins below a threshold. Pass only bands where the magnitude +;; is below `threshold'. This value is not normalized and is +;; therefore dependant on the buffer size. + +;; See pv-mag-above diff --git a/rsc3/examples/ugen/fft/pv-mag-clip.help.scm b/rsc3/examples/ugen/fft/pv-mag-clip.help.scm new file mode 100644 index 0000000..49eab6b --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-mag-clip.help.scm @@ -0,0 +1,17 @@ +;; (PV_Magclip buffer threshold) + +;; clip bins to a threshold. clips bin magnitudes to a maximum +;; threshold. + +;; buffer - fft buffer. +;; threshold - magnitude threshold. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((a (play-buf 1 12 (buf-rate-scale kr 12) 0 0 1)) + (f (fft* 10 a)) + (h (pv-mag-clip f (mouse-x kr 0 5 0 0.1)))) + (audition (out 0 (mul (ifft* h) 0.5)))) diff --git a/rsc3/examples/ugen/fft/pv-mag-freeze.help.scm b/rsc3/examples/ugen/fft/pv-mag-freeze.help.scm new file mode 100644 index 0000000..bfe0f18 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-mag-freeze.help.scm @@ -0,0 +1,22 @@ +;; (PV_Magfreeze buffer freeze) + +;; freeze magnitudes. freezes magnitudes at current levels when +;; freeze > 0. + +;; buffer - fft buffer. +;; freeze - if > 0 then magnitudes are frozen at current levels. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let ((dup (lambda (a) (mce2 a a))) + (s (sin-osc ar (mul-add (lf-noise1 kr 5.2) 250 400) 0)) + (f (sin-osc kr 0.2 0))) + (audition (out 0 (dup (mul 0.25 (ifft* (pv-mag-freeze (fft* 10 s) f))))))) + +(let ((dup (lambda (a) (mce2 a a))) + (s (play-buf 1 12 (buf-rate-scale kr 12) 1 0 1)) + (f (gt (mouse-y kr 0 1 0 0.1) 0.5))) + (audition (out 0 (dup (mul 0.25 (ifft* (pv-mag-freeze (fft* 10 s) f))))))) diff --git a/rsc3/examples/ugen/fft/pv-mag-mul.help.scm b/rsc3/examples/ugen/fft/pv-mag-mul.help.scm new file mode 100644 index 0000000..912083e --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-mag-mul.help.scm @@ -0,0 +1,2 @@ +;; (pv-mag-mul bufferA bufferB) + diff --git a/rsc3/examples/ugen/fft/pv-mag-noise.help.scm b/rsc3/examples/ugen/fft/pv-mag-noise.help.scm new file mode 100644 index 0000000..fc329bd --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-mag-noise.help.scm @@ -0,0 +1,15 @@ +;; (pv-mag-noise buffer) + +;; Magnitudes are multiplied with noise. + +;; buffer - fft buffer. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((a (play-buf 1 12 (buf-rate-scale kr 12) 0 0 1)) + (f (fft* 10 a)) + (h (pv-mag-noise f))) + (audition (out 0 (mul (ifft* h) 0.5)))) diff --git a/rsc3/examples/ugen/fft/pv-mag-shift.help.scm b/rsc3/examples/ugen/fft/pv-mag-shift.help.scm new file mode 100644 index 0000000..04a490c --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-mag-shift.help.scm @@ -0,0 +1,2 @@ +;; (pv-mag-shift buffer stretch shift) + diff --git a/rsc3/examples/ugen/fft/pv-mag-smear.help.scm b/rsc3/examples/ugen/fft/pv-mag-smear.help.scm new file mode 100644 index 0000000..f6f7a00 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-mag-smear.help.scm @@ -0,0 +1,24 @@ +;; (pv-mag-smear buffer bins) + +;; Average a bin's magnitude with its neighbors. + +;; buffer - fft buffer. + +;; bins - number of bins to average on each side of bin. +;; As this number rises, so will CPU usage. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc-read 12 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((dup (lambda (a) (mce2 a a))) + (in (mul (lf-saw ar 500 0) (decay2 (mul (impulse ar 2 0) 0.2) 0.01 2))) + (c0 (fft* 10 in)) + (c1 (pv-mag-smear c0 (mouse-x kr 0 100 0 0.1)))) + (audition (out 0 (mul 0.5 (dup (ifft* c1)))))) + +(let* ((dup (lambda (a) (mce2 a a))) + (s (play-buf 1 12 (buf-rate-scale kr 12) 1 0 1)) + (x (mouse-x kr 0 100 0 0.1))) + (audition (out 0 (mul 0.5 (dup (ifft* (pv-mag-smear (fft* 10 s) x))))))) diff --git a/rsc3/examples/ugen/fft/pv-mag-squared.help.scm b/rsc3/examples/ugen/fft/pv-mag-squared.help.scm new file mode 100644 index 0000000..2af6acc --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-mag-squared.help.scm @@ -0,0 +1 @@ +;; (pv-mag-squared buffer) diff --git a/rsc3/examples/ugen/fft/pv-max.help.scm b/rsc3/examples/ugen/fft/pv-max.help.scm new file mode 100644 index 0000000..477d74c --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-max.help.scm @@ -0,0 +1 @@ +;; (pv-max bufferA bufferB) diff --git a/rsc3/examples/ugen/fft/pv-min.help.scm b/rsc3/examples/ugen/fft/pv-min.help.scm new file mode 100644 index 0000000..1755b54 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-min.help.scm @@ -0,0 +1 @@ +;; (pv-min bufferA bufferB) diff --git a/rsc3/examples/ugen/fft/pv-mul.help.scm b/rsc3/examples/ugen/fft/pv-mul.help.scm new file mode 100644 index 0000000..77bd867 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-mul.help.scm @@ -0,0 +1 @@ +;; (pv-mul bufferA bufferB) diff --git a/rsc3/examples/ugen/fft/pv-phase-shift.help.scm b/rsc3/examples/ugen/fft/pv-phase-shift.help.scm new file mode 100644 index 0000000..8fbce6f --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-phase-shift.help.scm @@ -0,0 +1,11 @@ +;; (pv-phase-shift buffer shift) + +;; add `shift' to the phase component of every bin at `buffer'. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)))) + +(let ((n (mul (white-noise ar) 0.1)) + (x (mouse-x kr 0 1 0 0.1))) + (audition (out 0 (ifft* (pv-phase-shift (fft* 10 n) x))))) diff --git a/rsc3/examples/ugen/fft/pv-phase-shift270.help.scm b/rsc3/examples/ugen/fft/pv-phase-shift270.help.scm new file mode 100644 index 0000000..70f39e2 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-phase-shift270.help.scm @@ -0,0 +1,11 @@ +;; (pv-phase-shift270 buffer) + +;; Swap the real and imaginary components of every bin at `buffer' and +;; swap the sign of the real components. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)))) + +(let ((n (mul (white-noise ar) 0.1))) + (audition (out 0 (ifft* (pv-phase-shift270 (fft* 10 n)))))) diff --git a/rsc3/examples/ugen/fft/pv-phase-shift90.help.scm b/rsc3/examples/ugen/fft/pv-phase-shift90.help.scm new file mode 100644 index 0000000..82e41d9 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-phase-shift90.help.scm @@ -0,0 +1,11 @@ +;; (pv-phase-shift90 buffer) + +;; Swap the real and imaginary components of every bin at `buffer' and +;; swap the of the imaginary components. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)))) + +(let ((n (mul (white-noise ar) 0.1))) + (audition (out 0 (ifft* (pv-phase-shift90 (fft* 10 n)))))) diff --git a/rsc3/examples/ugen/fft/pv-rand-comb.help.scm b/rsc3/examples/ugen/fft/pv-rand-comb.help.scm new file mode 100644 index 0000000..2b54220 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-rand-comb.help.scm @@ -0,0 +1,16 @@ +;; (pv-rand-comb buffer wipe trig) + +;; randomly clear bins. + +;; buffer = fft buffer. wipe = clear bins from input in a random +;; order (0, 1). trig = select new random ordering. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)))) + +(let ((dup (lambda (a) (mce2 a a))) + (n (mul (white-noise ar) 0.5)) + (x (mouse-x kr 0.6 0.95 0 0.1)) + (t (impulse kr 0.4 0))) + (audition (out 0 (dup (ifft* (pv-rand-comb (fft* 10 n) x t)))))) diff --git a/rsc3/examples/ugen/fft/pv-rand-wipe.help.scm b/rsc3/examples/ugen/fft/pv-rand-wipe.help.scm new file mode 100644 index 0000000..98c63b9 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-rand-wipe.help.scm @@ -0,0 +1,28 @@ +;; (pv-rand-wipe bufferA bufferB wipe trig) + +;; Cross fades between two sounds by copying bins in a random order. + +;; bufferA = fft buffer A. bufferB = fft buffer B. wipe = copies +;; bins from bufferB in a random order (0, 1). trig = select new +;; random ordering. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)) + (async fd (b-alloc 11 2048 1)))) + +(define-syntax n-of + (syntax-rules () + ((_ n f) (mix-fill n (lambda (_) f))))) + +(let* ((n 6) + (a (n-of n (mul (lf-saw ar (exp-rand 400.0 1000.0) 0.0) 0.1))) + (b (n-of n (mul (lf-pulse ar (exp-rand 80.0 400.0) 0.0 0.2) + (u:max (mul (sin-osc kr (rand 0.0 8.0) 0.0) 0.2) 0.0)))) + (f (fft* 10 a)) + (g (fft* 11 b)) + (y (mouse-y kr 0 1 0 0.1)) + (x (mouse-x kr 0 1 0 0.1)) + (h (pv-rand-wipe f g x (gt y 0.5))) + (i (ifft* h))) + (audition (out 0 (mul 0.5 (mce2 i i))))) diff --git a/rsc3/examples/ugen/fft/pv-rect-comb.help.scm b/rsc3/examples/ugen/fft/pv-rect-comb.help.scm new file mode 100644 index 0000000..e83a185 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-rect-comb.help.scm @@ -0,0 +1,19 @@ +;; (pv-rect-comb buffer numTeeth phase width) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 2048 1)))) + +(let* ((dup (lambda (a) (mce2 a a))) + (x (mouse-x kr 0 0.5 0 0.1)) + (y (mouse-y kr 0 0.5 0 0.1)) + (n (dup (mul (white-noise ar) 0.3))) + (c (pv-rect-comb (fft* 10 n) 8 x y))) + (audition (out 0 (ifft* c)))) + +(let* ((dup (lambda (a) (mce2 a a))) + (p (mul-add (lf-tri kr 0.097 0) 0.4 0.5)) + (w (mul-add (lf-tri kr 0.24 0) -0.5 0.5)) + (n (dup (mul (white-noise ar) 0.3))) + (c (pv-rect-comb (fft* 10 n) 8 p w))) + (audition (out 0 (ifft* c)))) diff --git a/rsc3/examples/ugen/fft/pv-rect-comb2.help.scm b/rsc3/examples/ugen/fft/pv-rect-comb2.help.scm new file mode 100644 index 0000000..84ece86 --- /dev/null +++ b/rsc3/examples/ugen/fft/pv-rect-comb2.help.scm @@ -0,0 +1 @@ +;; (pv-rect-comb2 bufferA bufferB numTeeth phase width) diff --git a/rsc3/examples/ugen/fft/pvcollect.help.scm b/rsc3/examples/ugen/fft/pvcollect.help.scm new file mode 100644 index 0000000..a9f3d49 --- /dev/null +++ b/rsc3/examples/ugen/fft/pvcollect.help.scm @@ -0,0 +1,61 @@ +;; (pvcollect chain numframes func frombin tobin zeroothers) + +;; Process each bin of an fft chain separately. + +;; pvcollect applies function func to each bin of an fft chain. func +;; should be a function that takes magnitude, phase, index as inputs +;; and returns a resulting [magnitude, phase]. + +;; The "index" is the integer bin number, starting at 0 for DC. You +;; can optionally ignore the phase and only return a single +;; (magnitude) value, in which case the phase is assumed to be left +;; unchanged. + +;; frombin, tobin, and zeroothers are optional arguments which limit +;; the processing to a specified integer range of fft bins. If +;; zeroothers is set to 1 then bins outside of the range being +;; processed are silenced. + +;; Note that this procedure can be relatively CPU-heavy, depending on +;; how you use it. + +(define no-op + (lambda (m p _) + (list m p))) + +(define rand-phase + (lambda (m p _) + (list m (rand 0 3.14)))) + +(define noise-phase + (lambda (m p _) + (list m (lin-lin (lf-noise0 kr 3) -1 1 0 3.14)))) + +(define combf + (lambda (m p i) + (list (if (= (modulo i 7) 0) m 0) p))) + +(define noise-mag + (lambda (m p _) + (list (mul (gt (lf-noise0 kr 10) 0) m) p))) + +(define spectral-delay + (lambda (m p _) + (let ((v (lin-lin (lf-par kr 0.5 0) -1 1 0.1 1))) + (list (add m (delay-n m 1 v)) p)))) + +(define (bpf-sweep nf) + (lambda (m p i) + (let ((e (u:abs (sub i (lin-lin (lf-par kr 0.1 0) -1 1 2 (/ nf 20)))))) + (list (mul (lt e 10) m) p)))) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 1024 1)) + (async fd (b-alloc-read 11 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((nf 1024) + (i (play-buf 1 11 (buf-rate-scale kr 11) 1 0 1)) + (c1 (fft* 10 i)) + (c2 (pvcollect c1 nf spectral-delay 0 250 0))) + (audition (out 0 (mul 0.1 (ifft* c2))))) diff --git a/rsc3/examples/ugen/filters/amp-comp-a.help.scm b/rsc3/examples/ugen/filters/amp-comp-a.help.scm new file mode 100644 index 0000000..b842645 --- /dev/null +++ b/rsc3/examples/ugen/filters/amp-comp-a.help.scm @@ -0,0 +1,51 @@ +;; (amp-compA freq root minAmp rootAmp) + +;; ANSI A-weighting curve. + +;; Basic psychoacoustic amplitude compensation + +;; Higher frequencies are normally perceived as louder, which amp-compA +;; compensates. Following the measurings by Fletcher and Munson, the +;; ANSI standard describes a function for loudness vs. frequency. +;; Note that this curve is only valid for standardized amplitude. +;; For a simpler but more flexible curve, see amp-comp. + +;; freq - input frequency value. For freq == root, the output is +;; rootAmp. (default freq 0 Hz) + +;; root - root freq relative to which the curve is calculated (usually +;; lowest freq) (default 0 Hz) default value: C (60.midicps) + +;; minAmp - amplitude at the minimum point of the curve (around 2512 +;; Hz) (default -10dB) + +;; rootAmp - amplitude at the root frequency. (default 1) apart from +;; freq, the values are not modulatable + +;; compare a sine without compensation with one that uses amplitude +;; compensation + +(let* ((x (mouse-x kr 300 15000 1 0.1)) + (y (mouse-y kr 0 1 0 0.1)) + (o (mul (sin-osc ar x 0) 0.1)) + (c (amp-comp-a x 300 (db-amp -10) 1))) + (audition (out 0 (mce2 (mul o y) (mul3 o (sub 1 y) c))))) + +;; adjust the minimum and root amp (in this way one can flatten out +;; the curve for higher amplitudes) + +(let* ((x (mouse-x kr 300 18000 1 0.1)) + (y (mouse-y kr 0 1 0 0.1)) + (o (mul (formant ar 300 x 20) 0.1)) + (c (amp-comp-a x 300 0.6 0.3))) + (audition (out 0 (mce2 (mul o y) (mul3 o (sub 1 y) c))))) + +;; amplitude compensation in frequency modulation (using +;; Fletscher-Munson curve) + +(let* ((x (mouse-x kr 300 15000 1 0.1)) + (y (mouse-y kr 3 200 1 0.1)) + (m (mul x (mul-add (sin-osc ar y 0) 0.5 1))) + (a (amp-comp-a m 300 (db-amp -10) 1)) + (c (mul3 (sin-osc ar m 0) 0.1 a))) + (audition (out 0 c))) diff --git a/rsc3/examples/ugen/filters/amp-comp.help.scm b/rsc3/examples/ugen/filters/amp-comp.help.scm new file mode 100644 index 0000000..ff1b61f --- /dev/null +++ b/rsc3/examples/ugen/filters/amp-comp.help.scm @@ -0,0 +1,47 @@ +;; (amp-comp freq root exp) + +;; Basic psychoacoustic amplitude compensation. + +;; Implements the (optimized) formula: compensationFactor = (root / +;; freq) ** exp. Higher frequencies are normally perceived as louder, +;; which amp-comp compensates. + +;; See also amp-compA + +;; freq - input frequency value. For freq == root, the output is 1.0. + +;; root - root freq relative to which the curve is calculated (usually +;; lowest freq) default value: C (60.midicps) + +;; exp - exponent. how steep the curve decreases for increasing freq +;; (see plots below). default value 0.3333 + +;; Note that for frequencies very much smaller than root the +;; amplitudes can become very high. in this case limit the freq with +;; freq.max(minval), or use amp-compA. + +;; compare a sine without compensation with one that uses amplitude +;; compensation + +(let* ((x (mouse-x kr 300 15000 1 0.1)) + (y (mouse-y kr 0 1 0 0.1)) + (o (mul (sin-osc ar x 0) 0.1)) + (c (amp-comp x 300 0.333))) + (audition (out 0 (mce2 (mul o y) (mul3 o (sub 1 y) c))))) + +;; different sounds cause quite different loudness perception, and the +;; desired musical behavior can vary, so the exponent can be tuned: + +(let* ((x (mouse-x kr 300 15000 1 0.1)) + (o (mul (pulse ar x 0.5) 0.1)) + (c (amp-comp x 300 1.3))) + (audition (out 0 (mul o c)))) + +;; amplitude compensation in frequency modulation + +(let* ((x (mouse-x kr 300 15000 1 0.1)) + (y (mouse-y kr 3 200 1 0.1)) + (m (mul x (mul-add (sin-osc ar y 0) 0.5 1))) + (a (amp-comp m 300 0.333)) + (c (mul3 (sin-osc ar m 0) 0.1 a))) + (audition (out 0 c))) diff --git a/rsc3/examples/ugen/filters/bpf.help.scm b/rsc3/examples/ugen/filters/bpf.help.scm new file mode 100644 index 0000000..5a25079 --- /dev/null +++ b/rsc3/examples/ugen/filters/bpf.help.scm @@ -0,0 +1,16 @@ +;; (bpf in freq rq) + +;; Second order Butterworth bandpass filter + +;; in - input signal to be processed +;; freq - cutoff frequency in Hertz. +;; rq - the reciprocal of Q. bandwidth / cutoffFreq. + +(let* ((f1 (x-line kr 0.7 300 20 remove-synth)) + (f2 (mul-add (f-sin-osc kr f1 0) 3600 4000))) + (audition (out 0 (bpf (mul (saw ar 200) 0.25) f2 0.3)))) + +(let* ((f1 (mouse-x kr 220 440 0 0.1)) + (f2 (mce2 f1 (sub 550 f1))) + (rq (mouse-y kr 0 0.01 0 0.1))) + (audition (out 0 (bpf (white-noise ar) f2 rq)))) diff --git a/rsc3/examples/ugen/filters/bpz2.help.scm b/rsc3/examples/ugen/filters/bpz2.help.scm new file mode 100644 index 0000000..4adf7b2 --- /dev/null +++ b/rsc3/examples/ugen/filters/bpz2.help.scm @@ -0,0 +1,7 @@ +;; (bpz2 in) + +;; Two zero fixed midpass. This filter cuts out 0 Hz and the Nyquist +;; frequency. + +(audition (out 0 (bpz2 (mul (white-noise ar) 0.25)))) + diff --git a/rsc3/examples/ugen/filters/brf.help.scm b/rsc3/examples/ugen/filters/brf.help.scm new file mode 100644 index 0000000..6b4695f --- /dev/null +++ b/rsc3/examples/ugen/filters/brf.help.scm @@ -0,0 +1,7 @@ +;; (brf in freq rq) + +;; Second order Butterworth band reject filter. + +(let* ((f1 (x-line kr 0.7 300 20 remove-synth)) + (f2 (mul-add (f-sin-osc kr f1 0) 3600 4000))) + (audition (out 0 (brf (mul (saw ar 200) 0.1) f2 0.3)))) diff --git a/rsc3/examples/ugen/filters/brz2.help.scm b/rsc3/examples/ugen/filters/brz2.help.scm new file mode 100644 index 0000000..5007078 --- /dev/null +++ b/rsc3/examples/ugen/filters/brz2.help.scm @@ -0,0 +1,15 @@ +;; (brz2 in) + +;; A two zero fixed midcut filter. A special case fixed +;; filter. Implements the formula: + +;; out(i) = 0.5 * (in(i) + in(i-2)) + +;; This filter cuts out frequencies around 1/2 of the Nyquist +;; frequency. + +;; Compare: + +(audition (out 0 (mul (white-noise ar) 0.15))) + +(audition (out 0 (brz2 (mul (white-noise ar) 0.15)))) diff --git a/rsc3/examples/ugen/filters/clip.help.scm b/rsc3/examples/ugen/filters/clip.help.scm new file mode 100644 index 0000000..ca4e268 --- /dev/null +++ b/rsc3/examples/ugen/filters/clip.help.scm @@ -0,0 +1,5 @@ +;; (clip in lo hi) + +;; clip `in' to lie between `lo' and `hi', which are i-rate inputs. + +(audition (out 0 (clip (mul (sin-osc ar 440 0) 0.4) -0.25 0.25))) diff --git a/rsc3/examples/ugen/filters/dyn-klank.help.scm b/rsc3/examples/ugen/filters/dyn-klank.help.scm new file mode 100644 index 0000000..fe2fd49 --- /dev/null +++ b/rsc3/examples/ugen/filters/dyn-klank.help.scm @@ -0,0 +1,47 @@ +;; (dyn-klank in freqScale freqOffset decayScale spec) + +;; Dynklank is a bank of frequency resonators which can be used to +;; simulate the resonant modes of an object. Each mode is given a ring +;; time, which is the time for the mode to decay by 60 dB. + +;; Unlike klank, the parameters in specificationsArrayRef can be +;; changed after it has been started. + +(let ((i (mul (impulse ar 2 0) 0.1)) + (d (klank-data '(800 1071 1153 1723) + (replicate 4 1) + (replicate 4 1)))) + (audition (out 0 (dyn-klank i 1 0 1 d)))) + +(let ((i (mul (dust ar 8) 0.1)) + (d (klank-data '(800 1071 1353 1723) + (replicate 4 1) + (replicate 4 1)))) + (audition (out 0 (dyn-klank i 1 0 1 d)))) + +(let* ((i (mul (impulse ar 3 0) 0.1)) + (f (list 800 1071 1153 1723)) + (r (list 1 1 1 1)) + (x (mouse-x kr 0.5 2 1 0.1)) + (y (mouse-y kr 0.1 10 1 0.1)) + (d (klank-data (map (lambda (e) (mul e x)) f) + (replicate 4 1) + (map (lambda (e) (mul e y)) r)))) + (audition (out 0 (dyn-klank i 1 0 1 d)))) + +(let* ((i (lambda (f) + (mul (impulse ar (lin-lin (lf-noise0 kr f) -1 1 3 12) 0) 0.1))) + (t (lambda (i d l r) + (map (lambda (e) (mul e (t-rand l r i))) d))) + (d (lambda (i f r) + (klank-data (t i f 0.5 2) + (replicate 4 1) + (t i r 0.1 10)))) + (f1 (list 800 1071 1153 1723)) + (f2 (list 786 1083 1169 1715)) + (r1 (list 1 0.95 0.75 1.25)) + (r2 (list 1 1.35 0.95 1.15)) + (i1 (i 1.5)) + (i2 (i 1.25))) + (audition (out 0 (mce2 (dyn-klank i1 1 0 1 (d i1 f1 r1)) + (dyn-klank i2 1 0 1 (d i2 f2 r2)))))) diff --git a/rsc3/examples/ugen/filters/fold.help.scm b/rsc3/examples/ugen/filters/fold.help.scm new file mode 100644 index 0000000..31b784e --- /dev/null +++ b/rsc3/examples/ugen/filters/fold.help.scm @@ -0,0 +1,22 @@ +;; (fold in lo hi) + +;; fold a signal outside given thresholds. + +;; This differs from the BinaryOpUGen fold2 in that it allows one to +;; set both low and high thresholds. + +;; in - signal to be foldped +;; lo - low threshold of foldping +;; hi - high threshold of foldping + +(let ((o (mul (sin-osc ar 440 0) 0.2)) + (l (rand -0.175 -0.025)) + (r (rand 0.025 0.175))) + (audition (out 0 (fold o l r)))) + +;; lo and hi are i-rate only. + +(let ((o (mul (sin-osc ar 440 0) 0.2)) + (x (mouse-x kr -0.175 -0.025 1 0.1)) + (y (mouse-y kr 0.025 0.175 1 0.1))) + (audition (out 0 (fold o x y)))) diff --git a/rsc3/examples/ugen/filters/formlet.help.scm b/rsc3/examples/ugen/filters/formlet.help.scm new file mode 100644 index 0000000..ef12fda --- /dev/null +++ b/rsc3/examples/ugen/filters/formlet.help.scm @@ -0,0 +1,16 @@ +;; (formlet in freq attackTime decayTime) + +;; FOF-like filter + +(let ((i (impulse ar 20 0.5))) + (audition (out 0 (formlet i 1000 0.01 0.1)))) + +(let* ((f (x-line kr 10 400 8 remove-synth)) + (i (mul (blip ar f 1000) 0.1))) + (audition (out 0 (formlet i 1000 0.01 0.1)))) + +;; Modulating formant frequency. + +(let ((i (mul (blip ar (mul-add (sin-osc kr 5 0) 20 300) 1000) 0.1)) + (f (x-line kr 1500 700 8 remove-synth))) + (audition (out 0 (formlet i f 0.005 0.04)))) diff --git a/rsc3/examples/ugen/filters/fos.help.scm b/rsc3/examples/ugen/filters/fos.help.scm new file mode 100644 index 0000000..aa8ef1b --- /dev/null +++ b/rsc3/examples/ugen/filters/fos.help.scm @@ -0,0 +1,15 @@ +;; (fos in a0 a1 b1) + +;; First order filter section. + +;; Same as one-pole. + +(let ((x (mul (lf-tri ar 0.4 0) 0.99)) + (i (mul (lf-saw ar 200 0) 0.2))) + (audition (out 0 (fos i (sub 1 (u:abs x)) 0 x)))) + +;; Same as one-zero + +(let ((x (mul (lf-tri ar 0.4 0) 0.99)) + (i (mul (lf-saw ar 200 0) 0.2))) + (audition (out 0 (fos i (sub 1 (u:abs x)) x 0)))) diff --git a/rsc3/examples/ugen/filters/freq-shift.help.scm b/rsc3/examples/ugen/filters/freq-shift.help.scm new file mode 100644 index 0000000..343f37b --- /dev/null +++ b/rsc3/examples/ugen/filters/freq-shift.help.scm @@ -0,0 +1,38 @@ +;; (freq-shift input shift phase) + +;; freq-shift implements single sideband amplitude modulation, also +;; known as frequency shifting, but not to be confused with pitch +;; shifting. Frequency shifting moves all the components of a signal +;; by a fixed amount but does not preserve the original harmonic +;; relationships. + +;; input - audio input +;; shift - amount of shift in cycles per second +;; phase - phase of the frequency shift (0 - 2pi) + +;; shifting a 100Hz tone by 1 Hz rising to 500Hz + +(let ((i (sin-osc ar 100 0)) + (s (x-line kr 1 500 5 remove-synth))) + (audition (out 0 (mul (freq-shift i s 0) 0.1)))) + +;; shifting a complex tone by 1 Hz rising to 500Hz + +(let ((i (klang ar 1 0 (klang-data (list 101 303 606 808) + (replicate 4 1) + (replicate 4 1)))) + (s (x-line kr 1 500 5 remove-synth))) + (audition (out 0 (mul (freq-shift i s 0) 0.1)))) + +;; modulating shift and phase + +(let ((i (sin-osc ar 10 0)) + (s (mul (lf-noise2 ar 0.3) 1500)) + (p (lin-lin (sin-osc ar 500 0) -1 1 0 (* 2 pi)))) + (audition (out 0 (mul (freq-shift i s p) 0.1)))) + +;; shifting bandpassed noise + +(let ((i (bpf (white-noise ar) 1000 0.001)) + (s (mul (lf-noise0 ar 5.5) 1000))) + (audition (out 0 (mul (freq-shift i s 0) 32)))) diff --git a/rsc3/examples/ugen/filters/hpf.help.scm b/rsc3/examples/ugen/filters/hpf.help.scm new file mode 100644 index 0000000..ac1b47c --- /dev/null +++ b/rsc3/examples/ugen/filters/hpf.help.scm @@ -0,0 +1,8 @@ +;; (hpf in freq) + +;; Second order Butterworth highpass filter. + +(let* ((i (mul (saw ar 200) 0.1)) + (f1 (x-line kr 0.7 300 20 do-nothing)) + (f2 (mul-add (f-sin-osc kr f1 0) 3600 4000))) + (audition (out 0 (mul (hpf i f2) 5)))) diff --git a/rsc3/examples/ugen/filters/hpz1.help.scm b/rsc3/examples/ugen/filters/hpz1.help.scm new file mode 100644 index 0000000..c3a4702 --- /dev/null +++ b/rsc3/examples/ugen/filters/hpz1.help.scm @@ -0,0 +1,5 @@ +;; (hpz1 in) + +;; Two point difference filter. + +(audition (out 0 (hpz1 (mul (white-noise ar) 0.25)))) diff --git a/rsc3/examples/ugen/filters/hpz2.help.scm b/rsc3/examples/ugen/filters/hpz2.help.scm new file mode 100644 index 0000000..87c176e --- /dev/null +++ b/rsc3/examples/ugen/filters/hpz2.help.scm @@ -0,0 +1,5 @@ +;; (hpz2 in) + +;; Two zero fixed highpass filter. + +(audition (out 0 (hpz2 (mul (white-noise ar) 0.25)))) diff --git a/rsc3/examples/ugen/filters/klank.help.scm b/rsc3/examples/ugen/filters/klank.help.scm new file mode 100644 index 0000000..683e777 --- /dev/null +++ b/rsc3/examples/ugen/filters/klank.help.scm @@ -0,0 +1,50 @@ +;; (klank in freqScale freqOffset decayScale spec) + +;; klank is a bank of fixed frequency resonators which can be used to +;; simulate the resonant modes of an object. Each mode is given a ring +;; time, which is the time for the mode to decay by 60 dB. + +;; The UGen assistant klank-data can help create the 'spec' entry. +;; Note that the SC3 language reorders the inputs, the RSC client does +;; not. + +;; input - the excitation input to the resonant filter bank. + +;; freqscale - a scale factor multiplied by all frequencies at +;; initialization time. + +;; freqoffset - an offset added to all frequencies at initialization +;; time. + +;; decayscale - a scale factor multiplied by all ring times at +;; initialization time. + +(let ((i (mul (impulse ar 2 0) 0.1)) + (d (klank-data '(800 1071 1153 1723) + (replicate 5 1) + (replicate 5 1)))) + (audition (out 0 (klank i 1 0 1 d)))) + +(let ((i (mul (dust ar 8) 0.1)) + (d (klank-data '(800 1071 1353 1723) + (replicate 4 1) + (replicate 4 1)))) + (audition (out 0 (klank i 1 0 1 d)))) + +(let ((i (mul (pink-noise ar) 0.007)) + (d (klank-data '(800 1071 1353 1723) + (replicate 4 1) + (replicate 4 1)))) + (audition (out 0 (klank i 1 0 1 d)))) + +(let ((i (mul (pink-noise ar) (mce2 0.007 0.007))) + (d (klank-data '(200 671 1153 1723) + (replicate 4 1) + (replicate 4 1)))) + (audition (out 0 (klank i 1 0 1 d)))) + +(let ((i (mul (decay (impulse ar 4 0) 0.03) (mul (clip-noise ar) 0.01))) + (d (klank-data (replicate-m 12 (rand 800 4000)) + (replicate 12 1) + (replicate-m 12 (rand 0.1 2))))) + (audition (out 0 (klank i 1 0 1 d)))) diff --git a/rsc3/examples/ugen/filters/lag.help.scm b/rsc3/examples/ugen/filters/lag.help.scm new file mode 100644 index 0000000..07120be --- /dev/null +++ b/rsc3/examples/ugen/filters/lag.help.scm @@ -0,0 +1,7 @@ +;; (lag in lagTime) + +;; A simple averaging filter. + +(let* ((x (mouse-x kr 220 440 0 0.1)) + (f (mce2 x (lag x 1)))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/filters/lag2.help.scm b/rsc3/examples/ugen/filters/lag2.help.scm new file mode 100644 index 0000000..58e185e --- /dev/null +++ b/rsc3/examples/ugen/filters/lag2.help.scm @@ -0,0 +1,7 @@ +;; (lag2 in lagTime) + +;; lag2 is the same as (lag kr (Lag kr in time) time). + +(let* ((x (mouse-x kr 220 440 0 0.1)) + (f (mce2 x (lag2 x 1)))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/filters/lag3.help.scm b/rsc3/examples/ugen/filters/lag3.help.scm new file mode 100644 index 0000000..14e5115 --- /dev/null +++ b/rsc3/examples/ugen/filters/lag3.help.scm @@ -0,0 +1,7 @@ +;; (lag3 in lagTime) + +;; lag3 is the same as (lag (Lag (Lag in time) time) time). + +(let* ((x (mouse-x kr 220 440 0 0.1)) + (f (mce2 x (lag3 x 1)))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/filters/leak-dc.help.scm b/rsc3/examples/ugen/filters/leak-dc.help.scm new file mode 100644 index 0000000..53bc8fe --- /dev/null +++ b/rsc3/examples/ugen/filters/leak-dc.help.scm @@ -0,0 +1,9 @@ +;; (leak-dc in coef) + +;; Remove DC. This filter removes a DC offset from a signal. + +;; in - input signal +;; coef - leak coefficient + +(let ((a (mul (lf-pulse ar 800 0.5 0.5) 0.1))) + (audition (out 0 (mce2 a (leak-dc a 0.995))))) diff --git a/rsc3/examples/ugen/filters/limiter.help.scm b/rsc3/examples/ugen/filters/limiter.help.scm new file mode 100644 index 0000000..cfdfc3a --- /dev/null +++ b/rsc3/examples/ugen/filters/limiter.help.scm @@ -0,0 +1,11 @@ +;; (limiter input level lookAheadTime) + +;; peak limiter. Limits the input amplitude to the given +;; level. limiter will not overshoot like compander will, but it needs +;; to look ahead in the audio. Thus there is a delay equal to twice +;; the lookAheadTime. limiter, unlike compander, is completely +;; transparent for an in range signal. + +(let* ((t (impulse ar 8 (mul (lf-saw kr 0.25 -0.6) 0.7))) + (i (mul (decay2 t 0.001 0.3) (f-sin-osc ar 500 0)))) + (audition (out 0 (mce2 (mul i 0.1) (limiter i 0.2 0.01))))) diff --git a/rsc3/examples/ugen/filters/lin-exp.help.scm b/rsc3/examples/ugen/filters/lin-exp.help.scm new file mode 100644 index 0000000..b0ffdc5 --- /dev/null +++ b/rsc3/examples/ugen/filters/lin-exp.help.scm @@ -0,0 +1,13 @@ +;; (lin-exp in srclo srchi dstlo dsthi) + +;; Map a linear range to an exponential range. + +;; in - input to convert - kr, ar +;; srclo - lower limit of input range - ir +;; srchi - upper limit of input range - ir +;; dstlo - lower limit of output range - ir +;; dsthi - upper limit of output range - ir + +(audition + (out 0 (mul (sin-osc ar (lin-exp (mouse-x kr 0 1 0 0.1) 0 1 440 660) 0) + (lin-exp (mouse-y kr 0 1 0 0.1) 0 1 0.01 0.25)))) diff --git a/rsc3/examples/ugen/filters/lin-lin.help.scm b/rsc3/examples/ugen/filters/lin-lin.help.scm new file mode 100644 index 0000000..a8a67e1 --- /dev/null +++ b/rsc3/examples/ugen/filters/lin-lin.help.scm @@ -0,0 +1,13 @@ +;; (lin-lin in srclo srchi dstlo dsthi) + +;; Map a linear range to another linear range. + +;; in - input to convert - kr, ar +;; srclo - lower limit of input range - ir +;; srchi - upper limit of input range - ir +;; dstlo - lower limit of output range - ir +;; dsthi - upper limit of output range - ir + +(audition + (out 0 (mul (sin-osc ar (lin-lin (mouse-x kr 0 1 0 0.1) 0 1 440 660) 0) + (lin-lin (mouse-y kr 0 1 0 0.1) 0 1 0.01 0.25)))) diff --git a/rsc3/examples/ugen/filters/lpf.help.scm b/rsc3/examples/ugen/filters/lpf.help.scm new file mode 100644 index 0000000..24b3235 --- /dev/null +++ b/rsc3/examples/ugen/filters/lpf.help.scm @@ -0,0 +1,8 @@ +;; (lpf in freq) + +;; Second order Butterworth lowpass filter. + +(audition + (let ((f (x-line kr 0.7 300 20 remove-synth))) + (out 0 (lpf (mul (saw ar 200) 0.1) + (mul-add (f-sin-osc kr f 0) 3600 4000))))) diff --git a/rsc3/examples/ugen/filters/lpz1.help.scm b/rsc3/examples/ugen/filters/lpz1.help.scm new file mode 100644 index 0000000..e49d06b --- /dev/null +++ b/rsc3/examples/ugen/filters/lpz1.help.scm @@ -0,0 +1,6 @@ +;; (lpz1 ar in) + +;; Two point average filter + +(audition + (out 0 (lpz1 (mul (white-noise ar) 0.25)))) diff --git a/rsc3/examples/ugen/filters/lpz2.help.scm b/rsc3/examples/ugen/filters/lpz2.help.scm new file mode 100644 index 0000000..1e8522f --- /dev/null +++ b/rsc3/examples/ugen/filters/lpz2.help.scm @@ -0,0 +1,6 @@ +;; (lpz2 ar in) + +;; Two zero fixed lowpass filter + +(audition + (out 0 (lpz2 (mul (white-noise ar) 0.25)))) diff --git a/rsc3/examples/ugen/filters/median.help.scm b/rsc3/examples/ugen/filters/median.help.scm new file mode 100644 index 0000000..8ba2335 --- /dev/null +++ b/rsc3/examples/ugen/filters/median.help.scm @@ -0,0 +1,27 @@ +;; (median length in) + +;; median filter. + +;; Signal with impulse noise. + +(audition + (out 0 (median 3 (add (mul (saw ar 500) 0.1) (mul (dust2 ar 100) 0.9))))) + +;; The median length can be increased for longer duration noise. + +(audition + (out 0 (median 5 (add (mul (saw ar 500) 0.1) (lpz1 (mul (dust2 ar 100) 0.9)))))) + +;; Long median filters begin chopping off the peaks of the waveform + +(audition + (out 0 (let ((x (mul (sin-osc ar 1000 0) 0.2))) + (mce2 x (median 31 x))))) + +;; Another noise reduction application. Use median filter for high +;; frequency noise. Use leak-dc for low frequency noise. + +(audition + (out 0 (let* ((s0 (mul-add (white-noise ar) 0.1 (mul (sin-osc ar 800 0) 0.1))) + (s1 (median 31 s0))) + (leak-dc s1 0.9)))) diff --git a/rsc3/examples/ugen/filters/moog-ff.help.scm b/rsc3/examples/ugen/filters/moog-ff.help.scm new file mode 100644 index 0000000..5218a94 --- /dev/null +++ b/rsc3/examples/ugen/filters/moog-ff.help.scm @@ -0,0 +1,26 @@ +;; (moog-ff in freq gain reset) + +;; Moog VCF implementation, designed by Federico Fontana. A digital +;; implementation of the Moog VCF (filter). + +;; in - the input signal +;; freq - the cutoff frequency +;; gain - the filter resonance gain, between zero and 4 +;; reset - when greater than zero, this will reset the +;; state of the digital filters at the beginning +;; of a computational block. + +;; The design of this filter is described in the conference paper +;; Fontana, F. (2007) Preserving the Digital Structure of the Moog +;; VCF. in Proc. ICMC07, Copenhagen, 25-31 August 2007 + +(let ((n (mul (white-noise ar) 0.1)) + (y (mouse-y kr 100 10000 1 0.1)) + (x (mouse-x kr 0 4 0 0.1))) + (audition (out 0 (moog-ff n y x 0)))) + +(let* ((p (pulse ar (mce2 40 121) (mce2 0.3 0.7))) + (f0 (lin-lin (lf-noise0 kr 0.43) -1 1 0.001 2.2)) + (f1 (lin-lin (sin-osc kr f0 0) -1 1 30 4200)) + (y (mouse-y kr 1 4 0 0.1))) + (audition (out 0 (moog-ff p f1 (mul 0.83 y) 0)))) diff --git a/rsc3/examples/ugen/filters/normalizer.help.scm b/rsc3/examples/ugen/filters/normalizer.help.scm new file mode 100644 index 0000000..c05f91f --- /dev/null +++ b/rsc3/examples/ugen/filters/normalizer.help.scm @@ -0,0 +1,9 @@ +;; (normalizer in level dur) + +;; Flattens dynamics. + +(let ((z (mul (decay2 (impulse ar 8 (mul (lf-saw kr 0.25 -0.6) 0.7)) + 0.001 + 0.3) + (f-sin-osc ar 500 0)))) + (audition (out 0 (mce2 z (normalizer z 0.4 0.01))))) diff --git a/rsc3/examples/ugen/filters/one-pole.help.scm b/rsc3/examples/ugen/filters/one-pole.help.scm new file mode 100644 index 0000000..3fa4c5e --- /dev/null +++ b/rsc3/examples/ugen/filters/one-pole.help.scm @@ -0,0 +1,20 @@ +;; (one-pole in coef) + +;; A one pole filter. Implements the formula: out(i) = ((1 - +;; abs(coef)) * in(i)) + (coef * out(i-1)). + +;; in - input signal to be processed +;; coef - feedback coefficient. Should be between -1 and +1 + +(audition + (out 0 (one-pole (mul (white-noise ar) 0.5) 0.95))) + +(audition + (out 0 (one-pole (mul (white-noise ar) 0.5) -0.95))) + +(audition + (out 0 (one-pole (mul (white-noise ar) 0.5) + (line kr -0.99 0.99 10 remove-synth)))) + + + diff --git a/rsc3/examples/ugen/filters/one-zero.help.scm b/rsc3/examples/ugen/filters/one-zero.help.scm new file mode 100644 index 0000000..aee0267 --- /dev/null +++ b/rsc3/examples/ugen/filters/one-zero.help.scm @@ -0,0 +1,13 @@ +;; (one-zero in coef) + +;; One zero filter + +(audition + (out 0 (one-zero (mul (white-noise ar) 0.5) 0.5))) + +(audition + (out 0 (one-zero (mul (white-noise ar) 0.5) -0.5))) + +(audition + (out 0 (one-zero (mul (white-noise ar) 0.5) + (line kr -0.5 0.5 10 remove-synth)))) diff --git a/rsc3/examples/ugen/filters/resonz.help.scm b/rsc3/examples/ugen/filters/resonz.help.scm new file mode 100644 index 0000000..56706a7 --- /dev/null +++ b/rsc3/examples/ugen/filters/resonz.help.scm @@ -0,0 +1,39 @@ +;; (resonz in freq bwr) + +;; Resonant filter. + +;; A two pole resonant filter with zeroes at z = +/- 1. Based on +;; K. Steiglitz, "A Note on Constant-Gain Digital Resonators," +;; Computer Music Journal, vol 18, no. 4, pp. 8-10, Winter 1994. The +;; reciprocal of Q is used rather than Q because it saves a divide +;; operation inside the unit generator. + +;; in - input signal to be processed +;; freq - resonant frequency in Hertz +;; rq - bandwidth ratio (reciprocal of Q). rq = bandwidth / centerFreq + +(audition (out 0 (resonz (mul (white-noise ar) 0.5) 2000 0.1))) + +;; Modulate frequency + +(let ((f (x-line kr 1000 8000 10 remove-synth))) + (audition (out 0 (resonz (mul (white-noise ar) 0.5) f 0.05)))) + +;; Modulate bandwidth + +(let ((rq (x-line kr 1 0.001 8 remove-synth))) + (audition (out 0 (resonz (mul (white-noise ar) 0.5) 2000 rq)))) + +;; Modulate bandwidth opposite direction + +(let ((rq (x-line kr 0.001 1 8 remove-synth))) + (audition (out 0 (resonz (mul (white-noise ar) 0.5) 2000 rq)))) + +;; random resonator at a random location, run as often as you like... + +(let ((freq (choose (map (lambda (z) (* z 120)) (enum-from-to 1 16)))) + (bw 1/4) + (gain 8)) + (audition (out 0 (pan2 (resonz (white-noise ar) freq (/ bw freq)) + (rand -1 1) + gain)))) diff --git a/rsc3/examples/ugen/filters/rhpf.help.scm b/rsc3/examples/ugen/filters/rhpf.help.scm new file mode 100644 index 0000000..3efcd7a --- /dev/null +++ b/rsc3/examples/ugen/filters/rhpf.help.scm @@ -0,0 +1,10 @@ +;; (Rhpf in freq rq) + +;; A resonant high pass filter. + +(audition + (out + 0 + (rhpf (mul (saw ar 200) 0.1) + (mul-add (f-sin-osc kr (x-line kr 0.7 300 20 remove-synth) 0) 3600 4000) + 0.2))) diff --git a/rsc3/examples/ugen/filters/ringz.help.scm b/rsc3/examples/ugen/filters/ringz.help.scm new file mode 100644 index 0000000..0847016 --- /dev/null +++ b/rsc3/examples/ugen/filters/ringz.help.scm @@ -0,0 +1,46 @@ +;; (ringz in freq decayTime) + +;; Ringing filter. This is the same as resonz, except that instead of +;; a resonance parameter, the bandwidth is specified in a 60dB ring +;; decay time. One ringz is equivalent to one component of the klank +;; UGen. + +(audition + (out 0 (ringz (mul (dust ar 3) 0.3) 2000 2))) + +(audition + (out 0 (ringz (mul (white-noise ar) 0.005) 2000 0.5))) + +;; Modulate frequency + +(audition + (out 0 (ringz (mul (white-noise ar) 0.005) + (x-line kr 100 3000 10 do-nothing) + 0.5))) + +(audition + (out 0 (ringz (mul (impulse ar 6 0) 0.3) + (x-line kr 100 3000 10 do-nothing) + 0.5))) + +;; Modulate ring time + +(audition + (out 0 (ringz (mul (impulse ar 6 0) 0.3) + 2000 + (x-line kr 4 0.04 8 do-nothing)))) + +;; Modulate ring time opposite direction + +(audition + (out 0 (ringz (mul (impulse ar 6 0) 0.3) + 2000 + (x-line kr 0.04 4 8 do-nothing)))) + +(audition + (out 0 (let ((n (mul (white-noise ar) 0.001))) + (mix-fill + 10 + (lambda (_) + (let ((f (x-line kr (rand 100 5000) (rand 100 5000) 20 do-nothing))) + (ringz n f 0.5))))))) diff --git a/rsc3/examples/ugen/filters/rlpf.help.scm b/rsc3/examples/ugen/filters/rlpf.help.scm new file mode 100644 index 0000000..718d47b --- /dev/null +++ b/rsc3/examples/ugen/filters/rlpf.help.scm @@ -0,0 +1,8 @@ +;; (Rlpf in freq rq) + +;; A resonant low pass filter. + +(let* ((f1 (x-line kr 0.7 300 20 remove-synth)) + (f2 (mul-add (f-sin-osc kr f1 0) 3600 4000))) + (audition + (out 0 (rlpf (mul (saw ar 200) 0.1) f2 0.2)))) diff --git a/rsc3/examples/ugen/filters/sos.help.scm b/rsc3/examples/ugen/filters/sos.help.scm new file mode 100644 index 0000000..9b919ed --- /dev/null +++ b/rsc3/examples/ugen/filters/sos.help.scm @@ -0,0 +1,13 @@ +;; (sos in a0 a1 a2 b1 b2) + +;; Second order filter section (biquad). A standard second order +;; filter section. Filter coefficients are given directly rather than +;; calculated for you. + +;; Same as two-pole + +(let* ((theta (line kr (* 0.2 pi) pi 5 remove-synth)) + (rho (line kr 0.6 0.99 5 remove-synth)) + (b1 (mul 2 (mul rho (u:cos theta)))) + (b2 (neg (squared rho)))) + (audition (out 0 (sos (lf-saw ar 200 0.1) 1 0 0 b1 b2)))) diff --git a/rsc3/examples/ugen/filters/two-pole.help.scm b/rsc3/examples/ugen/filters/two-pole.help.scm new file mode 100644 index 0000000..23fd13d --- /dev/null +++ b/rsc3/examples/ugen/filters/two-pole.help.scm @@ -0,0 +1,12 @@ +;; (two-pole in freq radius) + +;; Two pole filter. This provides lower level access to setting of +;; pole location. For general purposes resonz is better. + +(audition + (out 0 (two-pole (mul (white-noise ar) 0.005) 2000 0.95))) + +(audition + (out 0 (two-pole (mul (white-noise ar) 0.005) + (x-line kr 800 8000 8 remove-synth) + 0.95))) diff --git a/rsc3/examples/ugen/filters/two-zero.help.scm b/rsc3/examples/ugen/filters/two-zero.help.scm new file mode 100644 index 0000000..9f4639d --- /dev/null +++ b/rsc3/examples/ugen/filters/two-zero.help.scm @@ -0,0 +1,8 @@ +;; (two-zero in freq radius) + +;; Two zero filter + +(audition + (out 0 (two-zero (mul (white-noise ar) 0.125) + (x-line kr 20 20000 8 remove-synth) + 1))) diff --git a/rsc3/examples/ugen/filters/wrap.help.scm b/rsc3/examples/ugen/filters/wrap.help.scm new file mode 100644 index 0000000..082ecbb --- /dev/null +++ b/rsc3/examples/ugen/filters/wrap.help.scm @@ -0,0 +1,22 @@ +;; (wrap in lo hi) + +;; wrap a signal outside given thresholds. + +;; This differs from the BinaryOpUGen wrap2 in that it allows one to +;; set both low and high thresholds. + +;; in - signal to be wrapped +;; lo - low threshold of wrapping +;; hi - high threshold of wrapping + +(let ((o (mul (sin-osc ar 440 0) 0.2)) + (l (rand -0.175 -0.025)) + (r (rand 0.025 0.175))) + (audition (out 0 (wrap o l r)))) + +;; lo and hi are i-rate only. + +(let ((o (mul (sin-osc ar 440 0) 0.2)) + (x (mouse-x kr -0.175 -0.025 1 0.1)) + (y (mouse-y kr 0.025 0.175 1 0.1))) + (audition (out 0 (wrap o x y)))) diff --git a/rsc3/examples/ugen/granular/grain-buf.help.scm b/rsc3/examples/ugen/granular/grain-buf.help.scm new file mode 100644 index 0000000..d03d10c --- /dev/null +++ b/rsc3/examples/ugen/granular/grain-buf.help.scm @@ -0,0 +1,46 @@ +;; (grain-buf nc tr dur sndbuf rate pos interp pan envbuf) + +;; Granular synthesis with sound stored in a buffer + +;; nc - the number of channels to output. If 1, mono is returned and +;; pan is ignored. + +;; tr - a kr or ar trigger to start a new grain. If ar, grains after +;; the start of the synth are sample accurate. + +;; The following args are polled at grain creation time + +;; dur - size of the grain. + +;; sndbuf - the buffer holding an audio signal + +;; rate - the playback rate of the sampled sound + +;; pos - the playback position for the grain to start with (0 is +;; beginning, 1 is end of file) + +;; interp - the interpolation method used for pitchshifting grains. +;; 1 = no interpolation. 2 = linear. 4 = cubic interpolation +;; (more computationally intensive). + +;; pan - a value from -1 to 1. Determines where to pan the output in +;; the same manner as pan-az. + +;; envb - the buffer number containing a singal to use for the +;; grain envelope. -1 uses a built-in Hanning envelope. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 10 "/home/rohan/audio/metal.wav" 0 0)) + (let ((g (letc ((gate 1) + (amp 1) + (sndbuf 0) + (envbuf -1)) + (let* ((x (mouse-x kr -1 1 0 0.1)) + (y (mouse-y kr 10 45 0 0.1)) + (i (impulse kr y 0)) + (r (lin-lin (lf-noise1 kr 500) -1 1 0.5 2)) + (p (lin-lin (lf-noise2 kr 0.1) -1 1 0 1))) + (out 0 (grain-buf 2 i 0.1 sndbuf r p 2 x envbuf)))))) + (send-synth fd "g" g) + (send fd (s-new2 "g" -1 add-to-tail 1 "sndbuf" 10 "envbuf" -1))))) diff --git a/rsc3/examples/ugen/granular/grain-fm.help.scm b/rsc3/examples/ugen/granular/grain-fm.help.scm new file mode 100644 index 0000000..750f2ab --- /dev/null +++ b/rsc3/examples/ugen/granular/grain-fm.help.scm @@ -0,0 +1,35 @@ +;; (grain-fm nc tr dur carfreq modfreq index pan envbuf) + +;; Granular synthesis with frequency modulated sine tones + +;; nc - the number of channels to output. If 1, mono is returned and +;; pan is ignored. + +;; tr - a kr or ar trigger to start a new grain. If ar, grains after +;; the start of the synth are sample accurate. + +;; The following args are polled at grain creation time + +;; dur - size of the grain. + +;; carfreq - the carrier freq of the grain generators internal +;; oscillator + +;; modfreq - the modulating freq of the grain generators internal +;; oscillator + +;; index - the index of modulation + +;; pan - a value from -1 to 1. Determines where to pan the output in +;; the same manner as pan-az. + +;; envbuf - the buffer number containing a singal to use for the grain +;; envelope. -1 uses a built-in Hanning envelope. + +(let* ((x (mouse-x kr -0.5 0.5 0 0.1)) + (y (mouse-y kr 0 400 0 0.1)) + (n (white-noise kr)) + (fd (add 440 (mul n y))) + (t (impulse kr 10 0)) + (i (lin-lin (lf-noise1 kr 500) -1 1 1 10))) + (audition (out 0 (mul (grain-fm 2 t 0.1 fd 200 i x -1) 0.1)))) diff --git a/rsc3/examples/ugen/granular/grain-in.help.scm b/rsc3/examples/ugen/granular/grain-in.help.scm new file mode 100644 index 0000000..91d636c --- /dev/null +++ b/rsc3/examples/ugen/granular/grain-in.help.scm @@ -0,0 +1,27 @@ +;; (Grainin nc tr dur in pan envbuf) + +;; Granulate an input signal + +;; nc - the number of channels to output. If 1, mono is +;; returned and pan is ignored. + +;; tr - a kr or ar trigger to start a new grain. If ar, grains +;; after the start of the synth are sample accurate. + +;; The following args are polled at grain creation time + +;; dur - size of the grain. + +;; in - the input to granulate + +;; pan - a value from -1 to 1. Determines where to pan the output in +;; the same manner as pan-az. + +;; envbuf - the buffer number containing a singal to use for the +;; grain envelope. -1 uses a built-in Hanning envelope. + +(let* ((x (mouse-x kr -0.5 0.5 0 0.1)) + (y (mouse-y kr 5 25 0 0.1)) + (n (pink-noise ar)) + (t (impulse kr y 0))) + (audition (out 0 (mul (grain-in 2 t 0.1 n x -1) 0.1)))) diff --git a/rsc3/examples/ugen/granular/grain-sin.help.scm b/rsc3/examples/ugen/granular/grain-sin.help.scm new file mode 100644 index 0000000..21181bd --- /dev/null +++ b/rsc3/examples/ugen/granular/grain-sin.help.scm @@ -0,0 +1,28 @@ +;; (grain-sin nc tr dur freq pan envbuf) + +;; Granular synthesis with sine tones + +;; nc - the number of channels to output. If 1, mono is returned and +;; pan is ignored. + +;; tr - a kr or ar trigger to start a new grain. If ar, grains after +;; the start of the synth are sample accurate. + +;; The following args are polled at grain creation time + +;; dur - size of the grain. + +;; freq - the input to granulate + +;; pan - a value from -1 to 1. Determines where to pan the output in +;; the same manner as pan-az. + +;; envbuf - the buffer number containing a singal to use for the grain +;; envelope. -1 uses a built-in Hanning envelope. + +(let* ((x (mouse-x kr -0.5 0.5 0 0.1)) + (y (mouse-y kr 0 400 0 0.1)) + (n (white-noise kr)) + (f (add 440 (mul n y))) + (t (impulse kr 10 0))) + (audition (out 0 (mul (grain-sin 2 t 0.1 f x -1) 0.1)))) diff --git a/rsc3/examples/ugen/granular/warp1.help.scm b/rsc3/examples/ugen/granular/warp1.help.scm new file mode 100644 index 0000000..bb9341c --- /dev/null +++ b/rsc3/examples/ugen/granular/warp1.help.scm @@ -0,0 +1,43 @@ +;; (warp1 nc buf ptr freqScale windowSize envbuf overlaps windowrandRatio interp) + +;; Warp a buffer with a time pointer + +;; inspired by Chad Kirby's SuperCollider2 warp1 class, which was +;; inspired by Richard Karpen's sndwarp for CSound. A granular time +;; strecher and pitchshifter. + +;; nc - the number of channels in the soundfile used in bufnum. + +;; buf - the buffer number of a mono soundfile. + +;; ptr - the position in the buffer. The value should be between 0 +;; and 1, with 0 being the begining of the buffer, and 1 the +;; end. + +;; freqScale - the amount of frequency shift. 1.0 is normal, 0.5 is +;; one octave down, 2.0 is one octave up. Negative values +;; play the soundfile backwards. + +;; windowSize - the size of each grain window. + +;; envbuf - the buffer number containing a singal to use for the grain +;; envelope. -1 uses a built-in Hanning envelope. + +;; overlaps - the number of overlaping windows. + +;; windowrandRatio - the amount of randomness to the windowing +;; function. Must be between 0 (no randomness) to +;; 1.0 (probably to random actually) + +;; interp - the interpolation method used for pitchshifting grains. 1 +;; = no interpolation. 2 = linear. 4 = cubic interpolation +;; (more computationally intensive). + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 10 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((p (lin-lin (lf-saw kr 0.05 0) -1 1 0 1)) + (x (mouse-x kr 0.5 2 0 0.1)) + (w (warp1 1 10 p x 0.1 -1 8 0.1 2))) + (audition (out 0 w))) diff --git a/rsc3/examples/ugen/information/buf-channels.help.scm b/rsc3/examples/ugen/information/buf-channels.help.scm new file mode 100644 index 0000000..1b71dbb --- /dev/null +++ b/rsc3/examples/ugen/information/buf-channels.help.scm @@ -0,0 +1,5 @@ +;; (buf-channels rate bufnum) + +;; Current number of channels of buffer. Using at .ir is not the +;; safest choice. Since a buffer can be reallocated at any time, using +;; ir will not track the changes. diff --git a/rsc3/examples/ugen/information/buf-dur.help.scm b/rsc3/examples/ugen/information/buf-dur.help.scm new file mode 100644 index 0000000..9003909 --- /dev/null +++ b/rsc3/examples/ugen/information/buf-dur.help.scm @@ -0,0 +1,12 @@ +;; (buf-dur rate bufnum) + +;; Current duration of buffer. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 0 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((t (impulse ar (recip (buf-dur kr 0)) 0)) + (p (sweep t (buf-sample-rate kr 0)))) + (audition (out 0 (buf-rd 1 ar 0 p 0 2)))) + diff --git a/rsc3/examples/ugen/information/buf-frames.help.scm b/rsc3/examples/ugen/information/buf-frames.help.scm new file mode 100644 index 0000000..aa327e0 --- /dev/null +++ b/rsc3/examples/ugen/information/buf-frames.help.scm @@ -0,0 +1,13 @@ +;; (buf-frames rate bufnum) + +;; Current duration of buffer. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 0 "/home/rohan/audio/metal.wav" 0 0)))) + +(let ((p (phasor ar 0 (buf-rate-scale kr 0) 0 (buf-frames kr 0) 0))) + (audition (out 0 (buf-rd 1 ar 0 p 0 2)))) + +(let ((p (k2a (mouse-x kr 0 (buf-frames kr 0) 0 0.1)))) + (audition (out 0 (buf-rd 1 ar 0 p 0 2)))) diff --git a/rsc3/examples/ugen/information/buf-rate-scale.help.scm b/rsc3/examples/ugen/information/buf-rate-scale.help.scm new file mode 100644 index 0000000..db14bbc --- /dev/null +++ b/rsc3/examples/ugen/information/buf-rate-scale.help.scm @@ -0,0 +1,12 @@ +;; (buf-rate-scale rate bufnum) + +;; Buffer rate scaling in respect to server samplerate. Returns a +;; ratio by which the playback of a soundfile is to be scaled. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 0 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((r (mul (rand 0.5 2) (buf-rate-scale kr 0))) + (p (phasor ar 0 r 0 (buf-frames kr 0) 0))) + (audition (out 0 (buf-rd 1 ar 0 p 0 2)))) diff --git a/rsc3/examples/ugen/information/buf-sample-rate.help.scm b/rsc3/examples/ugen/information/buf-sample-rate.help.scm new file mode 100644 index 0000000..0e94e8b --- /dev/null +++ b/rsc3/examples/ugen/information/buf-sample-rate.help.scm @@ -0,0 +1,13 @@ +;; (buf-sample-rate rate bufnum) + +;; Buffer sample rate. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 0 "/home/rohan/audio/metal.wav" 0 0)))) + +;; Compare a sine tone derived from sample rate of a buffer with a +;; 440Hz tone. + +(let ((freq (mce2 (mul (buf-sample-rate ir 0) 0.01) 440))) + (audition (out 0 (mul (sin-osc ar freq 0) 0.1)))) diff --git a/rsc3/examples/ugen/information/num-audio-buses.help.scm b/rsc3/examples/ugen/information/num-audio-buses.help.scm new file mode 100644 index 0000000..aad29c8 --- /dev/null +++ b/rsc3/examples/ugen/information/num-audio-buses.help.scm @@ -0,0 +1,2 @@ +;; num-audio-buses + diff --git a/rsc3/examples/ugen/information/num-buffers.help.scm b/rsc3/examples/ugen/information/num-buffers.help.scm new file mode 100644 index 0000000..34c2cce --- /dev/null +++ b/rsc3/examples/ugen/information/num-buffers.help.scm @@ -0,0 +1 @@ +;; num-buffers diff --git a/rsc3/examples/ugen/information/num-control-buses.help.scm b/rsc3/examples/ugen/information/num-control-buses.help.scm new file mode 100644 index 0000000..ad45bf8 --- /dev/null +++ b/rsc3/examples/ugen/information/num-control-buses.help.scm @@ -0,0 +1 @@ +;; num-control-buses diff --git a/rsc3/examples/ugen/information/num-input-buses.help.scm b/rsc3/examples/ugen/information/num-input-buses.help.scm new file mode 100644 index 0000000..67354c0 --- /dev/null +++ b/rsc3/examples/ugen/information/num-input-buses.help.scm @@ -0,0 +1,8 @@ +;; num-input-buses + +;; The number of audio buses allocated to input. input buses follow +;; output buses which begin at zero. + +(let ((bus (add num-output-buses num-input-buses))) + (audition (mrg2 (out 0 (in 1 ar bus)) + (out bus (mul (sin-osc ar 440 0) 0.1))))) diff --git a/rsc3/examples/ugen/information/num-output-buses.help.scm b/rsc3/examples/ugen/information/num-output-buses.help.scm new file mode 100644 index 0000000..b3959d4 --- /dev/null +++ b/rsc3/examples/ugen/information/num-output-buses.help.scm @@ -0,0 +1,7 @@ +;; num-output-buses + +;; The number of audio buses allocated to output. + +(let ((bus num-output-buses)) + (audition (out 0 (mul (pulse ar 90 0.3) + (amplitude kr (lag (in 1 ar bus) 0.1) 0.01 0.01))))) diff --git a/rsc3/examples/ugen/information/num-running-synths.help.scm b/rsc3/examples/ugen/information/num-running-synths.help.scm new file mode 100644 index 0000000..3121dea --- /dev/null +++ b/rsc3/examples/ugen/information/num-running-synths.help.scm @@ -0,0 +1,7 @@ +;; num-running-synths + +;; Number of currently running synths. + +(audition + (out 0 (mul (sin-osc ar (mul-add num-running-synths 200 400) 0) + 0.1))) diff --git a/rsc3/examples/ugen/information/radians-per-sample.help.scm b/rsc3/examples/ugen/information/radians-per-sample.help.scm new file mode 100644 index 0000000..f6cef51 --- /dev/null +++ b/rsc3/examples/ugen/information/radians-per-sample.help.scm @@ -0,0 +1 @@ +;; radians-per-sample diff --git a/rsc3/examples/ugen/information/sample-dur.help.scm b/rsc3/examples/ugen/information/sample-dur.help.scm new file mode 100644 index 0000000..935ca95 --- /dev/null +++ b/rsc3/examples/ugen/information/sample-dur.help.scm @@ -0,0 +1,8 @@ +;; sample-dur + +;; Duration of one sample. Equivalent to 1 / sample-rate. + +;; Compare a sine tone derived from sample rate with a 440Hz tone. + +(let ((freq (mce2 (mul (recip sample-dur) 0.01) 440))) + (audition (out 0 (mul (sin-osc ar freq 0) 0.1)))) diff --git a/rsc3/examples/ugen/information/sample-rate.help.scm b/rsc3/examples/ugen/information/sample-rate.help.scm new file mode 100644 index 0000000..113b932 --- /dev/null +++ b/rsc3/examples/ugen/information/sample-rate.help.scm @@ -0,0 +1,8 @@ +;; sample-rate + +;; Server sample rate. + +;; Compare a sine tone derived from sample rate with a 440Hz tone. + +(let ((freq (mce2 (mul sample-rate 0.01) 440))) + (audition (out 0 (mul (sin-osc ar freq 0) 0.1)))) diff --git a/rsc3/examples/ugen/information/subsample-offset.help.scm b/rsc3/examples/ugen/information/subsample-offset.help.scm new file mode 100644 index 0000000..c4ac1b4 --- /dev/null +++ b/rsc3/examples/ugen/information/subsample-offset.help.scm @@ -0,0 +1,45 @@ +;; subsample-offset + +;; Offset from synth start within one sample. + +;; When a synth is created from a time stamped osc-bundle, it starts +;; calculation at the next possible block (normally 64 samples). Using +;; an offset-out ugen, one can delay the audio so that it matches +;; sample accurately. For some synthesis methods, one needs subsample +;; accuracy. subsample-offset provides the information where, within +;; the current sample, the synth was scheduled. It can be used to +;; offset envelopes or resample the audio output. + +;; See also offset-out. + +;; Demonstrate cubic subsample interpolation. An impulse train that +;; can be moved between samples. + +(with-sc3 + (lambda (fd) + (send-synth + fd + "s" + (letc ((out 0) + (add-offset 0)) + (let* ((i (mul (impulse ar 2000 0) 0.3)) + (d sample-dur) + (x 4) + (o (add (sub 1 subsample-offset) + (mouse-x kr 0 add-offset 0 0.1))) + (r (delay-c i (mul d (add 1 x)) (mul d (add o x))))) + (offset-out out r)))))) + +;; Create two pulse trains one sample apart, move one relative to the +;; other. When cursor is at the left, the impulses are adjacent, on +;; the right, they are exactly 1 sample apart. View this with an +;; oscilloscope. + +(with-sc3 + (lambda (fd) + (let ((t (utc)) + (dt (/ 1 (server-sample-rate-actual fd)))) + (send fd (bundle (+ t 0.2) + (list (s-new1 "s" -1 1 1 "addOffset" 3)))) + (send fd (bundle (+ t 0.2 dt) + (list (s-new1 "s" -1 1 1 "addOffset" 0))))))) diff --git a/rsc3/examples/ugen/io/in-feedback.help.scm b/rsc3/examples/ugen/io/in-feedback.help.scm new file mode 100644 index 0000000..80e5791 --- /dev/null +++ b/rsc3/examples/ugen/io/in-feedback.help.scm @@ -0,0 +1,57 @@ +;; (in-feedback num-channels bus) + +;; Read signal from a bus without erasing it, audio rate. + +;; The output (out) ugens overwrite data on the bus, giving this bus a +;; new timestamp so that any input (in) ugen can check if the data was +;; written within the current cycle. The next cycle this data is still +;; there, but in case of audio one normally doesn't want an in ugen to +;; read it again, as it might cause feedback. + +;; This is the reason why in ar checks the timestamp and ignores +;; everything that was not written within this cycle. This means that +;; nodes can only read data from a bus that was written by a +;; preceeding node when using the in ar ugen which overwrites the old +;; data. This is good for audio, but for control data it is more +;; convenient to be able to read a bus from any place in the node +;; order. + +;; This is why in kr behaves differently and reads also data with a +;; timestamp that is one cycle old. Now in some cases we want to be +;; able to read audio from a bus independant of the current node +;; order, which is the use of inFeedback. The delay introduced by +;; this is at a maximum one block size, which equals about 0.0014 sec +;; at the default block size and sample rate. + +;; Audio feedback modulation. + +(let ((f (mul-add (in-feedback 1 0) 1300 300))) + (audition (out 0 (mul (sin-osc ar f 0) 0.4)))) + +;; Evaluate these in either order and hear both tones. + +(let ((b (add num-input-buses num-output-buses))) + (audition (out 0 (in-feedback 1 b)))) + +(let ((b (add num-input-buses num-output-buses))) + (audition (mrg2 (out b (mul (sin-osc ar 440 0) 0.1)) + (out 0 (mul (sin-osc ar 660 0) 0.1))))) + +;; Doubters consult this. + +(let ((b (add num-input-buses num-output-buses))) + (audition (out 0 (in 1 ar b)))) + +;; Resonator, see localout for variant. + +(let* ((b (add num-input-buses num-output-buses)) + (p (in-feedback 1 b)) + (i (impulse ar 1 0)) + (d (delay-c (add i (mul p 0.995)) + 1 + (sub (recip 440) (recip control-rate))))) + (audition (mrg2 (offset-out b d) (offset-out 0 p)))) + +;; Compare with oscillator. + +(audition (out 1 (mul (sin-osc ar 440 0) 0.2))) diff --git a/rsc3/examples/ugen/io/in-trig.help.scm b/rsc3/examples/ugen/io/in-trig.help.scm new file mode 100644 index 0000000..8b05ad2 --- /dev/null +++ b/rsc3/examples/ugen/io/in-trig.help.scm @@ -0,0 +1,21 @@ +;; (in-trig num-channels bus) + +;; Generate a trigger anytime a bus is set. + +;; Any time the bus is "touched" ie. has its value set (using "/c_set" +;; etc.), a single impulse trigger will be generated. Its amplitude +;; is the value that the bus was set to. + +;; Run an oscillator with the trigger at bus 10. + +(let* ((t (in-trig 1 10)) + (p (env-perc 0.01 1 1 (list -4 -4))) + (e (env-gen kr t t 0 1 do-nothing p)) + (f (mul-add (latch t t) 440 880))) + (audition (out 0 (mul (sin-osc ar f 0) e)))) + +;; Set bus 10. + +(with-sc3 + (lambda (fd) + (send fd (c-set1 10 0.5)))) diff --git a/rsc3/examples/ugen/io/in.help.scm b/rsc3/examples/ugen/io/in.help.scm new file mode 100644 index 0000000..b4c8a22 --- /dev/null +++ b/rsc3/examples/ugen/io/in.help.scm @@ -0,0 +1,25 @@ +;; (in num-channels rate bus) + +;; Read signal from an audio or control bus. + +;; Patching input to output. + +(audition (out 0 (in 2 ar num-output-buses))) + +;; Patching input to output, with summed delay. + +(let ((i (in 2 ar num-input-buses))) + (audition (out 0 (add i (delay-n i 0.5 0.5))))) + +;; Write noise to bus 10, then read it out. The Mrg is ordered. + +(audition (mrg2 (out 0 (in 1 ar 10)) + (out 10 (mul (pink-noise ar) 0.3)))) + +;; Reading a control bus. + +(with-sc3 + (lambda (fd) + (send fd (c-set1 0 (random 200 5000))))) + +(audition (out 0 (mul (sin-osc ar (in 1 kr 0) 0) 0.1))) diff --git a/rsc3/examples/ugen/io/lag-in.help.scm b/rsc3/examples/ugen/io/lag-in.help.scm new file mode 100644 index 0000000..ad395ef --- /dev/null +++ b/rsc3/examples/ugen/io/lag-in.help.scm @@ -0,0 +1,11 @@ +;; (lag-in num-channels bus lag) + +;; Set bus 10. + +(with-sc3 + (lambda (fd) + (send fd (c-set1 10 (random 200 8000))))) + +;; Smooth a control rate input signal. + +(audition (out 0 (mul (sin-osc ar (lag-in 1 10 1) 0) 0.1))) diff --git a/rsc3/examples/ugen/io/local-in.help.scm b/rsc3/examples/ugen/io/local-in.help.scm new file mode 100644 index 0000000..b566e17 --- /dev/null +++ b/rsc3/examples/ugen/io/local-in.help.scm @@ -0,0 +1,18 @@ +;; (local-in num-channels rate) + +;; Define and read from buses local to a SynthDef + +;; num-channels - the number of channels of local buses. + +;; Localin defines buses that are local to the SynthDef. These are +;; like the global buses, but are more convenient if you want to +;; implement a self contained effect that uses a feedback processing +;; loop. There can only be one audio rate and one control rate +;; Localin per SynthDef. The audio can be written to the bus using +;; local-out. + +(let* ((a0 (mul (decay (impulse ar 0.3 0) 0.1) (mul (white-noise ar) 0.2))) + (a1 (add (local-in 2 ar) (mce2 a0 0))) + (a2 (delay-n a1 0.2 0.2))) + (audition (mrg2 (local-out (mul (mce-reverse a2) 0.8)) + (out 0 a2)))) diff --git a/rsc3/examples/ugen/io/offset-out.help.scm b/rsc3/examples/ugen/io/offset-out.help.scm new file mode 100644 index 0000000..5f291c3 --- /dev/null +++ b/rsc3/examples/ugen/io/offset-out.help.scm @@ -0,0 +1,12 @@ +;; (offset-out bufferindex inputs) + +;; output signal to a bus, the sample offset within the bus is kept +;; exactly. This ugen is used where sample accurate output is needed. + +(audition + (mrg2 (offset-out 0 (impulse ar 5 0)) + (out 0 (mul (sin-osc ar 60 0) 0.1)))) + +(audition + (mrg2 (out 0 (impulse ar 5 0)) + (out 0 (mul (sin-osc ar 60 0) 0.1)))) diff --git a/rsc3/examples/ugen/io/out.help.scm b/rsc3/examples/ugen/io/out.help.scm new file mode 100644 index 0000000..8d13f3b --- /dev/null +++ b/rsc3/examples/ugen/io/out.help.scm @@ -0,0 +1,7 @@ +;; (out bufferindex inputs) + +;; Send signal to an audio or control buss, mix with existing signal. +;; The user is responsible for making sure that the number of channels +;; match and that there are no conflicts. + +(audition (out 0 (mul (sin-osc ar (mce2 330 331) 0) 0.1))) diff --git a/rsc3/examples/ugen/io/replace-out.help.scm b/rsc3/examples/ugen/io/replace-out.help.scm new file mode 100644 index 0000000..3312f98 --- /dev/null +++ b/rsc3/examples/ugen/io/replace-out.help.scm @@ -0,0 +1,15 @@ +;; (replace-out bufferindex inputs) + +;; Send signal to a bus, overwrite existing signal. + +(audition + (mrg3 (out 0 (mul (sin-osc ar (mce2 330 331) 0) 0.1)) + (replace-out 0 (mul (sin-osc ar (mce2 880 881) 0) 0.1)) + (out 0 (mul (sin-osc ar (mce2 120 121) 0) 0.1)))) + +;; Compare to: + +(audition + (mrg3 (out 0 (mul (sin-osc ar (mce2 330 331) 0) 0.1)) + (out 0 (mul (sin-osc ar (mce2 880 881) 0) 0.1)) + (out 0 (mul (sin-osc ar (mce2 120 121) 0) 0.1)))) diff --git a/rsc3/examples/ugen/io/sound-in.help.scm b/rsc3/examples/ugen/io/sound-in.help.scm new file mode 100644 index 0000000..aaa5502 --- /dev/null +++ b/rsc3/examples/ugen/io/sound-in.help.scm @@ -0,0 +1,12 @@ +;; (sound-in channel) + +;; Read audio from the sound input hardware. + +;; channel - input channel number to read, +;; indexed from zero, can be mce. + +(audition (out 0 (sound-in 0))) + +(audition (out 0 (sound-in (mce2 0 1)))) + +(audition (out 0 (sound-in (mce4 0 2 1 3)))) diff --git a/rsc3/examples/ugen/io/x-out.help.scm b/rsc3/examples/ugen/io/x-out.help.scm new file mode 100644 index 0000000..9b26a15 --- /dev/null +++ b/rsc3/examples/ugen/io/x-out.help.scm @@ -0,0 +1,10 @@ +;; (x-out buffer-index xfade inputs) + +;; Send signal to a bus, crossfading with existing contents. + +(let ((pair (lambda (a b) (mul (sin-osc ar (mce2 a b) 0) 0.1)))) + (audition + (mrg4 (out 0 (pair 220 221)) + (x-out 0 (mouse-x kr 0 1 0 0.1) (pair 330 331)) + (x-out 0 (mouse-y kr 0 1 0 0.1) (pair 440 441)) + (out 0 (pair 120 121))))) diff --git a/rsc3/examples/ugen/noise/brown-noise.help.scm b/rsc3/examples/ugen/noise/brown-noise.help.scm new file mode 100644 index 0000000..790f86b --- /dev/null +++ b/rsc3/examples/ugen/noise/brown-noise.help.scm @@ -0,0 +1,6 @@ +;; (brown-noise rate) + +;; Generates noise whose spectrum falls off in power by 6 dB per +;; octave. + +(audition (out 0 (mul (brown-noise ar) 0.1))) diff --git a/rsc3/examples/ugen/noise/clip-noise.help.scm b/rsc3/examples/ugen/noise/clip-noise.help.scm new file mode 100644 index 0000000..3304c41 --- /dev/null +++ b/rsc3/examples/ugen/noise/clip-noise.help.scm @@ -0,0 +1,6 @@ +;; (clip-noise rate) + +;; Generates noise whose values are either -1 or 1. This produces the +;; maximum energy for the least peak to peak amplitude. + +(audition (out 0 (mul (clip-noise ar) 0.2))) diff --git a/rsc3/examples/ugen/noise/coin-gate.help.scm b/rsc3/examples/ugen/noise/coin-gate.help.scm new file mode 100644 index 0000000..33a6f1b --- /dev/null +++ b/rsc3/examples/ugen/noise/coin-gate.help.scm @@ -0,0 +1,15 @@ +;; (coin-gate prob in) + +;; When it receives a trigger, it tosses a coin, and either passes the +;; trigger or doesn't. + +(let ((f (t-rand 300 400 (Coingate 0.8 (impulse kr 10 0))))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) + +(let* ((p 0.2) + (t (mul (impulse ar 20 0) (add (sin-osc kr 0.5 0) 1))) + (t* (t-exp-rand (Mce 1000 1000) 12000 t)) + (i (lambda () (Coingate (+ p (rand 0 0.1)) (mul t 0.5)))) + (s (lambda () (ringz (i) t* 0.01))) + (ignore (lambda (f) (lambda (_) (f))))) + (audition (out 0 (mix/fill 3 (ignore s))))) diff --git a/rsc3/examples/ugen/noise/dust.help.scm b/rsc3/examples/ugen/noise/dust.help.scm new file mode 100644 index 0000000..3839f86 --- /dev/null +++ b/rsc3/examples/ugen/noise/dust.help.scm @@ -0,0 +1,9 @@ +;; (dust rate density) + +;; Generates random impulses from 0 to +1 at a rate determined by the +;; density argument. + +(audition (out 0 (mul (dust ar 200) 0.5))) + +(let ((r (x-line kr 20000 2 10 remove-synth))) + (audition (out 0 (mul (dust ar r) 0.5)))) diff --git a/rsc3/examples/ugen/noise/dust2.help.scm b/rsc3/examples/ugen/noise/dust2.help.scm new file mode 100644 index 0000000..9311075 --- /dev/null +++ b/rsc3/examples/ugen/noise/dust2.help.scm @@ -0,0 +1,9 @@ +;; (dust2 rate density) + +;; Generates random impulses from -1 to +1. The `density' is in +;; impulses per second. + +(audition (out 0 (mul (dust2 ar 200) 0.5))) + +(let ((r (x-line kr 20000 2 10 remove-synth))) + (audition (out 0 (mul (dust2 ar r) 0.5)))) diff --git a/rsc3/examples/ugen/noise/exp-rand.help.scm b/rsc3/examples/ugen/noise/exp-rand.help.scm new file mode 100644 index 0000000..4012803 --- /dev/null +++ b/rsc3/examples/ugen/noise/exp-rand.help.scm @@ -0,0 +1,8 @@ +;; (exp-rand lo hi) + +;; Generates a single random float value in an exponential +;; distributions from `lo' to `hi'. + +(let ((f (exp-rand 100 8000)) + (a (line kr 0.5 0 0.01 remove-synth))) + (audition (out 0 (mul (f-sin-osc ar f 0) a)))) diff --git a/rsc3/examples/ugen/noise/gray-noise.help.scm b/rsc3/examples/ugen/noise/gray-noise.help.scm new file mode 100644 index 0000000..1db8191 --- /dev/null +++ b/rsc3/examples/ugen/noise/gray-noise.help.scm @@ -0,0 +1,7 @@ +;; (gray-noise rate) + +;; Generates noise which results from flipping random bits in a word. +;; This type of noise has a high RMS level relative to its peak to +;; peak level. The spectrum is emphasized towards lower frequencies. + +(audition (out 0 (mul (gray-noise ar) 0.1))) diff --git a/rsc3/examples/ugen/noise/hasher.help.scm b/rsc3/examples/ugen/noise/hasher.help.scm new file mode 100644 index 0000000..a04349c --- /dev/null +++ b/rsc3/examples/ugen/noise/hasher.help.scm @@ -0,0 +1,8 @@ +;; (hasher in) + +;; Returns a unique output value from zero to one for each input value +;; according to a hash function. The same input value will always +;; produce the same output value. The input need not be from zero to +;; one. + +(audition (out 0 (mul (hasher (line ar 0 1 1 2)) 0.2))) diff --git a/rsc3/examples/ugen/noise/i-rand.help.scm b/rsc3/examples/ugen/noise/i-rand.help.scm new file mode 100644 index 0000000..d649177 --- /dev/null +++ b/rsc3/examples/ugen/noise/i-rand.help.scm @@ -0,0 +1,8 @@ +;; (i-rand lo hi) + +;; Generates a single random integer value in uniform distribution +;; from `lo' to `hi'. + +(let ((f (i-rand 200 1200)) + (a (line kr 0.2 0 0.1 remove-synth))) + (audition (out 0 (mul (f-sin-osc ar f 0) a)))) diff --git a/rsc3/examples/ugen/noise/lf-clip-noise.help.scm b/rsc3/examples/ugen/noise/lf-clip-noise.help.scm new file mode 100644 index 0000000..7c46334 --- /dev/null +++ b/rsc3/examples/ugen/noise/lf-clip-noise.help.scm @@ -0,0 +1,18 @@ +;; (lfclip-noise rate freq) + +;; randomly generates the values -1 or +1 at a rate given by the +;; nearest integer division of the sample rate by the freq argument. +;; It is probably pretty hard on your speakers. The freq argument is +;; the approximate rate at which to generate random values. + +(audition (out 0 (mul (lfclip-noise ar 1000) 0.1))) + +;; Modulate frequency + +(let ((f (x-line kr 1000 10000 10 remove-synth))) + (audition (out 0 (mul (lfclip-noise ar f) 0.1)))) + +;; Use as frequency control + +(let ((f (mul-add (lfclip-noise kr 4) 200 600))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) diff --git a/rsc3/examples/ugen/noise/lf-noise0.help.scm b/rsc3/examples/ugen/noise/lf-noise0.help.scm new file mode 100644 index 0000000..890afbc --- /dev/null +++ b/rsc3/examples/ugen/noise/lf-noise0.help.scm @@ -0,0 +1,31 @@ +;; (lf-noise0 rate freq) +;; (lf-noise1 rate freq) +;; (lf-noise2 rate freq) + +;; lf-noise0 is step noise. Generates random values at a rate given by +;; the nearest integer division of the sample rate by the freq +;; argument. + +;; lf-noise1 is ramp noise. Generates linearly interpolated random +;; values at a rate given by the nearest integer division of the +;; sample rate by the freq argument. + +;; lf-noise2 is quadratic noise. Generates quadratically interpolated +;; random values at a rate given by the nearest integer division of +;; the sample rate by the freq argument. + +(audition (out 0 (mul (lf-noise0 ar 1000) 0.25))) +(audition (out 0 (mul (lf-noise1 ar 1000) 0.25))) +(audition (out 0 (mul (lf-noise2 ar 1000) 0.25))) + +;; Modulate frequency. + +(audition (out 0 (mul (lf-noise0 ar (x-line kr 1000 10000 10 remove-synth)) 0.25))) +(audition (out 0 (mul (lf-noise1 ar (x-line kr 1000 10000 10 remove-synth)) 0.25))) +(audition (out 0 (mul (lf-noise2 ar (x-line kr 1000 10000 10 remove-synth)) 0.25))) + +;; Use as frequency control. + +(audition (out 0 (mul (sin-osc ar (mul-add (lf-noise0 kr 4) 400 450) 0) 0.2))) +(audition (out 0 (mul (sin-osc ar (mul-add (lf-noise1 kr 4) 400 450) 0) 0.2))) +(audition (out 0 (mul (sin-osc ar (mul-add (lf-noise2 kr 4) 400 450) 0) 0.2))) diff --git a/rsc3/examples/ugen/noise/lf-noise1.help.scm b/rsc3/examples/ugen/noise/lf-noise1.help.scm new file mode 100644 index 0000000..f3475db --- /dev/null +++ b/rsc3/examples/ugen/noise/lf-noise1.help.scm @@ -0,0 +1 @@ +;; See lf-noise0 diff --git a/rsc3/examples/ugen/noise/lf-noise2.help.scm b/rsc3/examples/ugen/noise/lf-noise2.help.scm new file mode 100644 index 0000000..f3475db --- /dev/null +++ b/rsc3/examples/ugen/noise/lf-noise2.help.scm @@ -0,0 +1 @@ +;; See lf-noise0 diff --git a/rsc3/examples/ugen/noise/lfd-clip-noise.help.scm b/rsc3/examples/ugen/noise/lfd-clip-noise.help.scm new file mode 100644 index 0000000..b3fba1d --- /dev/null +++ b/rsc3/examples/ugen/noise/lfd-clip-noise.help.scm @@ -0,0 +1,30 @@ +;; (lfdclip-noise rate freq) + +;; Like lfclip-noise, it generates the values -1 or +1 at a rate given +;; by the freq argument, with two differences: no time quantization, +;; and fast recovery from low freq values. + +;; (lfclip-noise, as well as lf-noise0,1,2 quantize to the nearest +;; integer division of the samplerate, and they poll the freq argument +;; only when scheduled, and thus seem to hang when freqs get very +;; low). + +;; If you don't need very high or very low freqs, or use fixed freqs, +;; lfclip-noise is more efficient. + +;; Try wiggling mouse quickly; LFNoise frequently seems stuck, +;; LFDNoise changes smoothly. + +(let ((f (mul-add (lfclip-noise ar (mouse-x kr 0.1 1000 1 0.1)) 200 500))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) + +(let ((f (mul-add (lfdclip-noise ar (mouse-x kr 0.1 1000 1 0.1)) 200 500))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) + +;; LFNoise quantizes time steps at high freqs, LFDNoise does not: + +(let ((f (x-line kr 1000 20000 10 remove-synth))) + (audition (out 0 (mul (lfclip-noise ar f) 0.1)))) + +(let ((f (x-line kr 1000 20000 10 remove-synth))) + (audition (out 0 (mul (lfdclip-noise ar f) 0.1)))) diff --git a/rsc3/examples/ugen/noise/lfd-noise0.help.scm b/rsc3/examples/ugen/noise/lfd-noise0.help.scm new file mode 100644 index 0000000..2855a4d --- /dev/null +++ b/rsc3/examples/ugen/noise/lfd-noise0.help.scm @@ -0,0 +1,49 @@ +;; (lfd-noise0 rate freq) +;; (lfd-noise1 rate freq) +;; (lfd-noise3 rate freq) + +;; lfd-noise0: Dynamic step noise. Like lf-noise0, it generates random +;; values at a rate given by the freq argument, with two differences: +;; no time quantization, and fast recovery from low freq values. + +;; lfd-noise1: Dynamic ramp noise. Like lf-noise1, it generates linearly +;; interpolated random values at a rate given by the freq argument, +;; with two differences: no time quantization, and fast recovery from +;; low freq values. + +;; lfd-noise3: Dynamic cubic noise. Like Lf-Noise3, it generates +;; linearly interpolated random values at a rate given by the freq +;; argument, with two differences: no time quantization, and fast +;; recovery from low freq values. + +;; (lf-noise0,1,3 quantize to the nearest integer division of the +;; samplerate, and they poll the freq argument only when scheduled, +;; and thus seem to hang when freqs get very low). + +;; If you don't need very high or very low freqs, or use fixed freqs, +;; lf-noise0,1,3 is more efficient. + +;; Try wiggling mouse quickly; Lf-Noise frequently seems stuck, +;; LFDNoise changes smoothly. + +(audition + (out 0 (mul (lf-noise0 ar (mouse-x kr 0.1 1000 1 0.1)) 0.1))) + +(audition + (out 0 (mul (lfd-noise0 ar (mouse-x kr 0.1 1000 1 0.1)) 0.1))) + +;; silent for 2 secs before going up in freq + +(audition + (out 0 (mul (lf-noise0 ar (x-line kr 0.5 10000 3 remove-synth)) 0.1))) + +(audition + (out 0 (mul (lfd-noise0 ar (x-line kr 0.5 10000 3 remove-synth)) 0.1))) + +;; lf-noise quantizes time steps at high freqs, lfd-noise does not: + +(audition + (out 0 (mul (lf-noise0 ar (x-line kr 1000 20000 10 remove-synth)) 0.1))) + +(audition + (out 0 (mul (lfd-noise0 ar (x-line kr 1000 20000 10 remove-synth)) 0.1))) diff --git a/rsc3/examples/ugen/noise/lfd-noise1.help.scm b/rsc3/examples/ugen/noise/lfd-noise1.help.scm new file mode 100644 index 0000000..a6abbd9 --- /dev/null +++ b/rsc3/examples/ugen/noise/lfd-noise1.help.scm @@ -0,0 +1,2 @@ +;; See lfd-noise0 + diff --git a/rsc3/examples/ugen/noise/lfd-noise3.help.scm b/rsc3/examples/ugen/noise/lfd-noise3.help.scm new file mode 100644 index 0000000..dd2da43 --- /dev/null +++ b/rsc3/examples/ugen/noise/lfd-noise3.help.scm @@ -0,0 +1 @@ +;; See lfd-noise0 diff --git a/rsc3/examples/ugen/noise/lin-rand.help.scm b/rsc3/examples/ugen/noise/lin-rand.help.scm new file mode 100644 index 0000000..5bbd2b2 --- /dev/null +++ b/rsc3/examples/ugen/noise/lin-rand.help.scm @@ -0,0 +1,9 @@ +;; (lin-rand lo hi minmax) + +;; Generates a single random float value in linear distribution from +;; lo to hi, skewed towards lo if minmax < 0, otherwise skewed towards +;; hi. + +(let ((f (lin-rand 200 10000 (mce2 -1 1))) + (a (line kr 0.4 0 0.01 remove-synth))) + (audition (out 0 (mul (f-sin-osc ar f 0) a)))) diff --git a/rsc3/examples/ugen/noise/mantissa-mask.help.scm b/rsc3/examples/ugen/noise/mantissa-mask.help.scm new file mode 100644 index 0000000..a64ac41 --- /dev/null +++ b/rsc3/examples/ugen/noise/mantissa-mask.help.scm @@ -0,0 +1,11 @@ +;; (mantissa-mask in bits) + +;; Masks off bits in the mantissa of the floating point sample +;; value. This introduces a quantization noise, but is less severe +;; than linearly quantizing the signal. + +;; in - input signal +;; bits - the number of mantissa bits to preserve. a number from 0 to 23. + +(let ((s (mul (sin-osc ar (mul-add (sin-osc kr 0.2 0) 400 500) 0) 0.4))) + (audition (out 0 (mantissa-mask s 3)))) diff --git a/rsc3/examples/ugen/noise/n-rand.help.scm b/rsc3/examples/ugen/noise/n-rand.help.scm new file mode 100644 index 0000000..bf6aad4 --- /dev/null +++ b/rsc3/examples/ugen/noise/n-rand.help.scm @@ -0,0 +1,13 @@ +;; (n-rand lo hi n) + +;; Generates a single random float value in a sum of `n' uniform +;; distributions from `lo' to `hi'. + +;; n = 1 : uniform distribution - same as rand +;; n = 2 : triangular distribution +;; n = 3 : smooth hump +;; as n increases, distribution converges towards gaussian + +(let ((f (mul (n-rand 1200 4000 2) (mce2 2 5))) + (a (line kr 0.2 0 0.01 remove-synth))) + (audition (out 0 (mul (f-sin-osc ar f 0) a)))) diff --git a/rsc3/examples/ugen/noise/pink-noise.help.scm b/rsc3/examples/ugen/noise/pink-noise.help.scm new file mode 100644 index 0000000..06af6cb --- /dev/null +++ b/rsc3/examples/ugen/noise/pink-noise.help.scm @@ -0,0 +1,7 @@ +;; (pink-noise rate) + +;; Generates noise whose spectrum falls off in power by 3 dB per +;; octave. This gives equal power over the span of each octave. This +;; version gives 8 octaves of pink noise. + +(audition (out 0 (mul (pink-noise ar) 0.25))) diff --git a/rsc3/examples/ugen/noise/rand-id.help.scm b/rsc3/examples/ugen/noise/rand-id.help.scm new file mode 100644 index 0000000..c661126 --- /dev/null +++ b/rsc3/examples/ugen/noise/rand-id.help.scm @@ -0,0 +1,50 @@ +;; (rand-id rate id) + +;; Choose which random number generator to use for this synth. All +;; synths that use the same generator reproduce the same sequence of +;; numbers when the same seed is set again. + +;; See also: rand-seed. + +;; Graphs to generate noise in the context of a given RNG and to reset +;; a specified RNG. + +(with-sc3 + (lambda (fd) + (send-synth + fd "r" + (letc ((bus 0) + (id 1)) + (mrg2 (rand-id ir id) + (out bus (add (mul (white-noise ar) 0.05) + (dust2 ar 70)))))) + (send-synth + fd "s" + (letc ((seed 1910) (id 1)) + (mrg2 (rand-id kr id) + (rand-seed kr + (impulse kr (mul-add (f-sin-osc kr 0.2 0) 10 11) 0) + seed)))))) + +;; Start two noise synths on left and right channel with a different randgen id + +(with-sc3 + (lambda (fd) + (send fd (s-new2 "r" 1001 1 1 "bus" 0 "id" 1)) + (send fd (s-new2 "r" 1002 1 1 "bus" 1 "id" 2)))) + +;; Reset the seed of randgen 1 + +(with-sc3 (lambda (fd) (send fd (s-new1 "s" 1003 1 1 "id" 1)))) + +;; Change the target RNG with ID 2, ie. effect right channel. + +(with-sc3 (lambda (fd) (send fd (n-set1 1003 "id" 2)))) + +;; free noise nodes. + +(with-sc3 + (lambda (fd) + (send fd (n-free1 1001)) + (send fd (n-free1 1002)) + (send fd (n-free1 1003)))) diff --git a/rsc3/examples/ugen/noise/rand-seed.help.scm b/rsc3/examples/ugen/noise/rand-seed.help.scm new file mode 100644 index 0000000..d43418d --- /dev/null +++ b/rsc3/examples/ugen/noise/rand-seed.help.scm @@ -0,0 +1,19 @@ +;; (rand-seed rate trig seed) + +;; When the trigger signal changes from nonpositive to positve, the +;; synth's random generator seed is reset to the given value. All +;; other synths that use the same random number generator reproduce +;; the same sequence of numbers again. + +;; See also: randID. + +;; Start a noise patch + +(let ((n (add (mul (white-noise ar) (mce2 0.05 0.05)) (dust2 ar (mce2 70 70)))) + (f (mul-add (lf-noise1 kr 3) 5500 6000))) + (audition (out 0 (add (resonz (mul n 5) f 0.5) (mul n 0.5))))) + +;; Reset the seed at a variable rate. + +(audition (mrg2 (rand-seed kr (impulse kr (mouse-x kr 0.1 100 0 0.1) 0) 1956) + 0)) diff --git a/rsc3/examples/ugen/noise/rand.help.scm b/rsc3/examples/ugen/noise/rand.help.scm new file mode 100644 index 0000000..86b8e9e --- /dev/null +++ b/rsc3/examples/ugen/noise/rand.help.scm @@ -0,0 +1,10 @@ +;; (rand lo hi) + +;; Generates a single random value in uniform distribution from lo to +;; hi. It generates this when the SynthDef first starts playing, and +;; remains fixed for the duration of the synth's existence. + +(let* ((a (line kr 0.2 0 0.1 2)) + (p (rand -1 1)) + (s (mul (f-sin-osc ar (rand 200 1200) 0) a))) + (audition (out 0 (pan2 s p 1)))) diff --git a/rsc3/examples/ugen/noise/t-exp-rand.help.scm b/rsc3/examples/ugen/noise/t-exp-rand.help.scm new file mode 100644 index 0000000..0e2b8f0 --- /dev/null +++ b/rsc3/examples/ugen/noise/t-exp-rand.help.scm @@ -0,0 +1,10 @@ +;; (t-exp-rand lo hi trig) + +;; Generates a random float value in exponential distribution from lo +;; to hi each time the trig signal changes from nonpositive to +;; positive values lo and hi must both have the same sign and be +;; non-zero. + +(let* ((t (dust kr 10)) + (f (t-exp-rand 300 3000 t))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) diff --git a/rsc3/examples/ugen/noise/t-rand.help.scm b/rsc3/examples/ugen/noise/t-rand.help.scm new file mode 100644 index 0000000..40962d7 --- /dev/null +++ b/rsc3/examples/ugen/noise/t-rand.help.scm @@ -0,0 +1,8 @@ +;; (t-rand lo hi trig) + +;; Generates a random float value in uniform distribution from lo each +;; time the trig signal changes from nonpositive to positive values + +(let* ((t (dust kr (mce2 5 12))) + (f (t-rand (mce2 200 1600) (mce2 500 3000) t))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) diff --git a/rsc3/examples/ugen/noise/ti-rand.help.scm b/rsc3/examples/ugen/noise/ti-rand.help.scm new file mode 100644 index 0000000..5d7d59b --- /dev/null +++ b/rsc3/examples/ugen/noise/ti-rand.help.scm @@ -0,0 +1,11 @@ +;; (ti-rand lo hi trig) + +;; Generates a random integer value in uniform distribution from lo to +;; hi each time the trig signal changes from nonpositive to positive +;; values + +(let ((p (ti-rand -1 1 (dust kr 10)))) + (audition (out 0 (pan2 (pink-noise ar) p 0.2)))) + +(let ((f (mul-add (ti-rand 4 12 (dust kr 10)) 150 (mce2 0 1)))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/noise/white-noise.help.scm b/rsc3/examples/ugen/noise/white-noise.help.scm new file mode 100644 index 0000000..7c8bec2 --- /dev/null +++ b/rsc3/examples/ugen/noise/white-noise.help.scm @@ -0,0 +1,13 @@ +;; (white-noise rate) + +;; Generates noise whose spectrum has equal power at all frequencies. + +(audition (out 0 (mul (white-noise ar) 0.15))) + +;; Noise generators constructors are unique, to share noise UGens +;; values must be explictly stored and reused. + +(audition (out 0 (mul (sub (white-noise ar) (white-noise ar)) 0.15))) + +(let ((n (white-noise ar))) + (audition (out 0 (sub n n)))) diff --git a/rsc3/examples/ugen/oscillators/blip.help.scm b/rsc3/examples/ugen/oscillators/blip.help.scm new file mode 100644 index 0000000..272db61 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/blip.help.scm @@ -0,0 +1,11 @@ +(import (rsc3)) + +(audition (out 0 (mul (blip ar 440 200) 0.15))) + +;; Modulate frequency +(let ((f (x-line kr 20000 200 6 remove-synth))) + (audition (out 0 (mul (blip ar f 100) 0.2)))) + +;; Modulate number of harmonics. +(let ((h (line kr 1 100 20 remove-synth))) + (audition (out 0 (mul (blip ar 200 h) 0.2)))) diff --git a/rsc3/examples/ugen/oscillators/buf-wr.help.scm b/rsc3/examples/ugen/oscillators/buf-wr.help.scm new file mode 100644 index 0000000..02490bf --- /dev/null +++ b/rsc3/examples/ugen/oscillators/buf-wr.help.scm @@ -0,0 +1,29 @@ +(import (sosc) (rsc3)) + +(let ((a (letc ((r 1)) + (let* ((r* (mul (buf-rate-scale kr 0) r)) + (p (phasor ar 0 r* 0 (buf-frames kr 0) 0)) + (f (mul-add (lf-noise1 kr 2) 300 400)) + (i (mul (sin-osc ar f 0) 0.1))) + (mrg2 (buf-wr 0 p 1 i) + (out 0 0.0))))) + (b (letc ((r 1)) + (let* ((r* (mul (buf-rate-scale kr 0) r)) + (p (phasor ar 0 r* 0 (buf-frames kr 0) 0))) + (out 0 (buf-rd 1 ar 0 p 1 2)))))) + (with-sc3 + (lambda (fd) + (async fd (b-alloc 0 (* 44100 2) 1)) + (send-synth fd "a" a) + (send-synth fd "b" b) + (send fd (s-new0 "a" 1001 1 0)) + (send fd (s-new0 "b" 1002 1 0))))) + +(define (do-send m) + (with-sc3 (lambda (fd) (send fd m)))) + +(do-send (n-set1 1002 "r" 5)) + +(do-send (n-set1 1001 "r" (random 0 2))) + +(do-send (n-set1 1002 "r" 2)) diff --git a/rsc3/examples/ugen/oscillators/c-osc.help.scm b/rsc3/examples/ugen/oscillators/c-osc.help.scm new file mode 100644 index 0000000..3c2a00b --- /dev/null +++ b/rsc3/examples/ugen/oscillators/c-osc.help.scm @@ -0,0 +1,13 @@ +(import (rsc3)) + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 512 1)) + (async fd (b-gen1 10 "sine1" (list (+ 1 2 4) 1 1/2 1/3 1/4 1/5 1/6 1/7 1/8 1/9 1/10))))) + +(audition (out 0 (mul (c-osc ar 10 200 0.7) 0.25))) + +(audition (out 0 (mul (c-osc ar 10 200 (mouse-x* kr 0 4 0 0.1)) 0.25))) + +;; Compare with: +(audition (out 0 (mul (osc ar 10 200 0.0) 0.25))) diff --git a/rsc3/examples/ugen/oscillators/f-sin-osc.help.scm b/rsc3/examples/ugen/oscillators/f-sin-osc.help.scm new file mode 100644 index 0000000..b9b354f --- /dev/null +++ b/rsc3/examples/ugen/oscillators/f-sin-osc.help.scm @@ -0,0 +1,14 @@ +;; SC2: Note extra iphase argument. + +(import (rsc3)) + +(audition (out 0 (mul (f-sin-osc ar (mce2 440 550) 0) 0.05))) + +(let ((f (x-line kr 200 4000 1 remove-synth))) + (audition (out 0 (mul (f-sin-osc ar f 0) 0.25)))) + +;; Loses amplitude towards the end +(let ((f (mul-add (f-sin-osc ar (x-line kr 4 401 8 remove-synth) 0) + 200 + 800))) + (audition (out 0 (mul (f-sin-osc ar f 0) 0.25)))) diff --git a/rsc3/examples/ugen/oscillators/formant.help.scm b/rsc3/examples/ugen/oscillators/formant.help.scm new file mode 100644 index 0000000..ca80e40 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/formant.help.scm @@ -0,0 +1,16 @@ +(import (rsc3)) + +;; Modulate fundamental frequency, formant frequency stays constant. +(audition + (let ((f (x-line kr 400 1000 8 remove-synth))) + (out 0 (mul (formant ar f 2000 800) 0.125)))) + +;; Modulate formant frequency, fundamental frequency stays constant. +(audition + (let ((f (x-line kr 400 4000 8 remove-synth))) + (out 0 (mul (formant ar (mce2 200 300) f 200) 0.125)))) + +;; Modulate width frequency, other frequencies stay constant. +(audition + (let ((w (x-line kr 800 8000 8 remove-synth))) + (out 0 (mul (formant ar 400 2000 w) 0.125)))) diff --git a/rsc3/examples/ugen/oscillators/gendy1.help.scm b/rsc3/examples/ugen/oscillators/gendy1.help.scm new file mode 100644 index 0000000..7dd0ebf --- /dev/null +++ b/rsc3/examples/ugen/oscillators/gendy1.help.scm @@ -0,0 +1,111 @@ +(import (rsc3)) + +;; sclang defaults +(audition (out 0 (pan2 (gendy1 ar 1 1 1 1 440 660 0.5 0.5 12 12) 0 0.15))) + +;; Wandering bass +(audition (out 0 (pan2 (gendy1 ar 1 1 1.0 1.0 30 100 0.3 0.05 5 5) 0 0.15))) + +;; Play me +(let* ((x (mouse-x* kr 100 1000 1 0.1)) + (g (gendy1 ar 2 3 1 1 20 x 0.5 0.0 40 40))) + (audition (out 0 (pan2 (mul (rlpf g 500 0.3) 0.2) 0.0 0.25)))) + +;; Scream! +(let ((x (mouse-x kr 220 440 1 0.1)) + (y (mouse-y kr 0.0 1.0 0 0.1))) + (audition (out 0 (pan2 (gendy1 ar 2 3 1 1 x (mul 8 x) y y 7 7) 0.0 0.3)))) + +;; 1 CP = random noise +(audition (out 0 (pan2 (gendy1 ar 1 1 1 1 440 660 0.5 0.5 1 1) 0 0.15))) + +;; 2 CPs = an oscillator +(audition (out 0 (pan2 (gendy1 ar 1 1 1 1 440 660 0.5 0.5 2 2) 0 0.15))) + +;; Used as an LFO +(let* ((ad (mul-add (sin-osc kr 0.1 0) 0.49 0.51)) + (dd (mul-add (sin-osc kr 0.13 0) 0.49 0.51)) + (as (mul-add (sin-osc kr 0.17 0) 0.49 0.51)) + (ds (mul-add (sin-osc kr 0.19 0) 0.49 0.51)) + (g (gendy1 kr 2 4 ad dd 3.4 3.5 as ds 10 10))) + (audition (out 0 (pan2 (sin-osc ar (mul-add g 50 350) 0) 0.0 0.3)))) + +;; Wasp +(let ((ad (mul-add (sin-osc kr 0.1 0) 0.1 0.9))) + (audition (out 0 (pan2 (gendy1 ar 0 0 ad 1.0 50 1000 1 0.005 12 12) 0.0 0.2)))) + +;; Modulate distributions. Change of pitch as distributions change +;; the duration structure and spectrum +(let* ((x (mouse-x* kr 0 7 0 0.1)) + (y (mouse-y* kr 0 7 0 0.1)) + (g (gendy1 ar x y 1 1 440 660 0.5 0.5 12 12))) + (audition (out 0 (pan2 g 0 0.2)))) + +;; Modulate number of CPs. +(let* ((x (mouse-x* kr 1 13 0 0.1)) + (g (gendy1 ar 1 1 1 1 440 660 0.5 0.5 12 x))) + (audition (out 0 (pan2 g 0 0.2)))) + +;; Self modulation. +(let* ((x (mouse-x* kr 1 13 0 0.1)) + (y (mouse-y* kr 0.1 10 0 0.1)) + (g0 (gendy1 kr 5 4 0.3 0.7 0.1 y 1.0 1.0 5 5)) + (g1 (gendy1 ar 1 1 1 1 440 (mul-add g0 500 600) 0.5 0.5 12 x))) + (audition (out 0 (pan2 g1 0.0 0.2)))) + +;; Use SINUS to track any oscillator and take CP positions from it use +;; adparam and ddparam as the inputs to sample. +(let* ((p (lf-pulse kr 100 0 0.4)) + (s (mul (sin-osc kr 30 0) 0.5)) + (g (gendy1 ar 6 6 p s 440 660 0.5 0.5 12 12))) + (audition (out 0 (pan2 g 0.0 0.2)))) + +;; Near the corners are interesting. +(let* ((x (mouse-x* kr 0 200 0 0.1)) + (y (mouse-y* kr 0 200 0 0.1)) + (p (lf-pulse kr x 0 0.4)) + (s (mul (sin-osc kr y 0) 0.5)) + (g (gendy1 ar 6 6 p s 440 660 0.5 0.5 12 12))) + (audition (out 0 (pan2 g 0.0 0.2)))) + +;; Texture +(let* + ((o (let* ((f (rand 130.0 160.3)) + (ad (mul-add (sin-osc kr 0.1 0) 0.49 0.51)) + (dd (mul-add (sin-osc kr 0.13 0) 0.49 0.51)) + (as (mul-add (sin-osc kr 0.17 0) 0.49 0.51)) + (ds (mul-add (sin-osc kr 0.19 0) 0.49 0.51)) + (g (gendy1 ar (rand 0 6) (rand 0 6) ad dd f f as ds 12 12))) + (pan2 (sin-osc ar (mul-add g 200 400) 0) + (rand -1 1) + 0.1))) + (x (mix-fill 10 (lambda (_) o)))) + (audition (out 0 x))) + +;; Try durscale 10.0 and 0.0 too. +(let* ((x (mouse-x* kr 10 700 0 0.1)) + (y (mouse-y* kr 50 1000 0 0.1)) + (g (gendy1 ar 2 3 1 1 1 x 0.5 0.1 10 10))) + (audition (out 0 (pan2 (comb-n (resonz g y 0.1) 0.1 0.1 5) 0.0 0.6)))) + +;; Overkill +(define (overkill i) + (mix-fill + i + (lambda (_) + (let* ((f (rand 50 560.3)) + (n (rand 2 20)) + (k (mul-add (sin-osc kr (exp-rand 0.02 0.2) 0) + (fdiv n 2) + (fdiv n 2))) + (g (gendy1 ar + (rand 0 6) (rand 0 6) (rand 0 1) (rand 0 1) f f + (rand 0 1) (rand 0 1) n k))) + (pan2 g (rand -1 1) (fdiv 0.5 (sqrt i))))))) + +(audition (out 0 (overkill 10))) + +;; Another traffic moment +(let ((x (mouse-x* kr 100 2000 0 0.1)) + (y (mouse-y* kr 0.01 1.0 0 0.1))) + (audition (out 0 (resonz (overkill 10) x y)))) diff --git a/rsc3/examples/ugen/oscillators/impulse.help.scm b/rsc3/examples/ugen/oscillators/impulse.help.scm new file mode 100644 index 0000000..2cf1627 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/impulse.help.scm @@ -0,0 +1,10 @@ +(import (rsc3)) + +(audition (out 0 (mul (impulse ar 800 0) 0.1))) + +(let ((f (x-line kr 800 10 5 remove-synth))) + (audition (out 0 (mul (impulse ar f 0.0) 0.5)))) + +(let ((f (mouse-y* kr 4 8 0 0.1)) + (p (mouse-x* kr 0 1 0 0.1))) + (audition (out 0 (mul (impulse ar f (mce2 0 p)) 0.2)))) diff --git a/rsc3/examples/ugen/oscillators/index.help.scm b/rsc3/examples/ugen/oscillators/index.help.scm new file mode 100644 index 0000000..4ecf3b9 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/index.help.scm @@ -0,0 +1,16 @@ +(import (sosc) (rsc3)) + +;; Allocate and set values at buffer 10. +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 6 1)) + (send fd (b-setn1 10 0 (list 50 100 200 400 800 1600))))) + +;; Index into the above buffer for frequency values. +(let ((f (mul (index 10 (mul (lf-saw kr 2 3) 4)) (mce2 1 9)))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) + +;; Free buffer +(with-sc3 + (lambda (fd) + (async fd (b-free 10)))) diff --git a/rsc3/examples/ugen/oscillators/klang.help.scm b/rsc3/examples/ugen/oscillators/klang.help.scm new file mode 100644 index 0000000..03d6f1a --- /dev/null +++ b/rsc3/examples/ugen/oscillators/klang.help.scm @@ -0,0 +1,10 @@ +;; (klang rate freqScale freqOffset spec) + +;; Bank of fixed oscillators. The UGen assistant klang.spec can help +;; create the 'spec' entry. Note that the SC3 language reorders the +;; inputs, the rsc3 client does not. + +(let ((d (klang-data '(440 550 660 770 880 990 1000) + '(0.05 0.02 0.07 0.04 0.05 0.02 0.03) + (replicate 7 0)))) + (audition (out 0 (klang ar 1 0 d)))) diff --git a/rsc3/examples/ugen/oscillators/lf-cub.help.scm b/rsc3/examples/ugen/oscillators/lf-cub.help.scm new file mode 100644 index 0000000..776b727 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/lf-cub.help.scm @@ -0,0 +1,37 @@ +;; (lf-cub rate freq iphase) + +;; a sine like shape made of two cubic pieces. smoother than lf-par. + +(let ((f (mul-add (lf-cub kr (mul-add (lf-cub kr 0.2 0) 8 10) 0) 400 800))) + (mul (lf-cub ar f 0) 0.1)) + +(mul (lf-cub ar (mul-add (lf-cub kr 0.2 0) 400 800) 0) 0.1) +(mul (lf-cub ar 800 0) 0.1) +(mul (lf-cub ar (x-line kr 100 8000 30 do-nothing) 0) 0.1) + +;; compare: + +(let ((f (mul-add (lf-par kr (mul-add (lf-par kr 0.2 0) 8 10) 0) 400 800))) + (mul (lf-par ar f 0) 0.1)) + +(mul (lf-par ar (mul-add (lf-par kr 0.2 0) 400 800) 0) 0.1) +(mul (lf-par ar 800 0) 0.1) +(mul (lf-par ar (x-line kr 100 8000 30 do-nothing) 0) 0.1) + +;; compare: + +(let ((f (mul-add (sin-osc kr (mul-add (sin-osc kr 0.2 0) 8 10) 0) 400 800))) + (mul (sin-osc ar f 0) 0.1)) + +(mul (sin-osc ar (mul-add (sin-osc kr 0.2 0) 400 800) 0) 0.1) +(mul (sin-osc ar 800 0) 0.1) +(mul (sin-osc ar (x-line kr 100 8000 30 do-nothing) 0) 0.1) + +;; compare: + +(let ((f (mul-add (lf-tri kr (mul-add (lf-tri kr 0.2 0) 8 10) 0) 400 800))) + (mul (lf-tri ar f 0) 0.1)) + +(mul (lf-tri ar (mul-add (lf-tri kr 0.2 0) 400 800) 0) 0.1) +(mul (lf-tri ar 800 0) 0.1) +(mul (lf-tri ar (x-line kr 100 8000 30 do-nothing) 0) 0.1) diff --git a/rsc3/examples/ugen/oscillators/lf-par.help.scm b/rsc3/examples/ugen/oscillators/lf-par.help.scm new file mode 100644 index 0000000..958c53c --- /dev/null +++ b/rsc3/examples/ugen/oscillators/lf-par.help.scm @@ -0,0 +1,3 @@ +;; See lf-cub. + +;; A sine-like shape made of two parabolas. Has audible odd harmonics. diff --git a/rsc3/examples/ugen/oscillators/lf-pulse.help.scm b/rsc3/examples/ugen/oscillators/lf-pulse.help.scm new file mode 100644 index 0000000..28ec243 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/lf-pulse.help.scm @@ -0,0 +1,12 @@ +;; (lf-pulse rate freq iphase width) + +;; A non-band-limited pulse oscillator. outputs a high value of one +;; and a low value of zero. Note that the iphase argument was not +;; present in SC2. + +;; freq - frequency in Hertz +;; iphase - initial phase offset in cycles ( 0..1 ) +;; width - pulse width duty cycle from zero to one. + +(let ((f (mul-add (lf-pulse kr 3 0 0.3) 200 200))) + (audition (out 0 (mul (lf-pulse ar f 0 0.2) 0.1)))) diff --git a/rsc3/examples/ugen/oscillators/lf-saw.help.scm b/rsc3/examples/ugen/oscillators/lf-saw.help.scm new file mode 100644 index 0000000..7438511 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/lf-saw.help.scm @@ -0,0 +1,14 @@ +;; (lf-saw rate freq iphase) + +;; sawtooth oscillator. A non-band-limited sawtooth +;; oscillator. output ranges from -1 to +1. + +;; freq - frequency in Hertz +;; iphase - phase in radians + +(audition (out 0 (mul (lf-saw ar 500 1) 0.1))) + +;; Used as both oscillator and LFO. + +(let ((f (mul-add (lf-saw kr 4 0) 400 400))) + (audition (out 0 (mul (lf-saw ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/oscillators/lf-tri.help.scm b/rsc3/examples/ugen/oscillators/lf-tri.help.scm new file mode 100644 index 0000000..4aca2a4 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/lf-tri.help.scm @@ -0,0 +1,11 @@ +;; (lf-tri rate freq iphase) + +;; A non-band-limited triangular waveform oscillator. output ranges +;; from -1 to +1. + +(audition (out 0 (mul (lf-tri ar 500 1) 0.1))) + +;; Used as both oscillator and LFO. + +(let ((f (mul-add (lf-tri kr 4 0) 400 400))) + (audition (out 0 (mul (lf-tri ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/oscillators/osc-n.help.scm b/rsc3/examples/ugen/oscillators/osc-n.help.scm new file mode 100644 index 0000000..5a3059e --- /dev/null +++ b/rsc3/examples/ugen/oscillators/osc-n.help.scm @@ -0,0 +1,10 @@ +;; (osc-n rate bufnum freq phase) + +;; Noninterpolating wavetable lookup oscillator with frequency and +;; phase modulation inputs. It is usually better to use the +;; interpolating oscillator. + +;; The buffer size must be a power of 2. The buffer should NOT be +;; filled using Wavetable format (b_gen commands should set wavetable +;; flag to false. + diff --git a/rsc3/examples/ugen/oscillators/osc.help.scm b/rsc3/examples/ugen/oscillators/osc.help.scm new file mode 100644 index 0000000..710a89b --- /dev/null +++ b/rsc3/examples/ugen/oscillators/osc.help.scm @@ -0,0 +1,48 @@ +;; (osc rate bufnum freq phase) + +;; linear interpolating wavetable lookup oscillator with frequency and +;; phase modulation inputs. + +;; This oscillator requires a buffer to be filled with a wavetable +;; format signal. This preprocesses the Signal into a form which can +;; be used efficiently by the oscillator. The buffer size must be a +;; power of 2. + +;; This can be acheived by creating a Buffer object and sending it one +;; of the "b_gen" messages ( sine1, sine2, sine3 ) with the wavetable +;; flag set to true. + +;; Note about wavetables: oscN requires the b_gen sine1 wavetable flag +;; to be OFF. osc requires the b_gen sine1 wavetable flag to be ON. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 512 1)) + (async fd (b-gen1 10 "sine1" (list (+ 1 2 4) 1 1/2 1/3 1/4 1/5))))) + +(audition (out 0 (mul (osc ar 10 220 0) 0.1))) + +;; Modulate freq + +(let ((f (x-line kr 2000 200 1 remove-synth))) + (audition (out 0 (mul (osc ar 10 f 0) 0.5)))) + +;; Modulate freq + +(let* ((f1 (x-line kr 1 1000 9 remove-synth)) + (f2 (mul-add (osc ar 10 f1 0) 200 800))) + (audition (out 0 (mul (osc ar 10 f2 0) 0.25)))) + +;; Modulate phase + +(let* ((f (x-line kr 20 8000 10 remove-synth)) + (p (mul (osc ar 10 f 0) (* 2 pi)))) + (audition (out 0 (mul (osc ar 10 800 p) 0.25)))) + +;; Change the buffer while its playing + +(audition (out 0 (mul (osc ar 10 220 0) 0.1))) + +(with-sc3 + (lambda (fd) + (async fd (b-gen1 10 "sine1" (list (+ 1 2 4) 1 (random 0 1) 1/4))))) diff --git a/rsc3/examples/ugen/oscillators/pm-osc.help.scm b/rsc3/examples/ugen/oscillators/pm-osc.help.scm new file mode 100644 index 0000000..c63e2f3 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/pm-osc.help.scm @@ -0,0 +1,20 @@ +;; (pm-osc rate carfreq modfreq index modphase) + +;; Phase modulation oscillator pair. + +;; carfreq - carrier frequency in cycles per second. +;; modfreq - modulator frequency in cycles per second. +;; index - modulation index in radians. +;; modphase - a modulation input for the modulator's phase in radians + +(let* ((f (line kr 600 900 5 remove-synth)) + (o (mul (pm-osc ar f 600 3 0) 0.1))) + (audition (out 0 o))) + +(let* ((mf (line kr 600 900 5 remove-synth)) + (o (mul (pm-osc ar 300 mf 3 0) 0.1))) + (audition (out 0 o))) + +(let* ((i (line kr 0 20 8 remove-synth)) + (o (mul (pm-osc ar 300 550 i 0) 0.1))) + (audition (out 0 o))) diff --git a/rsc3/examples/ugen/oscillators/pulse.help.scm b/rsc3/examples/ugen/oscillators/pulse.help.scm new file mode 100644 index 0000000..0948a8b --- /dev/null +++ b/rsc3/examples/ugen/oscillators/pulse.help.scm @@ -0,0 +1,22 @@ +;; (pulse rate freq width) + +;; Bandlimited pulse wave generator. + +;; Modulate frequency + +(audition + (let ((f (x-line kr 40 4000 6 remove-synth))) + (out 0 (mul (pulse ar f 0.1) 0.2)))) + +;; modulate pulse width + +(audition + (let ((w (line kr 0.01 0.99 8 remove-synth))) + (out 0 (mul (pulse ar 200 w) 0.2)))) + +;; two band limited square waves thru a resonant low pass filter + +(audition + (out 0 (rlpf (mul (pulse ar (mce2 100 250) 0.5) 0.1) + (x-line kr 8000 400 5 remove-synth) + 0.05))) diff --git a/rsc3/examples/ugen/oscillators/saw.help.scm b/rsc3/examples/ugen/oscillators/saw.help.scm new file mode 100644 index 0000000..7c9944a --- /dev/null +++ b/rsc3/examples/ugen/oscillators/saw.help.scm @@ -0,0 +1,11 @@ +;; (saw rate freq) + +;; Band limited sawtooth wave generator. + +(let ((f (x-line kr 40 4000 6 do-nothing))) + (audition (out 0 (mul (saw ar f) 0.2)))) + +;; Two band limited sawtooth waves thru a resonant low pass filter + +(let ((f (x-line kr 8000 400 5 do-nothing))) + (audition (out 0 (rlpf (mul (saw ar (mce2 100 250)) 0.1) f 0.05)))) diff --git a/rsc3/examples/ugen/oscillators/select.help.scm b/rsc3/examples/ugen/oscillators/select.help.scm new file mode 100644 index 0000000..9c37433 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/select.help.scm @@ -0,0 +1,22 @@ +;; (select which array) + +;; The output is selected from an array of inputs. + +(audition + (let* ((a (mce3 (sin-osc ar 440 0) (saw ar 440) (pulse ar 440 0.1))) + (cycle 3/2) + (w (mul-add (lf-saw kr 1 0) cycle cycle))) + (out 0 (mul (select w a) 0.2)))) + +;; Note: all the ugens are continously running. This may not be the +;; most efficient way if each input is cpu-expensive. + +;; Here used as a sequencer: + +(audition + (let* ((n 32) + (a (make-mce (map (compose midi-cps u:floor) + (replicate-m n (rand 30 80))))) + (cycle (/ n 2)) + (w (mul-add (lf-saw kr 1/2 0) cycle cycle))) + (out 0 (mul (saw ar (select w a)) 0.2)))) diff --git a/rsc3/examples/ugen/oscillators/shaper.help.scm b/rsc3/examples/ugen/oscillators/shaper.help.scm new file mode 100644 index 0000000..a0c0848 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/shaper.help.scm @@ -0,0 +1,18 @@ +;; (shaper bufnum in) + +;; Wave shaper. Performs waveshaping on the input signal by indexing +;; into the table. + +;; bufnum - the number of a buffer filled in wavetable format +;; containing the transfer function. +;; in - the input signal. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc 10 512 1)) + (async fd (b-gen1 10 "cheby" (list 0 1 0 1 1 0 1))))) + +(audition + (let* ((a (line kr 0 1 6 remove-synth)) + (s (mul (sin-osc ar 300 0) a))) + (out 0 (mul (shaper 10 s) 0.5)))) diff --git a/rsc3/examples/ugen/oscillators/sin-osc.help.scm b/rsc3/examples/ugen/oscillators/sin-osc.help.scm new file mode 100644 index 0000000..82977d7 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/sin-osc.help.scm @@ -0,0 +1,26 @@ +;; (sin-osc rate freq phase) + +;; interpolating sine wavetable oscillator. This is the same as osc +;; except that the table is a sine table of 8192 entries. + +;; freq - frequency in Hertz +;; phase - phase offset or modulator in radians + +(audition (out 0 (mul (sin-osc ar 440 0) (mce2 0.15 0.25)))) + +;; Modulate freq + +(let ((f (x-line kr 2000 200 1 remove-synth))) + (audition (out 0 (mul (sin-osc ar f 0) 0.5)))) + +;; Modulate freq + +(let* ((f1 (x-line kr 1 1000 9 remove-synth)) + (f2 (mul-add (sin-osc ar f1 0) 200 800))) + (audition (out 0 (mul (sin-osc ar f2 0) 0.25)))) + +;; Modulate phase + +(let* ((f (x-line kr 20 8000 10 remove-synth)) + (p (mul (sin-osc ar f 0) (* pi 2)))) + (audition (out 0 (mul (sin-osc ar 800 p) 0.25)))) diff --git a/rsc3/examples/ugen/oscillators/sync-saw.help.scm b/rsc3/examples/ugen/oscillators/sync-saw.help.scm new file mode 100644 index 0000000..2426e3b --- /dev/null +++ b/rsc3/examples/ugen/oscillators/sync-saw.help.scm @@ -0,0 +1,14 @@ +;; (sync-saw rate syncFreq sawFreq) + +;; A sawtooth wave that is hard synched to a fundamental pitch. This +;; produces an effect similar to moving formants or pulse width +;; modulation. The sawtooth oscillator has its phase reset when the +;; sync oscillator completes a cycle. This is not a band limited +;; waveform, so it may alias. + +;; The frequency of the slave synched sawtooth wave should always be +;; greater than the syncFreq. + +(audition + (let ((f (line kr 100 800 12 remove-synth))) + (out 0 (mul (sync-saw ar 100 f) 0.1)))) diff --git a/rsc3/examples/ugen/oscillators/t-choose.help.scm b/rsc3/examples/ugen/oscillators/t-choose.help.scm new file mode 100644 index 0000000..4e39853 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/t-choose.help.scm @@ -0,0 +1,15 @@ +;; (t-choose trig array) + +;; The output is selected randomly on recieving a trigger from an +;; array of inputs. t-choose is a composite of ti-rand and select. + +(audition + (let* ((t (dust ar (mouse-x kr 1 1000 1 0.1))) + (f (midi-cps (ti-rand 48 60 t))) + (a (mce3 (sin-osc ar f 0) + (saw ar (mul f 2)) + (pulse ar (mul f 0.5) 0.1)))) + (out 0 (mul (t-choose t a) 0.1)))) + +;; Note: all the ugens are continously running. This may not be the +;; most efficient way if each input is cpu-expensive. diff --git a/rsc3/examples/ugen/oscillators/t-grains.help.scm b/rsc3/examples/ugen/oscillators/t-grains.help.scm new file mode 100644 index 0000000..bcfe361 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/t-grains.help.scm @@ -0,0 +1,79 @@ +;; (t-grains numChannels trigger bufnum rate centerPos dur pan amp interp) + +;; Buffer granulator. triggers generate grains from a buffer. Each +;; grain has a Hanning envelope (sin^2(x) for x from 0 to pi) and is +;; panned between two channels of multiple outputs. + +;; numChannels - number of output channels. + +;; trigger - at each trigger, the following arguments are sampled and +;; used as the arguments of a new grain. A trigger occurs +;; when a signal changes from <= 0 to > 0. If the trigger +;; is audio rate then the grains will start with sample +;; accuracy. + +;; bufnum - the index of the buffer to use. It must be a one channel +;; (mono) buffer. + +;; rate - 1.0 is normal, 2.0 is one octave up, 0.5 is one octave down +;; and -1.0 is backwards normal rate ... etc. Unlike play-buf, +;; the rate is multiplied by BufRate, so you needn't do that +;; yourself. + +;; centerPos - the position in the buffer in seconds at which the +;; grain envelope will reach maximum amplitude. + +;; dur - duration of the grain in seconds. + +;; pan - a value from -1 to 1. Determines where to pan the output in +;; the same manner as pan-az. + +;; amp - amplitude of the grain. + +;; interp - 1, 2, or 4. Determines whether the grain uses (1) no +;; interpolation, (2) linear interpolation, or (4) cubic +;; interpolation. + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 10 "/home/rohan/audio/metal.wav" 0 0)))) + +(audition + (let* ((b 10) + (trate (mouse-y kr 2 200 1 0.1)) + (dur (fdiv 4 trate)) + (t (impulse ar trate 0)) + (i (mouse-x kr 0 (buf-dur kr b) 0 0.1))) + (out 0 (t-grains 2 t b 1 i dur 0 0.1 2)))) + +(audition + (let* ((b 10) + (trate (mouse-y kr 8 120 1 0.1)) + (dur (fdiv 12 trate)) + (clk (impulse ar trate 0)) + (x (mouse-x kr 0 (buf-dur kr b) 0 0.1)) + (pos (add x (t-rand 0 0.01 clk))) + (pan (mul (white-noise kr) 0.6))) + (out 0 (t-grains 2 clk b 1 pos dur pan 0.1 2)))) + +(audition + (let* ((b 10) + (trate (mouse-y kr 8 120 1 0.1)) + (dur (fdiv 4 trate)) + (clk (dust ar trate)) + (x (mouse-x kr 0 (buf-dur kr b) 0 0.1)) + (pos (add x (t-rand 0 0.01 clk))) + (pan (mul (white-noise kr) 0.6))) + (out 0 (t-grains 2 clk b 1 pos dur pan 0.1 2)))) + +;; The SC3 ** operator is the ShiftLeft binary UGen. + +(audition + (let* ((b 10) + (trate (mouse-y kr 2 120 1 0.1)) + (dur (fdiv 1.2 trate)) + (clk (impulse ar trate 0)) + (pos (mouse-x kr 0 (buf-dur kr b) 0 0.1)) + (pan (mul (white-noise kr) 0.6)) + (rate (shift-left 1.2 (u:round (mul (white-noise kr) 3) 1)))) + (out 0 (t-grains 2 clk b rate pos dur pan 0.1 2)))) diff --git a/rsc3/examples/ugen/oscillators/tw-choose.help.scm b/rsc3/examples/ugen/oscillators/tw-choose.help.scm new file mode 100644 index 0000000..d0a4243 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/tw-choose.help.scm @@ -0,0 +1,19 @@ +;; (tw-choose trig array weights normalize) + +;; The output is selected randomly on recieving a trigger from an +;; array of inputs. The weights of this choice are determined from +;; the weights array. If normalize is set to 1 the weights are +;; continuously normalized, which means an extra calculation overhead. +;; When using fixed values the normalizeSum method can be used to +;; normalize the values. TWChoose is a composite of TWindex and +;; select + +(let ((a (mce3 (sin-osc ar 220 0) + (saw ar 440) + (pulse ar 110 0.1))) + (t (dust ar (mouse-x kr 1 1000 1 0.1))) + (w (mce3 0.6 0.15 0.05))) + (audition (out 0 (mul (tw-choose t a w 1) 0.1)))) + +;; Note: all the ugens are continously running. This may not be the +;; most efficient way if each input is cpu-expensive. diff --git a/rsc3/examples/ugen/oscillators/tw-index.help.scm b/rsc3/examples/ugen/oscillators/tw-index.help.scm new file mode 100644 index 0000000..d7486d5 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/tw-index.help.scm @@ -0,0 +1,22 @@ +;; (tw-index in normalize array) + +;; triggered windex. When triggered, returns a random index value +;; based on array as a list of probabilities. By default the list of +;; probabilities should sum to 1.0, when the normalize flag is set to +;; 1, the values get normalized by the ugen (less efficient) + +;; Assuming normalized values + +(audition + (let* ((prob (mce3 1/5 2/5 2/5)) + (freq (mce3 400 500 600)) + (f (select (tw-index (impulse kr 6 0) 0.0 prob) freq))) + (out 0 (mul (sin-osc ar f 0) 0.2)))) + +;; Modulating probability values + +(audition + (let* ((t (impulse kr 6 0)) + (a (mce3 1/4 1/2 (mul-add (sin-osc kr 0.3 0) 0.5 0.5))) + (f (select (tw-index t 1.0 a) (mce3 400 500 600)))) + (out 0 (mul (sin-osc ar f 0) 0.2)))) diff --git a/rsc3/examples/ugen/oscillators/v-osc.help.scm b/rsc3/examples/ugen/oscillators/v-osc.help.scm new file mode 100644 index 0000000..e78deb5 --- /dev/null +++ b/rsc3/examples/ugen/oscillators/v-osc.help.scm @@ -0,0 +1,52 @@ +;; (v-osc rate bufpos freq phase) + +;; Variable wavetable oscillator. A wavetable lookup oscillator which +;; can be swept smoothly across wavetables. All the wavetables must be +;; allocated to the same size. Fractional values of table will +;; interpolate between two adjacent tables. + +;; This oscillator requires a buffer to be filled with a wavetable +;; format signal. This preprocesses the Signal into a form which can +;; be used efficiently by the oscillator. The buffer size must be a +;; power of 2. + +;; This can be acheived by creating a Buffer object and sending it one +;; of the "b_gen" messages ( sine1, sine2, sine3 ) with the wavetable +;; flag set to true. + +;; This can also be acheived by creating a Signal object and sending +;; it the 'asWavetable' message, saving it to disk, and having the +;; server load it from there. + +;; Note about wavetables: Vosc requires the b_gen sine1 wavetable flag +;; to be ON. + +;; Allocate and fill tables 0 to 7 [see also Vosc3] + +(with-sc3 + (lambda (fd) + (let* ((square + (lambda (a) (* a a))) + (nth + (lambda (i) + (async fd (b-alloc i 1024 1)) + (let* ((n (expt (+ i 1) 2)) + (a (map1 (lambda (j) (square (/ (- n j) n))) + (enum-from-to 0 (- n 1))))) + (async fd (b-gen1 i "sine1" (cons 7 a))))))) + (for-each nth (enum-from-to 0 7))))) + +;; oscillator at buffers 0 through 7. + +(let ((b (mouse-x kr 0 7 0 0.1)) + (f (mce2 120 121))) + (audition (out 0 (mul (v-osc ar b f 0) 0.3)))) + +;; Reallocate buffers while oscillator is running. + +(with-sc3 + (lambda (fd) + (for-each + (lambda (i) + (async fd (b-gen1 i "sine1" (cons 7 (replicate-m 16 (random 0 1)))))) + (enum-from-to 0 7)))) diff --git a/rsc3/examples/ugen/oscillators/v-osc3.help.scm b/rsc3/examples/ugen/oscillators/v-osc3.help.scm new file mode 100644 index 0000000..7f632ff --- /dev/null +++ b/rsc3/examples/ugen/oscillators/v-osc3.help.scm @@ -0,0 +1,55 @@ +;; (v-osc3 rate bufpos freq1 freq2 freq3) + +;; Three variable wavetable oscillators. + +;; A wavetable lookup oscillator which can be swept smoothly across +;; wavetables. All the wavetables must be allocated to the same +;; size. Fractional values of table will interpolate between two +;; adjacent tables. This unit generator contains three oscillators at +;; different frequencies, mixed together. + +;; This oscillator requires a buffer to be filled with a wavetable +;; format signal. This preprocesses the Signal into a form which can +;; be used efficiently by the oscillator. The buffer size must be a +;; power of 2. + +;; This can be acheived by creating a Buffer object and sending it one +;; of the "b_gen" messages ( sine1, sine2, sine3 ) with the wavetable +;; flag set to true. + +;; Note about wavetables: Vosc3 requires the b_gen sine1 wavetable +;; flag to be ON. + +;; Allocate and fill tables 0 to 7 with a generated list of harmonic +;; amplitudes. + +(with-sc3 + (lambda (fd) + (let* ((square + (lambda (a) (* a a))) + (nth + (lambda (i) + (async fd (b-alloc i 1024 1)) + (let* ((n (expt (+ i 1) 2)) + (a (map (lambda (j) + (square (/ (- n j) n))) + (enum-from-to 0 (- n 1))))) + (async fd (b-gen1 i "sine1" (cons 7 a))))))) + (for-each nth (enum-from-to 0 7))))) + +;; oscillator at buffers 0 through 7. + +(let ((p (mouse-x kr 0 7 0 0.1)) + (f1 (mce2 240 241)) + (f2 (mce2 240.27 241.1)) + (f3 (mce2 240.43 239.71))) + (audition (out 0 (mul (v-osc3 ar p f1 f2 f3) 0.2)))) + +;; Reallocate buffers while oscillator is running. + +(with-sc3 + (lambda (fd) + (for-each + (lambda (i) + (async fd (b-gen1 i "sine1" (cons 7 (replicate-m 16 (random 0 1)))))) + (enum-from-to 0 7)))) diff --git a/rsc3/examples/ugen/oscillators/var-saw.help.scm b/rsc3/examples/ugen/oscillators/var-saw.help.scm new file mode 100644 index 0000000..31b53cf --- /dev/null +++ b/rsc3/examples/ugen/oscillators/var-saw.help.scm @@ -0,0 +1,11 @@ +;; (var-saw rate freq iphasewidth) + +;; Variable duty saw + +;; freq - frequency in Hertz +;; iphase - initial phase offset in cycles ( 0..1 ) +;; width - duty cycle from zero to one. + +(let ((f (mul-add (lf-pulse kr (mce2 3 3.03) 0 0.3) 200 200)) + (w (lin-lin (lf-tri kr 1 0) -1 1 0 1))) + (audition (out 0 (mul (var-saw ar f 0 w) 0.1)))) diff --git a/rsc3/examples/ugen/panners/decode-b2.help.scm b/rsc3/examples/ugen/panners/decode-b2.help.scm new file mode 100644 index 0000000..854b043 --- /dev/null +++ b/rsc3/examples/ugen/panners/decode-b2.help.scm @@ -0,0 +1,27 @@ +;; (decode-b2 numChannels w x y orientation) + +;; 2D Ambisonic B-format decoder. + +;; Decode a two dimensional ambisonic B-format signal to a set of +;; speakers in a regular polygon. The outputs will be in clockwise +;; order. The position of the first speaker is either center or left +;; of center. + +;; The number of output speakers is typically 4 to 8. + +;; The parameters w, x and y are the B-format signals. + +;; The parameter orientation should be zero if the front is a vertex +;; of the polygon. The first speaker will be directly in +;; front. Should be 0.5 if the front bisects a side of the +;; polygon. Then the first speaker will be the one left of +;; center. Default is 0.5. + +(let* ((p (pink-noise ar)) + (encoded (pan-b2 p (mouse-x kr -1 1 0 0.1) 0.1)) + (decoded (decode-b2 4 + (mce-channel encoded 0) + (mce-channel encoded 1) + (mce-channel encoded 2) + 0))) + (audition (out 0 decoded))) diff --git a/rsc3/examples/ugen/panners/lin-pan2.help.scm b/rsc3/examples/ugen/panners/lin-pan2.help.scm new file mode 100644 index 0000000..cd08777 --- /dev/null +++ b/rsc3/examples/ugen/panners/lin-pan2.help.scm @@ -0,0 +1,7 @@ +;; (lin-pan2 in pos level) + +;; Two channel linear pan. See pan2. + +(audition (out 0 (lin-pan2 (pink-noise ar) (f-sin-osc kr 2 0) 0.1))) + +(audition (out 0 (lin-pan2 (f-sin-osc ar 800 0.1) (f-sin-osc kr 3 0) 0.1))) diff --git a/rsc3/examples/ugen/panners/pan-b2.help.scm b/rsc3/examples/ugen/panners/pan-b2.help.scm new file mode 100644 index 0000000..8c9836f --- /dev/null +++ b/rsc3/examples/ugen/panners/pan-b2.help.scm @@ -0,0 +1,15 @@ +;; (pan-b2 in azimuth gain) + +;; 2D Ambisonic B-format panner. Encode a mono signal to two +;; dimensional ambisonic B-format. The azimuth parameter is the +;; position around the circle from -1 to +1. -1 is behind, -0.5 is +;; left, 0 is forward, +0.5 is right, +1 is behind. + +(let* ((p (pink-noise ar)) + (encoded (pan-b2 p (mouse-x kr -1 1 0 0.1) 0.1)) + (decoded (decode-b2 4 + (mce-channel encoded 0) + (mce-channel encoded 1) + (mce-channel encoded 2) + 0.5))) + (audition (out 0 decoded))) diff --git a/rsc3/examples/ugen/panners/pan2.help.scm b/rsc3/examples/ugen/panners/pan2.help.scm new file mode 100644 index 0000000..c8c6a97 --- /dev/null +++ b/rsc3/examples/ugen/panners/pan2.help.scm @@ -0,0 +1,11 @@ +;; (pan2 in pos level) + +;; Two channel equal power panner. The pan position is bipolar, -1 is +;; left, +1 is right. The level is a control rate input. + +(let ((p (f-sin-osc kr 2 0))) + (audition (out 0 (pan2 (pink-noise ar) p 0.3)))) + +(let ((x (mouse-x kr -1 1 0 0.1)) + (y (mouse-y kr 0 1 0 0.1))) + (audition (out 0 (pan2 (pink-noise ar) x y)))) diff --git a/rsc3/examples/ugen/panners/rotate2.help.scm b/rsc3/examples/ugen/panners/rotate2.help.scm new file mode 100644 index 0000000..564521b --- /dev/null +++ b/rsc3/examples/ugen/panners/rotate2.help.scm @@ -0,0 +1,45 @@ +;; (rotate2 x y pos) + +;; Rotate a sound field. rotate2 can be used for rotating an +;; ambisonic B-format sound field around an axis. rotate2 does an +;; equal power rotation so it also works well on stereo sounds. It +;; takes two audio inputs (x, y) and an angle control (pos). It +;; outputs two channels (x, y). + +;; It computes: + +;; xout = cos(angle) * xin + sin(angle) * yin; +;; yout = cos(angle) * yin - sin(angle) * xin; + +;; where angle = pos * pi, so that -1 becomes -pi and +1 becomes +pi. +;; This allows you to use an lf-saw to do continuous rotation around a +;; circle. + +;; The control pos is the angle to rotate around the circle from -1 +;; to +1. -1 is 180 degrees, -0.5 is left, 0 is forward, +0.5 is +;; right, +1 is behind. + +(let* ((p (mul (white-noise ar) 0.05)) + (q (mul (mix (lf-saw ar (make-mce (list 200 200.37 201)) 0)) 0.03)) + (encoded (add (pan-b2 p -0.5 1) (pan-b2 q -0.5 1))) + (rotated (rotate2 (mce-channel encoded 1) + (mce-channel encoded 2) + (mouse-x kr -1 1 0 0.1))) + (decoded (decode-b2 4 + (mce-channel encoded 0) + (mce-channel rotated 0) + (mce-channel rotated 1) + 0.5))) + (audition (out 0 decoded))) + +;; Rotation of stereo sound, via LFO. + +(let ((x (mul (pink-noise ar) 0.4)) + (y (mul (lf-tri ar 800 0) (mul (lf-pulse kr 3 0 0.3) 0.2)))) + (audition (out 0 (rotate2 x y (lf-saw kr 0.1 0))))) + +;; Rotation of stereo sound, via mouse. + +(let ((x (mix-fill 4 (lambda (_) (mul (lf-saw ar (rand 198 202) 0) 0.1)))) + (y (mul (sin-osc ar 900 0) (mul (lf-pulse kr 3 0 0.3) 0.2)))) + (audition (out 0 (rotate2 x y (mouse-x kr 0 2 0 0.1))))) diff --git a/rsc3/examples/ugen/physical-models/ball.help.scm b/rsc3/examples/ugen/physical-models/ball.help.scm new file mode 100644 index 0000000..5fc2131 --- /dev/null +++ b/rsc3/examples/ugen/physical-models/ball.help.scm @@ -0,0 +1,11 @@ +;; (ball in g damp friction) + +;; Physical model of bouncing object. + +;; Models the path of a bouncing object that is reflected by a +;; vibrating surface. + +;; in - modulated surface level +;; g - gravity +;; damp - damping on impact +;; friction - proximity from which on attraction to surface starts diff --git a/rsc3/examples/ugen/ternary-ops/mul-add.help.scm b/rsc3/examples/ugen/ternary-ops/mul-add.help.scm new file mode 100644 index 0000000..1cf74d3 --- /dev/null +++ b/rsc3/examples/ugen/ternary-ops/mul-add.help.scm @@ -0,0 +1,9 @@ +;; (mul-add a b c) + +;; Functionally equivalent to (add (mul a b) c). + +(let ((f (mul-add (lf-saw kr (mce2 10 9) 0) 200 400))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) + +(let ((f (add (mul (lf-saw kr (mce2 10 9) 0) 200) 400))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/triggers/gate.help.scm b/rsc3/examples/ugen/triggers/gate.help.scm new file mode 100644 index 0000000..2803925 --- /dev/null +++ b/rsc3/examples/ugen/triggers/gate.help.scm @@ -0,0 +1,7 @@ +;; (gate in trig) + +;; The signal at `in' is passed while `trig' is greater than zero. + +(let ((s (mul (f-sin-osc ar 500 0) 1/4)) + (t (lf-pulse ar 1 0 1/10))) + (audition (out 0 (gate s t)))) diff --git a/rsc3/examples/ugen/triggers/in-range.help.scm b/rsc3/examples/ugen/triggers/in-range.help.scm new file mode 100644 index 0000000..41d3e26 --- /dev/null +++ b/rsc3/examples/ugen/triggers/in-range.help.scm @@ -0,0 +1,13 @@ +;; (in-range in lo hi) + +;; Tests if a signal is within a given range. + +;; If in is >= lo and <= hi output 1.0, otherwise output 0.0. output +;; is initially zero. + +;; in - signal to be tested +;; lo - low threshold +;; hi - high threshold + +(let ((a (in-range (mul (sin-osc kr 1 0) 0.2) -0.15 0.15))) + (audition (out 0 (mul a (mul (brown-noise ar) 0.1))))) diff --git a/rsc3/examples/ugen/triggers/last-value.help.scm b/rsc3/examples/ugen/triggers/last-value.help.scm new file mode 100644 index 0000000..78365f6 --- /dev/null +++ b/rsc3/examples/ugen/triggers/last-value.help.scm @@ -0,0 +1,11 @@ +;; (last-value in diff) + +;; output the last value before the input changed more than a +;; threshhold. + +(let ((f (last-value (mouse-x kr 100 400 0 0.1) 40))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) + +(let* ((x (mouse-x kr 0.1 4 0 0.1)) + (f (mul-add (u:abs (sub x (last-value x 0.5))) 400 200))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) diff --git a/rsc3/examples/ugen/triggers/most-change.help.scm b/rsc3/examples/ugen/triggers/most-change.help.scm new file mode 100644 index 0000000..6205b85 --- /dev/null +++ b/rsc3/examples/ugen/triggers/most-change.help.scm @@ -0,0 +1,7 @@ +;; (most-change a b) + +;; output the input that changed most. + +(let* ((x (mouse-x kr 200 300 0 0.1)) + (f (most-change (mul-add (lf-noise0 kr 1) 400 900) x))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/triggers/peak-follower.help.scm b/rsc3/examples/ugen/triggers/peak-follower.help.scm new file mode 100644 index 0000000..c071702 --- /dev/null +++ b/rsc3/examples/ugen/triggers/peak-follower.help.scm @@ -0,0 +1,40 @@ +;; (peak-follower in decay) + +;; Track peak signal amplitude. outputs the peak amplitude of the +;; signal received at the input. If level is below maximum, the level +;; decreases by the factor given in decay. + +;; in - input signal. +;; decay - decay factor. + +;; internally, the absolute value of the signal is used, to prevent +;; underreporting the peak value if there is a negative DC offset. To +;; obtain the minimum and maximum values of the signal as is, use the +;; running-min and running-max UGens. + + +;; No decay + +(let* ((s (mul (dust ar 20) (line kr 0 1 4 do-nothing))) + (f (mul-add (peak-follower s 1.0) 1500 200))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) + +;; A little decay + +(let* ((s (mul (dust ar 20) (line kr 0 1 4 do-nothing))) + (f (mul-add (peak-follower s 0.999) 1500 200))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) + +;; Mouse x controls decay + +(let* ((x (mouse-x kr 0.99 1.0001 1 0.1)) + (s (mul (dust ar 20) (line kr 0 1 4 do-nothing))) + (f (mul-add (peak-follower s (u:min x 1.0)) 1500 200))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) + +;; Follow a sine lfo + +(let* ((x (mouse-x kr 0.99 1.0001 1 0.1)) + (s (sin-osc kr 0.2 0)) + (f (mul-add (peak-follower s (u:min x 1.0)) 200 500))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) diff --git a/rsc3/examples/ugen/triggers/peak.help.scm b/rsc3/examples/ugen/triggers/peak.help.scm new file mode 100644 index 0000000..e5d9739 --- /dev/null +++ b/rsc3/examples/ugen/triggers/peak.help.scm @@ -0,0 +1,8 @@ +;; (peak trig reset) + +;; outputs the maximum value read at the `trig' input until `reset' is +;; triggered. + +(let* ((p (peak (dust ar 20) (impulse ar 0.4 0))) + (f (mul-add p 500 200))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) diff --git a/rsc3/examples/ugen/triggers/phasor.help.scm b/rsc3/examples/ugen/triggers/phasor.help.scm new file mode 100644 index 0000000..ad47a9c --- /dev/null +++ b/rsc3/examples/ugen/triggers/phasor.help.scm @@ -0,0 +1,20 @@ +;; (phasor trig rate start end resetpos) + +;; triggered linear ramp between two levels. Starts a linear ramp +;; when trig input crosses from non-positive to positive. + +;; trig - sets phase to resetPos (default: 0, equivalent to start) +;; rate - rate value in 1 / frameDur (at 44.1 kHz sample rate: rate +;; 1 is eqivalent to 44100/sec) +;; start, end - start and end points of ramp +;; resetPos - determines where to jump to on recieving a trigger. the +;; value at that position can be calculated as follows: +;; (end - start) * resetPos + +;; phasor controls sine frequency: end frequency matches a second sine wave. + +(let* ((r (mouse-x kr 0.2 2 1 0.1)) + (t (impulse ar r 0)) + (x (phasor ar t (fdiv r sample-rate) 0 1 0)) + (f (mce2 (lin-lin x 0 1 600 1000) 1000))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) diff --git a/rsc3/examples/ugen/triggers/poll.help.scm b/rsc3/examples/ugen/triggers/poll.help.scm new file mode 100644 index 0000000..8caf37c --- /dev/null +++ b/rsc3/examples/ugen/triggers/poll.help.scm @@ -0,0 +1,47 @@ +;; (poll trig in trigid label) + +;; Print/query the current output value of a UGen. + +;; trig - a non-positive to positive transition telling poll to return +;; a value + +;; in - the signal you want to poll + +;; trigid - if greater then 0, a '/tr' message is sent back to the +;; client (similar to send-trig) + +;; label - a string or symbol to be printed with the polled value + +;; poll returns its in signal (and is therefore transparent). +;; WARNING: Printing values from the Server in intensive for the +;; CPU. poll should be used for debugging purposes. + +(define (string->ugen s) + (make-mce + (cons (string-length s) + (map char->integer (string->list s))))) + +(let ((t (impulse kr 2 0)) + (i (line kr 0 1 5 remove-synth))) + (audition (poll t i 0 (string->ugen "Test")))) + +(with-sc3 + (lambda (fd) + (letrec ((print (lambda (e) (display e) (newline))) + (showing (lambda (f) (lambda () (let ((v (f))) (print v) v)))) + (repeat (lambda (f) (if (f) (repeat f) #f)))) + (async fd (/notify 1)) + (repeat (showing (lambda () (wait fd "/tr")))) + (async fd (/notify 0))))) + +;; multichannel Expansion (Broken...) + +(define (poll* trig in trigId label) + (poll trig in trigId (string->ugen label))) + +(poll* (impulse kr (mce2 10 5) 0) + (line kr 0 (mce2 1 5) (mce2 1 2) do-nothing) + 0 + "Test") + +(with-sc3 server-status) diff --git a/rsc3/examples/ugen/triggers/pulse-count.help.scm b/rsc3/examples/ugen/triggers/pulse-count.help.scm new file mode 100644 index 0000000..3e85090 --- /dev/null +++ b/rsc3/examples/ugen/triggers/pulse-count.help.scm @@ -0,0 +1,7 @@ +;; (pulse-count trig reset) + +;; This outputs the number of pulses received at `trig' and outputs +;; that value until `reset' is triggered. + +(let ((f (mul (pulse-count (impulse ar 10 0) (impulse ar 0.4 0)) 200))) + (audition (out 0 (mul (sin-osc ar f 0) 0.05)))) diff --git a/rsc3/examples/ugen/triggers/pulse-divider.help.scm b/rsc3/examples/ugen/triggers/pulse-divider.help.scm new file mode 100644 index 0000000..6d3321f --- /dev/null +++ b/rsc3/examples/ugen/triggers/pulse-divider.help.scm @@ -0,0 +1,11 @@ +;; (pulse-divider trig div start) + +;; outputs one impulse each time it receives a certain number of +;; triggers at its input. A trigger happens when the signal changes +;; from non-positive to positive. + +(let* ((p (impulse ar 8 0)) + (d (pulse-divider p (mce2 4 7) 0)) + (a (mul (sin-osc ar 1200 0) (decay2 p 0.005 0.1))) + (b (mul (sin-osc ar 600 0) (decay2 d 0.005 0.5)))) + (audition (out 0 (mul (add a b) 0.4)))) diff --git a/rsc3/examples/ugen/triggers/running-max.help.scm b/rsc3/examples/ugen/triggers/running-max.help.scm new file mode 100644 index 0000000..4473a1c --- /dev/null +++ b/rsc3/examples/ugen/triggers/running-max.help.scm @@ -0,0 +1,16 @@ +;; (running-max in trig) + +;; Track maximum level. outputs the maximum value received at the +;; input. When triggered, the maximum output value is reset to the +;; current value. + +;; in - input signal +;; trig - reset the output value to the current input value + +(let* ((t (impulse ar 0.4 0)) + (f (mul-add (running-max (dust ar 20) t) 500 200))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) + +(let* ((t (impulse kr (mouse-x kr 0.01 2 1 0.1) 0)) + (f (mul-add (running-max (sin-osc kr 2 0) t) 500 200))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) diff --git a/rsc3/examples/ugen/triggers/running-min.help.scm b/rsc3/examples/ugen/triggers/running-min.help.scm new file mode 100644 index 0000000..306c329 --- /dev/null +++ b/rsc3/examples/ugen/triggers/running-min.help.scm @@ -0,0 +1,16 @@ +;; (running-min in trig) + +;; Track minimum level. outputs the minimum value received at the +;; input. When triggered, the minimum output value is reset to the +;; current value. + +;; in - input signal +;; trig - reset the output value to the current input value + +(let* ((t (impulse ar 2.0 0)) + (f (mul-add (running-min (sub 1 (dust ar 20)) t) 500 200))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) + +(let* ((t (impulse kr (mouse-x kr 0.5 4 1 0.1) 0)) + (f (mul-add (running-min (sub 2 (sin-osc kr 2 0)) t) 500 200))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) diff --git a/rsc3/examples/ugen/triggers/schmidt.help.scm b/rsc3/examples/ugen/triggers/schmidt.help.scm new file mode 100644 index 0000000..b3667e7 --- /dev/null +++ b/rsc3/examples/ugen/triggers/schmidt.help.scm @@ -0,0 +1,14 @@ +;; (schmidt in lo hi) + +;; schmidt trigger. When in crosses to greater than hi, output 1.0, +;; then when signal crosses lower than lo output 0.0. output is +;; initially zero. + +;; in - signal to be tested +;; lo - low threshold +;; hi - high threshold + +(let* ((in (lf-noise1 kr 3)) + (octave (add (schmidt in -0.15 0.15) 1)) + (f (add (mul in 200) (mul 500 octave)))) + (audition (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/triggers/send-trig.help.scm b/rsc3/examples/ugen/triggers/send-trig.help.scm new file mode 100644 index 0000000..dd03d58 --- /dev/null +++ b/rsc3/examples/ugen/triggers/send-trig.help.scm @@ -0,0 +1,25 @@ +;; (send-trig in id value) + +;; On receiving a trigger (0 to non-zero transition), send a trigger +;; message from the server back to all registered clients. Clients +;; register by sending a /notify message to the server. + +;; input - the trigger + +;; id - an integer that will be passed with the trigger message. This +;; is useful if you have more than one send-trig in a SynthDef + +;; value - a UGen or float that will be polled at the time of trigger, +;; and its value passed with the trigger message + +(let ((s (lf-noise0 kr 10))) + (audition (mrg2 (send-trig s 0 s) + (out 0 (mul (sin-osc ar (mul-add s 200 500) 0) 0.1))))) + +(with-sc3 + (lambda (fd) + (async fd (notify 1)) + (sleep 2.0) + (let ((r (wait fd "/tr"))) + (async fd (notify 0)) + r))) diff --git a/rsc3/examples/ugen/triggers/set-reset-ff.help.scm b/rsc3/examples/ugen/triggers/set-reset-ff.help.scm new file mode 100644 index 0000000..fdcdf73 --- /dev/null +++ b/rsc3/examples/ugen/triggers/set-reset-ff.help.scm @@ -0,0 +1,14 @@ +;; (set-reset-ff trig reset) + +;; Set-reset flip flop. output is set to 1.0 upon receiving a trigger +;; in the set input, and to 0.0 upon receiving a trigger in the reset +;; input. Once the flip flop is set to zero or one further triggers in +;; the same input are have no effect. One use of this is to have some +;; precipitating event cause something to happen until you reset it. + +;; trig - trigger sets output to one +;; reset - trigger resets output to zero + +(let ((n (brown-noise ar)) + (g (set-reset-ff (dust ar 5) (dust ar 5)))) + (audition (out 0 (mul3 n g 0.2)))) diff --git a/rsc3/examples/ugen/triggers/stepper.help.scm b/rsc3/examples/ugen/triggers/stepper.help.scm new file mode 100644 index 0000000..a44d4df --- /dev/null +++ b/rsc3/examples/ugen/triggers/stepper.help.scm @@ -0,0 +1,90 @@ +;; (stepper trig reset min max step resetval) + +;; stepper pulse counter. Each trigger increments a counter which is +;; output as a signal. The counter wraps between min and max. + +(with-sc3 + (lambda (fd) + (let ((a (list 97.999 195.998 523.251 466.164 195.998 + 233.082 87.307 391.995 87.307 261.626 + 195.998 77.782 233.082 195.998 97.999 + 155.563))) + (async fd (b-alloc 10 128 1)) + (send fd (b-setn1 10 0 a))))) + +;; Function composition... + +(define (seq s l) + (if (null? l) + s + (seq ((car l) s) (cdr l)))) + +(let* ((rate (mouse-x kr 1 5 1 0.1)) + (clock (impulse kr rate 0)) + (env (decay2 clock 0.002 2.5)) + (index (stepper clock 0 0 15 1 0)) + (freq (buf-rd 1 kr 10 index 1 1)) + (ffreq (add (if #t + (lag2 freq 0.1) + (mul (mouse-y kr 80 1600 1 0.1) (add (Mul env 4) 2))) + (mce2 0 0.3))) + (lfo (sin-osc kr 0.2 (mce4 0 (/ pi 2) 0.0024 0.0025))) + (rvb (lambda (s) (allpass-n s + 0.05 + (clone 2 (rand 0 0.05)) + (rand 1.5 2.0)))) + (proc (list + (lambda (s) (mul (rlpf s ffreq 0.3) env)) + (lambda (s) (mul (rlpf s ffreq 0.3) env)) + (lambda (s) (mul s 0.2)) + ;; Echo + (lambda (s) (mul-add (comb-l s 1 (fdiv 0.66 rate) 2) 0.8 s)) + ;; Reverb + (lambda (s) (add s (mul (seq s (replicate 5 rvb)) 0.3))) + (lambda (s) (leak-dc s 0.1)) + ;; Flanger + (lambda (s) (add (delay-l s 0.1 lfo) s)) + ;; Slight bass emphasis + (lambda (s) (one-pole s 0.9)))) + (init (mix (lf-pulse ar (mul freq (mce3 1 3/2 2)) 0 0.3)))) + (audition (out 0 (seq init proc)))) + +;; Pattern randomizer.... + +(with-sc3 + (lambda (fd) + (let ((p (map (lambda (e) + (midi-cps (+ 36 (s:degree-to-key e (list 0 3 5 7 10) 12)))) + (map floor (replicate-m 16 (random 0 15)))))) + (send fd (b-setn1 10 0 p))))) + +;; A shorter variant, using some simple syntax... + +(define-syntax seq* + (syntax-rules () + ((_ i s f ...) + (seq i (list (lambda (s) f) ...))))) + +(let* ((rate (mouse-x kr 1 5 1 0.1)) + (clock (impulse kr rate 0)) + (env (decay2 clock 0.002 2.5)) + (index (stepper clock 0 0 15 1 0)) + (freq (buf-rd 1 kr 10 index 1 1)) + (ffreq (add (lag2 freq 0.1) (mce2 0 0.3))) + (lfo (sin-osc kr 0.2 (mce4 0 (/ pi 2) 0.0024 0.0025))) + (rvb (lambda (s) (allpass-n s + 0.05 + (clone 2 (rand 0 0.05)) + (rand 1.5 2.0)))) + (init (mix (lf-pulse ar (mul freq (mce3 1 3/2 2)) 0 0.3))) + (proc (seq* init + s + (mul (rlpf s ffreq 0.3) env) + (mul (rlpf s ffreq 0.3) env) + (mul s 0.2) + (mul-add (comb-l s 1 (fdiv 0.66 rate) 2) 0.8 s) + (add s (mul (seq s (replicate 5 rvb)) 0.3)) + (leak-dc s 0.1) + (add (delay-l s 0.1 lfo) s) + (one-pole s 0.9)))) + (audition (out 0 proc))) diff --git a/rsc3/examples/ugen/triggers/sweep.help.scm b/rsc3/examples/ugen/triggers/sweep.help.scm new file mode 100644 index 0000000..55ecece --- /dev/null +++ b/rsc3/examples/ugen/triggers/sweep.help.scm @@ -0,0 +1,34 @@ +;; (sweep trig rate) + +;; triggered linear ramp. Starts a linear raise by rate/sec from zero +;; when trig input crosses from non-positive to positive. + +;; Using sweep to modulate sine frequency + +(let* ((t (impulse kr (mouse-x kr 0.5 20 1 0.1) 0)) + (f (add (sweep t 700) 500))) + (audition (out 0 (mul (sin-osc ar f 0) 0.2)))) + +;; Using sweep to index into a buffer + +(with-sc3 + (lambda (fd) + (async fd (b-alloc-read 0 "/home/rohan/audio/metal.wav" 0 0)))) + +(let* ((t (impulse ar (mouse-x kr 0.5 20 1 0.1) 0)) + (i (sweep t (buf-sample-rate ir 0)))) + (audition (out 0 (buf-rd 1 ar 0 i 0 2)))) + +;; Backwards, variable offset + +(let* ((t (impulse ar (mouse-x kr 0.5 10 1 0.1) 0)) + (r (buf-sample-rate ir 0)) + (i (add (sweep t (neg r)) (mul (buf-frames ir 0) (lf-noise0 kr 15))))) + (audition (out 0 (buf-rd 1 ar 0 i 0 2)))) + +;; Raising rate + +(let* ((t (impulse ar (mouse-x kr 0.5 10 1 0.1) 0)) + (r (add (sweep t 2) 0.5)) + (i (sweep t (mul (buf-sample-rate ir 0) r)))) + (audition (out 0 (buf-rd 1 ar 0 i 0 2)))) diff --git a/rsc3/examples/ugen/triggers/t-delay.help.scm b/rsc3/examples/ugen/triggers/t-delay.help.scm new file mode 100644 index 0000000..640fb08 --- /dev/null +++ b/rsc3/examples/ugen/triggers/t-delay.help.scm @@ -0,0 +1,13 @@ +;; (t-delay trigger delayTime) + +;; Delays a trigger by a given time. Any triggers which arrive in the +;; time between an input trigger and its delayed output, are ignored. + +;; trigger - input trigger signal. +;; delayTime - delay time in seconds. + +(let* ((s (mul (sin-osc ar 440 0) 0.1)) + (z (impulse ar 2 0)) + (l (mul z 0.1)) + (r (mul (toggle-ff (t-delay z 0.5)) s))) + (audition (out 0 (mce2 l r)))) diff --git a/rsc3/examples/ugen/triggers/timer.help.scm b/rsc3/examples/ugen/triggers/timer.help.scm new file mode 100644 index 0000000..d81bff9 --- /dev/null +++ b/rsc3/examples/ugen/triggers/timer.help.scm @@ -0,0 +1,10 @@ +;; (timer trig) + +;; Returns time since last triggered + +;; Using timer to modulate sine frequency: the slower the trigger is +;; the higher the frequency + +(let* ((t (impulse kr (mouse-x kr 0.5 20 1 0.1) 0)) + (s (sin-osc ar (mul-add (timer t) 500 500) 0))) + (audition (out 0 (mul s 0.2)))) diff --git a/rsc3/examples/ugen/triggers/toggle-ff.help.scm b/rsc3/examples/ugen/triggers/toggle-ff.help.scm new file mode 100644 index 0000000..4f8463c --- /dev/null +++ b/rsc3/examples/ugen/triggers/toggle-ff.help.scm @@ -0,0 +1,9 @@ +;; (toggle-ff trig) + +;; Toggle flip flop. Toggles between zero and one upon receiving a trigger. + +;; trig - trigger input + +(let* ((t (dust ar (x-line kr 1 1000 60 do-nothing))) + (s (sin-osc ar (mul-add (toggle-ff t) 400 800) 0))) + (audition (out 0 (mul s 0.1)))) diff --git a/rsc3/examples/ugen/triggers/trig.help.scm b/rsc3/examples/ugen/triggers/trig.help.scm new file mode 100644 index 0000000..039ee85 --- /dev/null +++ b/rsc3/examples/ugen/triggers/trig.help.scm @@ -0,0 +1,9 @@ +;; (trig in dur) + +;; When `in' is trigerred output the trigger value for `dur' seconds. + +(let ((s (f-sin-osc ar 800 0)) + (g (trig (dust ar 1) 0.2))) + (audition (out 0 (mul3 s g 0.5)))) + +(audition (out 0 (trig (dust ar 4) 0.1))) diff --git a/rsc3/examples/ugen/triggers/trig1.help.scm b/rsc3/examples/ugen/triggers/trig1.help.scm new file mode 100644 index 0000000..b97e1bc --- /dev/null +++ b/rsc3/examples/ugen/triggers/trig1.help.scm @@ -0,0 +1,6 @@ +;; (trig1 in dur) + +;; When `in' is trigered output a unit signal for `dur' seconds. + +(let ((a (trig1 (dust ar 1) 0.2))) + (audition (out 0 (mul3 (f-sin-osc ar 800 0) a 0.2)))) diff --git a/rsc3/examples/ugen/unary-ops/abs.help.scm b/rsc3/examples/ugen/unary-ops/abs.help.scm new file mode 100644 index 0000000..4cc27d8 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/abs.help.scm @@ -0,0 +1,5 @@ +;; (abs a) + +;; Absolute value. + +(audition (out 0 (u:abs (mul (sync-saw ar 100 440) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/amp-db.help.scm b/rsc3/examples/ugen/unary-ops/amp-db.help.scm new file mode 100644 index 0000000..982d937 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/amp-db.help.scm @@ -0,0 +1,12 @@ +;; (amp-db a) + +;; Convert linear amplitude to decibels. + +(audition + (out 0 (mul (f-sin-osc ar 800 0.0) + (db-amp (amp-db (line kr 0.5 0.0 5 remove-synth)))))) + +(let* ((x (mouse-x kr -60 0 0 0.1)) + (f (mul-add (db-amp x) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/arc-cos.help.scm b/rsc3/examples/ugen/unary-ops/arc-cos.help.scm new file mode 100644 index 0000000..f2dca7a --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/arc-cos.help.scm @@ -0,0 +1,9 @@ +;; (arc-cos a) + +;; Arc cosine. + +(let* ((a (line kr -1 1 1 remove-synth)) + (b (sub (fdiv (arc-cos a) (/ pi 2)) 1)) + (f (mul-add b 900 1600))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/arc-sin.help.scm b/rsc3/examples/ugen/unary-ops/arc-sin.help.scm new file mode 100644 index 0000000..822a0f4 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/arc-sin.help.scm @@ -0,0 +1,9 @@ +;; (arc-sin a) + +;; Arc sine. + +(let* ((a (line kr -1 1 1 remove-synth)) + (b (sub (fdiv (arc-sin a) (/ pi 2)) 1)) + (f (mul-add b 900 1600))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/arc-tan.help.scm b/rsc3/examples/ugen/unary-ops/arc-tan.help.scm new file mode 100644 index 0000000..5f7ef79 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/arc-tan.help.scm @@ -0,0 +1,9 @@ +;; (arc-tan a) + +;; Arc tan. + +(let* ((a (line kr -1 1 1 remove-synth)) + (b (sub (fdiv (arc-tan a) (/ pi 2)) 1)) + (f (mul-add b 900 1600))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/ceil.help.scm b/rsc3/examples/ugen/unary-ops/ceil.help.scm new file mode 100644 index 0000000..ca3d003 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/ceil.help.scm @@ -0,0 +1,8 @@ +;; (ceil a) + +;; Round signal up. + +(let* ((x (mouse-x kr 65 95 0 0.1)) + (f (midi-cps (mce2 (u:floor x) (ceil x))))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/cos-h.help.scm b/rsc3/examples/ugen/unary-ops/cos-h.help.scm new file mode 100644 index 0000000..dc9f475 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/cos-h.help.scm @@ -0,0 +1,9 @@ +;; (cos-h a) + +;; Cosine. + +(let* ((a (line kr (- pi) pi 1 remove-synth)) + (b (sub (fdiv (cos-h a) (/ pi 2)) 1)) + (f (mul-add b 900 1600))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/cos.help.scm b/rsc3/examples/ugen/unary-ops/cos.help.scm new file mode 100644 index 0000000..4a2288a --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/cos.help.scm @@ -0,0 +1,9 @@ +;; (cos a) + +;; Cosine. + +(let* ((a (line kr (- pi) pi 1 remove-synth)) + (b (sub (fdiv (u:cos a) (/ pi 2)) 1)) + (f (mul-add b 900 1600))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/cps-midi.help.scm b/rsc3/examples/ugen/unary-ops/cps-midi.help.scm new file mode 100644 index 0000000..98ed70d --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/cps-midi.help.scm @@ -0,0 +1,7 @@ +;; (cps-midi a) + +;; Convert cycles per second to MIDI note. + +(let ((f (line kr 600 900 5 remove-synth))) + (audition + (out 0 (mul (saw ar (midi-cps (cps-midi f))) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/cps-oct.help.scm b/rsc3/examples/ugen/unary-ops/cps-oct.help.scm new file mode 100644 index 0000000..da52868 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/cps-oct.help.scm @@ -0,0 +1,7 @@ +;; (cps-oct a) + +;; Convert cycles per second to decimal octaves. + +(audition + (let ((f (oct-cps (cps-oct (x-line kr 600 900 6 remove-synth))))) + (out 0 (mul (saw ar f) 0.2)))) diff --git a/rsc3/examples/ugen/unary-ops/cubed.help.scm b/rsc3/examples/ugen/unary-ops/cubed.help.scm new file mode 100644 index 0000000..e5ea88b --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/cubed.help.scm @@ -0,0 +1,9 @@ +;; (cubed a) + +;; Cube. + +(let* ((a (line ar -2 2 3 remove-synth)) + (b (cubed a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/db-amp.help.scm b/rsc3/examples/ugen/unary-ops/db-amp.help.scm new file mode 100644 index 0000000..aac1db4 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/db-amp.help.scm @@ -0,0 +1,7 @@ +;; (db-amp a) + +;; Convert decibels to linear amplitude. + +(audition + (out 0 (mul (f-sin-osc ar 800 0.0) + (db-amp (line kr -3 -40 10 remove-synth))))) diff --git a/rsc3/examples/ugen/unary-ops/distort.help.scm b/rsc3/examples/ugen/unary-ops/distort.help.scm new file mode 100644 index 0000000..712718c --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/distort.help.scm @@ -0,0 +1,8 @@ +;; (distort a) + +;; Nonlinear distortion. + +(audition + (out 0 (mul (distort (mul (f-sin-osc ar 500 0.0) + (x-line kr 0.1 10 10 do-nothing))) + 0.25))) diff --git a/rsc3/examples/ugen/unary-ops/exp.help.scm b/rsc3/examples/ugen/unary-ops/exp.help.scm new file mode 100644 index 0000000..6fa4cb1 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/exp.help.scm @@ -0,0 +1,9 @@ +;; (exp a) + +;; Exponential. + +(let* ((a (line ar -2 2 3 remove-synth)) + (b (u:exp a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/floor.help.scm b/rsc3/examples/ugen/unary-ops/floor.help.scm new file mode 100644 index 0000000..f52027e --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/floor.help.scm @@ -0,0 +1,8 @@ +;; (u:floor a) + +;; Round signal down. + +(let* ((x (mouse-x kr 65 95 0 0.1)) + (f (midi-cps (u:floor x)))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/frac.help.scm b/rsc3/examples/ugen/unary-ops/frac.help.scm new file mode 100644 index 0000000..90f0ef8 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/frac.help.scm @@ -0,0 +1,9 @@ +;; (frac a) + +;; Fractional part. + +(let* ((a (line ar -2 2 3 remove-synth)) + (b (frac a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/is-negative.help.scm b/rsc3/examples/ugen/unary-ops/is-negative.help.scm new file mode 100644 index 0000000..3a32d5c --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/is-negative.help.scm @@ -0,0 +1,12 @@ +;; (is-negative a) + +;; Predicate to determine if a value is negative. + +(define (is-negative a) + (lt a 0.0)) + +(let* ((a (line ar -1 1 1 remove-synth)) + (b (is-negative a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/is-positive.help.scm b/rsc3/examples/ugen/unary-ops/is-positive.help.scm new file mode 100644 index 0000000..51beb8f --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/is-positive.help.scm @@ -0,0 +1,12 @@ +;; (is-positive a) + +;; Predicate to determine if a value is positive. + +(define (is-positive a) + (ge a 0.0)) + +(let* ((a (line ar -1 1 1 remove-synth)) + (b (is-positive a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/is-strictly-positive.help.scm b/rsc3/examples/ugen/unary-ops/is-strictly-positive.help.scm new file mode 100644 index 0000000..a834cb0 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/is-strictly-positive.help.scm @@ -0,0 +1,12 @@ +;; (is-strictly-positive a) + +;; Predicate to determine if a value is strictly positive. + +(define (is-strictly-positive a) + (gt a 0.0)) + +(let* ((a (line ar -1 1 1 remove-synth)) + (b (is-strictly-positive a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/log.help.scm b/rsc3/examples/ugen/unary-ops/log.help.scm new file mode 100644 index 0000000..edf5977 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/log.help.scm @@ -0,0 +1,9 @@ +;; (u:log a) + +;; Reciprocal. + +(let* ((a (line ar -2 2 2 remove-synth)) + (b (u:log a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/log10.help.scm b/rsc3/examples/ugen/unary-ops/log10.help.scm new file mode 100644 index 0000000..0ea6deb --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/log10.help.scm @@ -0,0 +1,9 @@ +;; (log10 a) + +;; Base ten logarithm. + +(let* ((a (line ar -2 2 3 remove-synth)) + (b (log10 a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/log2.help.scm b/rsc3/examples/ugen/unary-ops/log2.help.scm new file mode 100644 index 0000000..0a7651d --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/log2.help.scm @@ -0,0 +1,9 @@ +;; (log2 a) + +;; Base two logarithm. + +(let* ((a (line ar -2 2 3 remove-synth)) + (b (log2 a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/midi-cps.help.scm b/rsc3/examples/ugen/unary-ops/midi-cps.help.scm new file mode 100644 index 0000000..6a6c743 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/midi-cps.help.scm @@ -0,0 +1,6 @@ +;; (midi-cps a) + +;; Convert MIDI note to cycles per second. + +(audition + (out 0 (mul (saw ar (midi-cps (line kr 24 108 10 remove-synth))) 0.2))) diff --git a/rsc3/examples/ugen/unary-ops/neg.help.scm b/rsc3/examples/ugen/unary-ops/neg.help.scm new file mode 100644 index 0000000..972571b --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/neg.help.scm @@ -0,0 +1,8 @@ +;; (neg a) + +;; Negation. + +(let ((s (sin-osc ar 440 0))) + (audition + (out 0 (mce2 (mul s 0.1) + (add s (neg s)))))) diff --git a/rsc3/examples/ugen/unary-ops/oct-cps.help.scm b/rsc3/examples/ugen/unary-ops/oct-cps.help.scm new file mode 100644 index 0000000..c905832 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/oct-cps.help.scm @@ -0,0 +1,11 @@ +;; (oct-cps a) + +;; Convert decimal octaves to cycles per second. + +(audition + (let ((f (oct-cps (line kr 2 9 6 remove-synth)))) + (out 0 (mul (saw ar f) 0.2)))) + +(audition + (let ((f (oct-cps (u:round (line kr 2 9 6 remove-synth) (/ 1 12))))) + (out 0 (mul (saw ar f) 0.2)))) diff --git a/rsc3/examples/ugen/unary-ops/sign.help.scm b/rsc3/examples/ugen/unary-ops/sign.help.scm new file mode 100644 index 0000000..3fd201e --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/sign.help.scm @@ -0,0 +1,9 @@ +;; (sign a) + +;; Sign function. -1 when a < 0, +1 when a > 0, 0 when a is 0 + +(let* ((a (line ar -1 1 1 remove-synth)) + (b (sign a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/sin-h.help.scm b/rsc3/examples/ugen/unary-ops/sin-h.help.scm new file mode 100644 index 0000000..858aed4 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/sin-h.help.scm @@ -0,0 +1,9 @@ +;; (sin-h a) + +;; Sine. + +(let* ((a (line kr (- pi) pi 1 remove-synth)) + (b (sub (fdiv (sin-h a) (/ pi 2)) 1)) + (f (mul-add b 900 1600))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/sin.help.scm b/rsc3/examples/ugen/unary-ops/sin.help.scm new file mode 100644 index 0000000..cee5d12 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/sin.help.scm @@ -0,0 +1,9 @@ +;; (u:sin a) + +;; Sine. + +(let* ((a (line kr (- pi) pi 1 remove-synth)) + (b (sub (fdiv (u:sin a) (/ pi 2)) 1)) + (f (mul-add b 900 1600))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/soft-clip.help.scm b/rsc3/examples/ugen/unary-ops/soft-clip.help.scm new file mode 100644 index 0000000..a74eeb7 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/soft-clip.help.scm @@ -0,0 +1,9 @@ +;; (soft-clip a) + +;; Nonlinear distortion. Distortion with a perfectly linear region +;; from -0.5 to +0.5. + +(audition + (out 0 (mul (soft-clip (mul (f-sin-osc ar 500 0.0) + (x-line kr 0.1 10 10 do-nothing))) + 0.25))) diff --git a/rsc3/examples/ugen/unary-ops/sqrt.help.scm b/rsc3/examples/ugen/unary-ops/sqrt.help.scm new file mode 100644 index 0000000..b507ca8 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/sqrt.help.scm @@ -0,0 +1,10 @@ +;; (u:sqrt a) + +;; Square root. The definition of square root is extended for signals +;; so that sqrt(a) when a<0 returns -sqrt(-a). + +(let* ((a (line ar -2 2 3 remove-synth)) + (b (u:sqrt a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/squared.help.scm b/rsc3/examples/ugen/unary-ops/squared.help.scm new file mode 100644 index 0000000..79e338e --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/squared.help.scm @@ -0,0 +1,9 @@ +;; (squared a) + +;; Square. + +(let* ((a (line ar -2 2 3 remove-synth)) + (b (squared a)) + (f (mul-add (mce2 a b) 600 900))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/tan-h.help.scm b/rsc3/examples/ugen/unary-ops/tan-h.help.scm new file mode 100644 index 0000000..e9908e1 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/tan-h.help.scm @@ -0,0 +1,9 @@ +;; (tan-h a) + +;; Tangent. + +(let* ((a (line kr (- pi) pi 1 remove-synth)) + (b (sub (fdiv (tan-h a) (/ pi 2)) 1)) + (f (mul-add b 900 1600))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1)))) diff --git a/rsc3/examples/ugen/unary-ops/tan.help.scm b/rsc3/examples/ugen/unary-ops/tan.help.scm new file mode 100644 index 0000000..09be331 --- /dev/null +++ b/rsc3/examples/ugen/unary-ops/tan.help.scm @@ -0,0 +1,9 @@ +;; (u:tan a) + +;; Tangent. + +(let* ((a (line kr (- pi) pi 1 remove-synth)) + (b (sub (fdiv (u:tan a) (/ pi 2)) 1)) + (f (mul-add b 900 1600))) + (audition + (out 0 (mul (sin-osc ar f 0) 0.1))))