rsc3/doc/examples/graph/_scm/scritto.scm

83 lines
3.3 KiB
Scheme
Raw Permalink Normal View History

2022-08-24 13:53:18 +00:00
;; 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)