isosceles

darcs-hash:20050126143620-2648a-9ed0c63eccd67d10b88ab1b321f952b7345ec488.gz
This commit is contained in:
nik gaffney 2005-01-26 22:36:20 +08:00
parent b357030cea
commit dc9e11e3bc

View file

@ -7,8 +7,9 @@
;; This software is licensed under the terms of the Lisp Lesser GNU Public ;; This software is licensed under the terms of the Lisp Lesser GNU Public
;; License , known as the LLGPL. The LLGPL consists of a preamble and ;; License , known as the LLGPL. The LLGPL consists of a preamble and
;; the LGPL. Where these conflict, the preamble takes precedence. The ;; the LGPL. Where these conflict, the preamble takes precedence. The
;; LLGPL is available online at http://opensource.franz.com/preamble.html. ;; LLGPL is available online at http://opensource.franz.com/preamble.html
;; ;; and is distributed with this code (see: LICENCE and LGPL files)
;;
;; authors ;; authors
;; ;;
;; nik gaffney <nik@f0.am> ;; nik gaffney <nik@f0.am>
@ -40,7 +41,7 @@
;; - bundles ;; - bundles
;; - blobs ;; - blobs
;; Known BUGS ;; known BUGS
;; ;;
;; - multiple arg messages containing strings can corrupt further output. . ;; - multiple arg messages containing strings can corrupt further output. .
;; probably need to collect a few more testcases. . ;; probably need to collect a few more testcases. .
@ -48,10 +49,10 @@
;; changes ;; changes
;; ;;
;; Sat, 18 Dec 2004 15:41:26 +0100 ;; Sat, 18 Dec 2004 15:41:26 +0100
;; - initial version ;; - initial version, single args only
;; Mon, 24 Jan 2005 15:43:20 +0100 ;; Mon, 24 Jan 2005 15:43:20 +0100
;; - sends and receives multiple arguments ;; - sends and receives multiple arguments
;; - tests in osc-test.lisp ;; - tests in osc-test.lisp
;; ;;
@ -94,7 +95,7 @@
(simple-string (simple-string
(vector-push-extend (char-code #\s) lump)) (vector-push-extend (char-code #\s) lump))
(t (t
(error "unrecognised datatype")))) (error "can only encode ints, floats or string"))))
(cat lump (cat lump
(osc-pad (osc-padding-length (length lump)))))) (osc-pad (osc-padding-length (length lump))))))
@ -110,7 +111,7 @@
(simple-string (simple-string
(setf lump (cat lump (encode-string x)))) (setf lump (cat lump (encode-string x))))
(t (t
(error "wrong type")))) (error "wrong type. turn back"))))
lump)) lump))
(defun encode-string (string) (defun encode-string (string)
@ -181,11 +182,13 @@
(defun encode-float32 (f) (defun encode-float32 (f)
"encode an ieee754 float as a 4 byte vector. currently sbcl specifc" "encode an ieee754 float as a 4 byte vector. currently sbcl specifc"
#+sbcl (encode-int32 (sb-kernel:single-float-bits f))) #+sbcl (encode-int32 (sb-kernel:single-float-bits f))
#-sbcl (error "cant encode floats using this implementation"))
(defun decode-float32 (s) (defun decode-float32 (s)
"ieee754 float from a vector of 4 bytes in network byte order" "ieee754 float from a vector of 4 bytes in network byte order"
#+sbcl (sb-kernel:make-single-float (decode-int32 s))) #+sbcl (sb-kernel:make-single-float (decode-int32 s)))
#-sbcl (error "cant decode floats using this implementation"))
(defun decode-int32 (s) (defun decode-int32 (s)
"4 byte > 32 bit int > two's compliment (in network byte order)" "4 byte > 32 bit int > two's compliment (in network byte order)"
@ -228,8 +231,8 @@
;; utility functions for OSC slonking ;; utility functions for OSC slonking
(defmacro cat (s &rest body) (defun cat (&rest catatac)
`(concatenate '(vector *) ,s ,@body)) (apply #'concatenate '(vector *) catatac))
(defun osc-string-length (string) (defun osc-string-length (string)
"determines the length required for a padded osc string" "determines the length required for a padded osc string"