moschatels (ints)
This commit is contained in:
parent
5c7ed79a7f
commit
f647738ccc
2 changed files with 24 additions and 17 deletions
|
@ -48,11 +48,18 @@
|
||||||
(is (equalp
|
(is (equalp
|
||||||
(osc::encode-int32 16843009) #(1 1 1 1)))
|
(osc::encode-int32 16843009) #(1 1 1 1)))
|
||||||
(is (equalp
|
(is (equalp
|
||||||
(osc::decode-int32 #(1 1 11 111)) 16845679))
|
(osc::decode-int32 #(127 255 255 255))
|
||||||
|
(osc::decode-uint32 #(127 255 255 255))))
|
||||||
(is (equalp
|
(is (equalp
|
||||||
(osc::encode-int32 -16843010) #(254 254 254 254)))
|
(osc::encode-int32 -16843010) #(254 254 254 254)))
|
||||||
(is (equalp
|
(is (equalp
|
||||||
(osc::decode-int32 #(255 255 255 255)) -1)))
|
(osc::decode-int32 #(127 255 255 255)) #x7FFFFFFF))
|
||||||
|
(is (equalp
|
||||||
|
(osc::encode-int32 #xFFFFFFFF) #(255 255 255 255)))
|
||||||
|
(is (equalp
|
||||||
|
(osc::decode-int32 #(255 255 255 255)) -1))
|
||||||
|
(is (equalp
|
||||||
|
(osc::decode-uint32 #(255 255 255 255)) #xFFFFFFFF)))
|
||||||
|
|
||||||
(test osc-string
|
(test osc-string
|
||||||
"OSC string encoding tests."
|
"OSC string encoding tests."
|
||||||
|
@ -113,9 +120,9 @@
|
||||||
(is (equalp
|
(is (equalp
|
||||||
(osc::decode-float64 #(64 55 25 153 153 153 153 154)) 23.1d0))
|
(osc::decode-float64 #(64 55 25 153 153 153 153 154)) 23.1d0))
|
||||||
(is (equalp
|
(is (equalp
|
||||||
(osc::decode-float64 #(1 1 1 1 1 1 1 1)) 7.748604185489348d-304))
|
(osc::decode-float64 #(1 1 1 1 1 1 1 1)) 7.748604185489348d-304))
|
||||||
(is (equalp
|
(is (equalp
|
||||||
(osc::decode-float64 #(128 0 0 0 0 0 0 0)) -0.0d0))
|
(osc::decode-float64 #(128 0 0 0 0 0 0 0)) -0.0d0))
|
||||||
(is (equalp
|
(is (equalp
|
||||||
(osc::decode-float64 #(255 240 0 0 0 0 0 0))
|
(osc::decode-float64 #(255 240 0 0 0 0 0 0))
|
||||||
:NEGATIVE-INFINITY))
|
:NEGATIVE-INFINITY))
|
||||||
|
@ -327,15 +334,15 @@
|
||||||
(test v1.1-required-data-types
|
(test v1.1-required-data-types
|
||||||
"OSC data encoding test. All required types for v1.1"
|
"OSC data encoding test. All required types for v1.1"
|
||||||
(is (equalp
|
(is (equalp
|
||||||
#(44 105 104 115 102 100 98 0)
|
#(44 105 104 115 102 100 98 0)
|
||||||
(osc::encode-typetags '(3
|
(osc::encode-typetags '(3
|
||||||
4294967297
|
4294967297
|
||||||
"test"
|
"test"
|
||||||
2.1e2
|
2.1e2
|
||||||
2.1d23
|
2.1d23
|
||||||
#(1 2 3 4)
|
#(1 2 3 4)
|
||||||
;; (osc::encode-timetag :now)
|
;; (osc::encode-timetag :now)
|
||||||
)))))
|
)))))
|
||||||
|
|
||||||
(test v1.1-keyword-typetags
|
(test v1.1-keyword-typetags
|
||||||
"OSC typetag encoding test."
|
"OSC typetag encoding test."
|
||||||
|
|
8
osc.lisp
8
osc.lisp
|
@ -325,15 +325,15 @@
|
||||||
(defun decode-int32 (s)
|
(defun decode-int32 (s)
|
||||||
"4 byte -> 32 bit int -> two's complement (in network byte order)"
|
"4 byte -> 32 bit int -> two's complement (in network byte order)"
|
||||||
(let ((i (decode-uint32 s)))
|
(let ((i (decode-uint32 s)))
|
||||||
(if (>= i #.(1- (expt 2 31)))
|
(if (>= i (expt 2 31))
|
||||||
(- (- #.(expt 2 32) i))
|
(- (- (expt 2 32) i))
|
||||||
i)))
|
i)))
|
||||||
|
|
||||||
(defun decode-int64 (s)
|
(defun decode-int64 (s)
|
||||||
"8 byte -> 64 bit int -> two's complement (in network byte order)"
|
"8 byte -> 64 bit int -> two's complement (in network byte order)"
|
||||||
(let ((i (decode-uint64 s)))
|
(let ((i (decode-uint64 s)))
|
||||||
(if (>= i #.(1- (expt 2 63)))
|
(if (>= i (expt 2 63))
|
||||||
(- (- #.(expt 2 64) i))
|
(- (- (expt 2 64) i))
|
||||||
i)))
|
i)))
|
||||||
|
|
||||||
;; floats are encoded using ieee-floats library for brevity and compatibility
|
;; floats are encoded using ieee-floats library for brevity and compatibility
|
||||||
|
|
Loading…
Reference in a new issue