-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheos-x1k2.scm
62 lines (49 loc) · 2.47 KB
/
eos-x1k2.scm
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
56
57
58
59
60
61
62
(use-modules (open-sound-control client))
(use-modules (open-sound-control server))
;; Connect to Eos
(define from-eos (make-osc-server "osc.tcp://:8000"))
(define to-eos (make-osc-address "osc.tcp://192.168.178.35:8000"))
(define (eos-send! path . vals)
(apply osc-send-from to-eos from-eos path vals))
(eos-send! "/eos/ping")
;; Connect to x1k2-midi-osc-alsa
(define from-x1k2 (make-osc-server "osc.udp://:7770"))
(define to-x1k2 (make-osc-address "osc.udp://localhost:7771"))
(osc-send to-x1k2 "/x1k2/buttons/*/set-led" 'off)
;; Set up encoders
(define (rotary-encoder enc param)
(add-osc-method from-x1k2 (string-append "/x1k2/encoders/" enc "/inc") ""
(lambda () (eos-send! (string-append "/eos/wheel/" param) 4)))
(add-osc-method from-x1k2 (string-append "/x1k2/encoders/" enc "/inc-fine") ""
(lambda () (eos-send! (string-append "/eos/wheel/" param) 1)))
(add-osc-method from-x1k2 (string-append "/x1k2/encoders/" enc "/dec") ""
(lambda () (eos-send! (string-append "/eos/wheel/" param) -4)))
(add-osc-method from-x1k2 (string-append "/x1k2/encoders/" enc "/dec-fine") ""
(lambda () (eos-send! (string-append "/eos/wheel/" param) -1))))
(rotary-encoder "1" "pan")
(rotary-encoder "2" "tilt")
(rotary-encoder "3" "zoom")
(rotary-encoder "4" "edge")
(rotary-encoder "6" "level")
;; Set up faders
(eos-send! "/eos/fader/1/config/4")
(add-osc-method from-x1k2 "/x1k2/faders/1/value-change" "i"
(lambda (lvl) (eos-send! "/eos/fader/1/1" (/ lvl 127))))
(add-osc-method from-x1k2 "/x1k2/faders/2/value-change" "i"
(lambda (lvl) (eos-send! "/eos/fader/1/2" (/ lvl 127))))
(add-osc-method from-x1k2 "/x1k2/faders/3/value-change" "i"
(lambda (lvl) (eos-send! "/eos/fader/1/3" (/ lvl 127))))
(add-osc-method from-x1k2 "/x1k2/faders/4/value-change" "i"
(lambda (lvl) (eos-send! "/eos/fader/1/4" (/ lvl 127))))
;; Go/stop-back
(define (playback-buttons go stop)
(osc-send to-x1k2 (string-append go "/set-led") 'green)
(osc-send to-x1k2 (string-append stop "/set-led") 'red)
(add-osc-method from-x1k2 (string-append go "/press") ""
(lambda () (eos-send! "/eos/key/go_0")))
(add-osc-method from-x1k2 (string-append stop "/press") ""
(lambda () (eos-send! "/eos/key/stop"))))
(playback-buttons "/x1k2/buttons/LAYER" "/x1k2/buttons/M")
(playback-buttons "/x1k2/buttons/SHIFT" "/x1k2/buttons/P")
(while 1
(osc-recv from-eos from-x1k2))