Permalink
Browse files

RingArea tests.

  • Loading branch information...
1 parent 86d2619 commit fa8321fcf272794c00924e1a5da72b72a884069a @cassiel committed Jul 16, 2012
Showing with 119 additions and 109 deletions.
  1. +8 −0 TECH-NOTES.md
  2. +50 −100 scratch.clj
  3. +13 −1 src/sifaka/object_common.clj
  4. +34 −8 src/sifaka/objects.clj
  5. +14 −0 test-data/one-ringarea.jzml
View
@@ -2,6 +2,9 @@
## General
+- We need to generalise ADSRH (e.g. in Pads): these actually take
+ expressions.
+
## Specific Objects
### Container
@@ -16,3 +19,8 @@
- There's no clear documentation for the properties `Multilabel` and
`Multicolor` - I'm guessing these are scriptable/OSC controllable
only. For now, they're always off.
+
+- Need to generalise ADSRH (see above).
+
+- To-do: "Capture", "light". (Light can apparently be a vector or
+ expression; we should investigate this.)
View
@@ -18,92 +18,6 @@
(with-out-str (px/prxml [:p {:class "greet"} [:i "Ladies & gentlemen"]]))
-;; Do everything in bytes; the Lemur's OSC spec uses blobs, and I doubt it's going
-;; to handle any non-ASCII encoding such as UTF-8.
-
-
-(def xxx (byte-array (map byte [2 3 4])))
-
-(def yyy (byte-array 10))
-
-(System/arraycopy xxx 0 yyy 0 (count xxx))
-
-(map #(get yyy %) (range (count yyy)))
-
-;; --- OSC experiments (obsolete: the Lemur protocol isn't OSC).
-
-(def a (atom nil))
-
-(def LEMUR_HOST "localhost")
-(def LEMUR_HOST "10.0.0.125")
-(def LEMUR_PORT 8001)
-
-; loopback test.
-(def server (osc-server 8001))
-(osc-handle server "/interface" (fn [msg] (reset! a msg)))
-(osc-close server)
-
-(def client (osc-client LEMUR_HOST LEMUR_PORT))
-
-(osc-send client
- "/interface"
- (count ba)
- (int 0)
- (int (u/crc ba))
- ba)
-
-@a
-
-;; --- XML file into byte-array.
-
-(def ba (io/read-file "test-data/tiny.jzml"))
-(count ba)
-
-;; --- Bespoke, Lemur-specific broken OSC:
-
-;; Header is 20 bytes / 5 int32s.
-;; 0: padded payload length + 16
-;; 1+2: "/jzml" padded
-;; 3: ",b" padded
-;; 4: unpadded payload length
-;;
-;; Actual (padded) payload is sent "raw", in packets limited to 1448 bytes.
-
-
-(def HEADER_SIZE_BYTES 20)
-
-
-
-(def chan (DatagramChannel/open))
-(.connect chan (InetSocketAddress. "10.0.0.125" 8002))
-
-
-
-(.write chan (ByteBuffer/wrap (byte-array (map byte [1 2 3 4]))))
-
-
-
-(.disconnect chan)
-
-(let
- [ba (io/pad-string-to-bytes "AB")]
- (map (partial get ba) (range (count ba))))
-
-(int \c)
-
-(map count
- (p/package-data (byte-array (map byte [1 2 3 4 5]))))
-
-
-(def ba (io/read-file "test-data/tiny_PREPPED.jzml"))
-(count ba)
-
-(io/transmit-payload "127.0.0.1" 8002 ba)
-(io/transmit-payload "10.0.0.125" 8002 ba)
-
-
-
-
(x/format-project-for-file [:fooble] [:gooble])
(x/format-project-for-upload [:fooble] [:gooble])
@@ -112,17 +26,7 @@
(with-out-str (p/prxml (x/fudge-container [100 100] [200 50] [80 80 80] [:foo])))
-(io/transmit-payload
- "10.0.0.125"
- 8002
- (.getBytes (x/format-project-for-upload
- (x/project "TestProject")
- (x/fudge-window (x/fudge-container
- [100 100]
- [200 200]
- [80 80 80]
- (x/fudge-container [5 5] [50 50] [255 255 255]))))))
-
+;; Nested container example. (container() takes varargs for the contents.)
(defn boz [size]
(if (< size 30)
@@ -147,7 +51,55 @@
(sp/sierpinski 3)
-(concat [1 2 3] [4 5 6])
+;; More examples.
+
+(io/transmit-payload
+ "10.0.0.125"
+ 8002
+ (.getBytes (x/format-project-for-upload
+ (x/project "TestProject")
+ (x/interface [(obj/container
+ {:position [100 100]
+ :size [300 300]
+ :colour [80 120 120]}
+ (obj/pads {:id 987
+ :name "pads"
+ :position [0 0]
+ :size [284 284]
+ :off-colour [50 50 50]
+ :on-colour [255 255 255]}))]))))
+
+(io/transmit-payload
+ "10.0.0.125"
+ 8002
+ (.getBytes (x/format-project-for-upload
+ (x/project "TestProject")
+ (x/interface [(obj/container
+ {:position [100 100]
+ :size [300 300]
+ :colour [80 120 120]}
+ (obj/ringarea {:id 987
+ :name "ra"
+ :position [0 0]
+ :size 284
+ :colour [150 150 150]}))]))))
+
+(io/transmit-payload
+ "10.0.0.125"
+ 8002
+ (.getBytes (x/format-project-for-upload
+ (x/project "TestProject")
+ (x/interface [(obj/container
+ {:position [10 10]
+ :size [700 700]
+ :colour [80 120 120]}
+ (map #(obj/ringarea
+ {:id %
+ :name (format "ra%d" %)
+ :position [(int (* 278 (inc (Math/sin (* % Math/PI 0.125)))))
+ (int (* 278 (inc (Math/cos (* % Math/PI 0.125)))))]
+ :size 120
+ :colour [(- 255 (* % 10)) 200 150]}) (range 16)))]))))
(io/transmit-payload
"10.0.0.125"
@@ -169,8 +121,6 @@
:off-colour c
:on-colour [255 0 0]}))))]))))
-(concat 1 2 [4 5])
-
;; -----
(obj/pads {:id 345
@@ -37,14 +37,26 @@
:osc_message (format "/%s/%s" object-name var-name)})
(defn variable
- ^{:doc "Common settings for an object variable. Value assumed to be float."}
+ ^{:doc "Common settings for an object variable. Value assumed to be float."}
[object-name var-name var-value]
[:VARIABLE (merge {:name (format "%s=%f" var-name var-value)
:send 0}
(base-osc-params object-name var-name)
fudge-midi-params
fudge-kbmouse-params)])
+(defn param
+ ^{:doc "Common settings for an object parameter."}
+ [obj-name param-name value]
+ [:PARAM (merge {:name (format "%s=" param-name)
+ :value value
+ :send 17 ; Is this the trigger mode?
+ :midi_scale "0,16363"
+ :osc_scale "0.0,1.0"}
+ (base-osc-params obj-name param-name)
+ fudge-midi-params
+ fudge-kbmouse-params)])
+
(defn window
^{:doc "Window phrase, with attributes (map) and sub-items (seq)."}
[attributes sub-items]
View
@@ -50,12 +50,38 @@
:multicolor 0
:multilabel 0}
(cons
- [:PARAM (merge {:name "x="
- :value 0.0
- :send 17
- :midi_scale "0,16363"
- :osc_scale "0.0,1.0"}
- (com/base-osc-params name "x")
- com/fudge-midi-params ; Actually, midi_trigger=1 here.
- com/fudge-kbmouse-params)]
+ (com/param name "x" 0.0)
(com/env name {}))))
+
+(defn ringarea
+ ^{:doc "RingArea control."}
+ [{id :id
+ name :name
+ [x y] :position
+ size :size
+ [r g b] :colour}]
+ (let [params [(com/param name "x" 0.5)
+ (com/param name "y" 0.5)]
+ variables [(com/variable name "attraction" 1.0)
+ (com/variable name "friction" 0.8)
+ (com/variable name "speed" 1.0)
+ (com/variable name "attraction_x" 0.5)
+ (com/variable name "attraction_y" 0.5)]]
+ (com/window {:class "RingArea"
+ :id id
+ :text name
+ :x x
+ :y y
+ :width size
+ :height size
+ :label 0
+ :state 1
+ :group 0
+ :send 1
+ :capture 1
+ :font "tahoma,10,0"
+ :osc_target -2
+ :midi_target -2
+ :kbmouse_target -2
+ :color (com/colour r g b)}
+ (concat params variables))))
@@ -0,0 +1,14 @@
+<JZML>
+<PROJECT version="3020" width="1024" height="724" osc_target="-2" midi_target="-2" kbmouse_target="-2"/>
+<WINDOW class="JAZZINTERFACE" text="Default" x="0" y="0" width="1024" height="724" state="1" group="0" font="tahoma,11,0" >
+<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">
+<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"/>
+<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"/>
+<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"/>
+<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"/>
+<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"/>
+<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"/>
+<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"/>
+</WINDOW>
+</WINDOW>
+</JZML>

0 comments on commit fa8321f

Please sign in to comment.