From 73f33aac45b04ea7bc4f1fb994cc9305fadaf757 Mon Sep 17 00:00:00 2001 From: nik gaffney Date: Tue, 6 Dec 2005 03:07:01 +0800 Subject: [PATCH] semifloscular openmcl version of decode-float32 uses decode-uint32 for correct negative float values. darcs-hash:20051205190701-2648a-06b565475c79901f26175fd84374bdb0314381b6.gz --- README.txt | 3 +++ osc.asd | 2 +- osc.lisp | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.txt b/README.txt index 795dc97..64132f4 100644 --- a/README.txt +++ b/README.txt @@ -42,6 +42,9 @@ things to do in :osc-ex[tensions|tras] changes + 2005-12-05 + - version 0.3 + - fixed openmcl float bug (decode-uint32) 2005-11-29 - version 0.2 - openmcl float en/decoding diff --git a/osc.asd b/osc.asd index dbb5398..c850ef6 100644 --- a/osc.asd +++ b/osc.asd @@ -7,5 +7,5 @@ :author "nik gaffney " :licence "LLGPL" :description "The Open Sound Control protocol, aka OSC" - :version "0.2" + :version "0.3" :components ((:file "osc"))) diff --git a/osc.lisp b/osc.lisp index 58cb841..e1ce391 100644 --- a/osc.lisp +++ b/osc.lisp @@ -258,7 +258,7 @@ "ieee754 float from a vector of 4 bytes in network byte order" #+sbcl (sb-kernel:make-single-float (decode-int32 s)) #+cmucl (kernel:make-single-float (decode-int32 s)) - #+openmcl (CCL::HOST-SINGLE-FLOAT-FROM-UNSIGNED-BYTE-32 (decode-int32 s)) + #+openmcl (CCL::HOST-SINGLE-FLOAT-FROM-UNSIGNED-BYTE-32 (decode-uint32 s)) #-(or sbcl cmucl openmcl) (error "cant decode floats using this implementation")) (defun decode-int32 (s) @@ -271,6 +271,14 @@ (- 0 (- #x100000000 i)) i))) +(defun decode-uint32 (s) + "4 byte -> 32 bit unsigned int" + (let ((i (+ (ash (elt s 0) 24) + (ash (elt s 1) 16) + (ash (elt s 2) 8) + (elt s 3)))) + i)) + (defun encode-int32 (i) "convert an integer into a sequence of 4 bytes in network byte order." (declare (type integer i))