Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

RingArea tests.

  • Loading branch information...
commit fa8321fcf272794c00924e1a5da72b72a884069a 1 parent 86d2619
Nick Rothwell authored
8 TECH-NOTES.md
Source Rendered
@@ -2,6 +2,9 @@
2 2
3 3 ## General
4 4
  5 +- We need to generalise ADSRH (e.g. in Pads): these actually take
  6 + expressions.
  7 +
5 8 ## Specific Objects
6 9
7 10 ### Container
@@ -16,3 +19,8 @@
16 19 - There's no clear documentation for the properties `Multilabel` and
17 20 `Multicolor` - I'm guessing these are scriptable/OSC controllable
18 21 only. For now, they're always off.
  22 +
  23 +- Need to generalise ADSRH (see above).
  24 +
  25 +- To-do: "Capture", "light". (Light can apparently be a vector or
  26 + expression; we should investigate this.)
150 scratch.clj
@@ -18,92 +18,6 @@
18 18
19 19 (with-out-str (px/prxml [:p {:class "greet"} [:i "Ladies & gentlemen"]]))
20 20
21   -;; Do everything in bytes; the Lemur's OSC spec uses blobs, and I doubt it's going
22   -;; to handle any non-ASCII encoding such as UTF-8.
23   -
24   -
25   -(def xxx (byte-array (map byte [2 3 4])))
26   -
27   -(def yyy (byte-array 10))
28   -
29   -(System/arraycopy xxx 0 yyy 0 (count xxx))
30   -
31   -(map #(get yyy %) (range (count yyy)))
32   -
33   -;; --- OSC experiments (obsolete: the Lemur protocol isn't OSC).
34   -
35   -(def a (atom nil))
36   -
37   -(def LEMUR_HOST "localhost")
38   -(def LEMUR_HOST "10.0.0.125")
39   -(def LEMUR_PORT 8001)
40   -
41   -; loopback test.
42   -(def server (osc-server 8001))
43   -(osc-handle server "/interface" (fn [msg] (reset! a msg)))
44   -(osc-close server)
45   -
46   -(def client (osc-client LEMUR_HOST LEMUR_PORT))
47   -
48   -(osc-send client
49   - "/interface"
50   - (count ba)
51   - (int 0)
52   - (int (u/crc ba))
53   - ba)
54   -
55   -@a
56   -
57   -;; --- XML file into byte-array.
58   -
59   -(def ba (io/read-file "test-data/tiny.jzml"))
60   -(count ba)
61   -
62   -;; --- Bespoke, Lemur-specific broken OSC:
63   -
64   -;; Header is 20 bytes / 5 int32s.
65   -;; 0: padded payload length + 16
66   -;; 1+2: "/jzml" padded
67   -;; 3: ",b" padded
68   -;; 4: unpadded payload length
69   -;;
70   -;; Actual (padded) payload is sent "raw", in packets limited to 1448 bytes.
71   -
72   -
73   -(def HEADER_SIZE_BYTES 20)
74   -
75   -
76   -
77   -(def chan (DatagramChannel/open))
78   -(.connect chan (InetSocketAddress. "10.0.0.125" 8002))
79   -
80   -
81   -
82   -(.write chan (ByteBuffer/wrap (byte-array (map byte [1 2 3 4]))))
83   -
84   -
85   -
86   -(.disconnect chan)
87   -
88   -(let
89   - [ba (io/pad-string-to-bytes "AB")]
90   - (map (partial get ba) (range (count ba))))
91   -
92   -(int \c)
93   -
94   -(map count
95   - (p/package-data (byte-array (map byte [1 2 3 4 5]))))
96   -
97   -
98   -(def ba (io/read-file "test-data/tiny_PREPPED.jzml"))
99   -(count ba)
100   -
101   -(io/transmit-payload "127.0.0.1" 8002 ba)
102   -(io/transmit-payload "10.0.0.125" 8002 ba)
103   -
104   -
105   -
106   -
107 21 (x/format-project-for-file [:fooble] [:gooble])
108 22
109 23 (x/format-project-for-upload [:fooble] [:gooble])
@@ -112,17 +26,7 @@
112 26
113 27 (with-out-str (p/prxml (x/fudge-container [100 100] [200 50] [80 80 80] [:foo])))
114 28
115   -(io/transmit-payload
116   - "10.0.0.125"
117   - 8002
118   - (.getBytes (x/format-project-for-upload
119   - (x/project "TestProject")
120   - (x/fudge-window (x/fudge-container
121   - [100 100]
122   - [200 200]
123   - [80 80 80]
124   - (x/fudge-container [5 5] [50 50] [255 255 255]))))))
125   -
  29 +;; Nested container example. (container() takes varargs for the contents.)
126 30
127 31 (defn boz [size]
128 32 (if (< size 30)
@@ -147,7 +51,55 @@
147 51
148 52 (sp/sierpinski 3)
149 53
150   -(concat [1 2 3] [4 5 6])
  54 +;; More examples.
  55 +
  56 +(io/transmit-payload
  57 + "10.0.0.125"
  58 + 8002
  59 + (.getBytes (x/format-project-for-upload
  60 + (x/project "TestProject")
  61 + (x/interface [(obj/container
  62 + {:position [100 100]
  63 + :size [300 300]
  64 + :colour [80 120 120]}
  65 + (obj/pads {:id 987
  66 + :name "pads"
  67 + :position [0 0]
  68 + :size [284 284]
  69 + :off-colour [50 50 50]
  70 + :on-colour [255 255 255]}))]))))
  71 +
  72 +(io/transmit-payload
  73 + "10.0.0.125"
  74 + 8002
  75 + (.getBytes (x/format-project-for-upload
  76 + (x/project "TestProject")
  77 + (x/interface [(obj/container
  78 + {:position [100 100]
  79 + :size [300 300]
  80 + :colour [80 120 120]}
  81 + (obj/ringarea {:id 987
  82 + :name "ra"
  83 + :position [0 0]
  84 + :size 284
  85 + :colour [150 150 150]}))]))))
  86 +
  87 +(io/transmit-payload
  88 + "10.0.0.125"
  89 + 8002
  90 + (.getBytes (x/format-project-for-upload
  91 + (x/project "TestProject")
  92 + (x/interface [(obj/container
  93 + {:position [10 10]
  94 + :size [700 700]
  95 + :colour [80 120 120]}
  96 + (map #(obj/ringarea
  97 + {:id %
  98 + :name (format "ra%d" %)
  99 + :position [(int (* 278 (inc (Math/sin (* % Math/PI 0.125)))))
  100 + (int (* 278 (inc (Math/cos (* % Math/PI 0.125)))))]
  101 + :size 120
  102 + :colour [(- 255 (* % 10)) 200 150]}) (range 16)))]))))
151 103
152 104 (io/transmit-payload
153 105 "10.0.0.125"
@@ -169,8 +121,6 @@
169 121 :off-colour c
170 122 :on-colour [255 0 0]}))))]))))
171 123
172   -(concat 1 2 [4 5])
173   -
174 124 ;; -----
175 125
176 126 (obj/pads {:id 345
14 src/sifaka/object_common.clj
@@ -37,7 +37,7 @@
37 37 :osc_message (format "/%s/%s" object-name var-name)})
38 38
39 39 (defn variable
40   - ^{:doc "Common settings for an object variable. Value assumed to be float."}
  40 + ^{:doc "Common settings for an object variable. Value assumed to be float."}
41 41 [object-name var-name var-value]
42 42 [:VARIABLE (merge {:name (format "%s=%f" var-name var-value)
43 43 :send 0}
@@ -45,6 +45,18 @@
45 45 fudge-midi-params
46 46 fudge-kbmouse-params)])
47 47
  48 +(defn param
  49 + ^{:doc "Common settings for an object parameter."}
  50 + [obj-name param-name value]
  51 + [:PARAM (merge {:name (format "%s=" param-name)
  52 + :value value
  53 + :send 17 ; Is this the trigger mode?
  54 + :midi_scale "0,16363"
  55 + :osc_scale "0.0,1.0"}
  56 + (base-osc-params obj-name param-name)
  57 + fudge-midi-params
  58 + fudge-kbmouse-params)])
  59 +
48 60 (defn window
49 61 ^{:doc "Window phrase, with attributes (map) and sub-items (seq)."}
50 62 [attributes sub-items]
42 src/sifaka/objects.clj
@@ -50,12 +50,38 @@
50 50 :multicolor 0
51 51 :multilabel 0}
52 52 (cons
53   - [:PARAM (merge {:name "x="
54   - :value 0.0
55   - :send 17
56   - :midi_scale "0,16363"
57   - :osc_scale "0.0,1.0"}
58   - (com/base-osc-params name "x")
59   - com/fudge-midi-params ; Actually, midi_trigger=1 here.
60   - com/fudge-kbmouse-params)]
  53 + (com/param name "x" 0.0)
61 54 (com/env name {}))))
  55 +
  56 +(defn ringarea
  57 + ^{:doc "RingArea control."}
  58 + [{id :id
  59 + name :name
  60 + [x y] :position
  61 + size :size
  62 + [r g b] :colour}]
  63 + (let [params [(com/param name "x" 0.5)
  64 + (com/param name "y" 0.5)]
  65 + variables [(com/variable name "attraction" 1.0)
  66 + (com/variable name "friction" 0.8)
  67 + (com/variable name "speed" 1.0)
  68 + (com/variable name "attraction_x" 0.5)
  69 + (com/variable name "attraction_y" 0.5)]]
  70 + (com/window {:class "RingArea"
  71 + :id id
  72 + :text name
  73 + :x x
  74 + :y y
  75 + :width size
  76 + :height size
  77 + :label 0
  78 + :state 1
  79 + :group 0
  80 + :send 1
  81 + :capture 1
  82 + :font "tahoma,10,0"
  83 + :osc_target -2
  84 + :midi_target -2
  85 + :kbmouse_target -2
  86 + :color (com/colour r g b)}
  87 + (concat params variables))))
14 test-data/one-ringarea.jzml
... ... @@ -0,0 +1,14 @@
  1 +<JZML>
  2 +<PROJECT version="3020" width="1024" height="724" osc_target="-2" midi_target="-2" kbmouse_target="-2"/>
  3 +<WINDOW class="JAZZINTERFACE" text="Default" x="0" y="0" width="1024" height="724" state="1" group="0" font="tahoma,11,0" >
  4 +<WINDOW class="RingArea" text="RingArea" x="402" y="184" width="200" height="200" id="2" state="1" group="0" font="tahoma,10,0" send="1" osc_target="-2" midi_target="-2" kbmouse_target="-2" capture="1" color="32768" label="0">
  5 +<PARAM name="x=" value="0.500000" send="17" osc_target="0" osc_trigger="1" osc_message="/RingArea/x" midi_target="-1" midi_trigger="1" midi_message="0x90,0x90,0,0" midi_scale="0,16383" osc_scale="0.000000,1.000000" kbmouse_target="-1" kbmouse_trigger="1" kbmouse_message="0,0,0" kbmouse_scale="0,1,0,1"/>
  6 +<PARAM name="y=" value="0.500000" send="17" osc_target="0" osc_trigger="1" osc_message="/RingArea/y" midi_target="-1" midi_trigger="1" midi_message="0x90,0x90,0,0" midi_scale="0,16383" osc_scale="0.000000,1.000000" kbmouse_target="-1" kbmouse_trigger="1" kbmouse_message="0,0,0" kbmouse_scale="0,1,0,1"/>
  7 +<VARIABLE name="attraction=1" send="0" osc_target="0" osc_trigger="1" osc_message="/RingArea/attraction" midi_target="-1" midi_trigger="1" midi_message="0x90,0x90,0,0" midi_scale="0,16383" kbmouse_target="-1" kbmouse_trigger="1" kbmouse_message="0,0,0" kbmouse_scale="0,1,0,1"/>
  8 +<VARIABLE name="friction=0.8" send="0" osc_target="0" osc_trigger="1" osc_message="/RingArea/friction" midi_target="-1" midi_trigger="1" midi_message="0x90,0x90,0,0" midi_scale="0,16383" kbmouse_target="-1" kbmouse_trigger="1" kbmouse_message="0,0,0" kbmouse_scale="0,1,0,1"/>
  9 +<VARIABLE name="speed=1" send="0" osc_target="0" osc_trigger="1" osc_message="/RingArea/speed" midi_target="-1" midi_trigger="1" midi_message="0x90,0x90,0,0" midi_scale="0,16383" kbmouse_target="-1" kbmouse_trigger="1" kbmouse_message="0,0,0" kbmouse_scale="0,1,0,1"/>
  10 +<VARIABLE name="attraction_x=0.5" send="0" osc_target="0" osc_trigger="1" osc_message="/RingArea/attraction_x" midi_target="-1" midi_trigger="1" midi_message="0x90,0x90,0,0" midi_scale="0,16383" kbmouse_target="-1" kbmouse_trigger="1" kbmouse_message="0,0,0" kbmouse_scale="0,1,0,1"/>
  11 +<VARIABLE name="attraction_y=0.5" send="0" osc_target="0" osc_trigger="1" osc_message="/RingArea/attraction_y" midi_target="-1" midi_trigger="1" midi_message="0x90,0x90,0,0" midi_scale="0,16383" kbmouse_target="-1" kbmouse_trigger="1" kbmouse_message="0,0,0" kbmouse_scale="0,1,0,1"/>
  12 +</WINDOW>
  13 +</WINDOW>
  14 +</JZML>

0 comments on commit fa8321f

Please sign in to comment.
Something went wrong with that request. Please try again.