-
Notifications
You must be signed in to change notification settings - Fork 0
/
ybot_dsp3.xtm
55 lines (40 loc) · 1.42 KB
/
ybot_dsp3.xtm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
;; All signal generators should have a freq, amp and phase
;; (even if they don't do anything)
(bind-alias SignalGenerator [SAMPLE]*)
(bind-func constant_c:[SignalGenerator,SAMPLE]*
(lambda (value)
(lambda ()
value)))
;(bind-macro (chain . args)
; `(,(car args) (chain ,@(cdr args))))
(bind-func phasor_c:[SignalGenerator]*
(lambda ()
(let ((freq:SignalGenerator (constant_c (convert 440.0)))
(phase:SAMPLE (convert 0.0)))
(lambda ()
(set! phase (modulo (+ phase (/ (freq) SAMPLERATE)) 1.0))
phase))))
(bind-func phasor_c:[SignalGenerator,SAMPLE]*
(lambda (freq)
(let ((f:SignalGenerator (constant_c freq))
(phase:SAMPLE (convert 0.0)))
(lambda ()
(set! phase (modulo (+ phase (/ (f) SAMPLERATE)) 1.0))
phase))))
(bind-func phasor_c:[SignalGenerator,SignalGenerator]*
(lambda (freq)
(let ((phase:SAMPLE (convert 0.0)))
(lambda ()
(set! phase (modulo (+ phase (/ (freq) SAMPLERATE)) 1.0))
phase))))
(bind-func sinetone_c:[SignalGenerator,SAMPLE,SAMPLE]*
(lambda (amp freq)
(let* ((a:SignalGenerator (constant_c amp))
(f:SignalGenerator (constant_c freq))
(p:SignalGenerator (phasor_c f)))
(lambda ()
(* (a) (sin (* STWOPI (p))))))))
(bind-func lfo1:SignalGenerator
(sinetone_c 1000.0 10.0))
(bind-macro (patch . args)
`(,(car args).,(cadr args) ,(caddr args)))