atroscine

darcs-hash:20050811090231-2648a-b62b40c5f0df7e8f5231240a1d3698146582da42.gz
This commit is contained in:
nik gaffney 2005-08-11 17:02:31 +08:00
parent 814298e0dc
commit 9bcc4ffcc2
4 changed files with 24 additions and 22 deletions

View file

@ -22,7 +22,7 @@ or via asdf-install.. .
limitations limitations
- doesnt send nested bundles or timetags later than 'now' - doesnt send nested bundles or timetags later than 'now'
- will most likely crash if the input is malformed - will raise an exception if the input is malformed
- doesnt do any pattern matching on addresses - doesnt do any pattern matching on addresses
- sbcl/cmucl specific float en/decoding - sbcl/cmucl specific float en/decoding
- only supports the type(tag)s specified in the OSC spec - only supports the type(tag)s specified in the OSC spec
@ -34,11 +34,11 @@ things to do
- portable en/decoding of floats -=> ieee754 tests - portable en/decoding of floats -=> ieee754 tests
- doubles and other defacto typetags - doubles and other defacto typetags
- correct en/decoding of timetags - correct en/decoding of timetags
- asdf-installable
changes changes
2005-03-16
- packaged as an asdf installable lump
2005-03-11 2005-03-11
- bundle and blob en/de- coding - bundle and blob en/de- coding
2005-03-05 2005-03-05

View file

@ -13,8 +13,10 @@
;; ;;
;; Commentry ;; Commentry
;; ;;
;; These examples are currently sbcl specific (ports welcome!) ;; These examples are currently sbcl specific [as is the float code],
;; but should still be able to explain enough to get started. .. ;; but should be easily modifyable to work with trivial-sockets, or
;; something similar for portablity. these examples should still be
;; able to explain enough to get you started. ..
;; ;;
;; eg. listen on port 6667 for incoming msgs ;; eg. listen on port 6667 for incoming msgs
;; ;;
@ -62,7 +64,7 @@
(socket-receive in buffer nil) (socket-receive in buffer nil)
(let ((oscuff (osc:decode-bundle buffer))) (let ((oscuff (osc:decode-bundle buffer)))
(format t "glonked -=> message with ~S~% arg(s)" (length oscuff)) (format t "glonked -=> message with ~S~% arg(s)" (length oscuff))
(write-stream-t1 oscuff stream))) (write-stream-t1 stream oscuff)))
(when in (socket-close in)) (when in (socket-close in))
(when out (socket-close out)))))) (when out (socket-close out))))))
@ -70,7 +72,7 @@
(defun make-udp-socket() (defun make-udp-socket()
(make-instance 'inet-socket :type :datagram :protocol :udp)) (make-instance 'inet-socket :type :datagram :protocol :udp))
(defun write-stream-t1 (osc-message stream) (defun write-stream-t1 (stream osc-message)
"writes a given message to a stream. keep in mind that when using a buffered "writes a given message to a stream. keep in mind that when using a buffered
stream any funtion writing to the stream should call (finish-output stream) stream any funtion writing to the stream should call (finish-output stream)
after it sends the mesages,. ." after it sends the mesages,. ."

View file

@ -7,5 +7,5 @@
:author "nik gaffney <nik@fo.am>" :author "nik gaffney <nik@fo.am>"
:licence "LLGPL" :licence "LLGPL"
:description "The Open Sound Control protocol, aka OSC" :description "The Open Sound Control protocol, aka OSC"
:components ((:file "osc")) :version "0.1"
) :components ((:file "osc")))

View file

@ -28,8 +28,9 @@
;; http://www.cnmat.berkeley.edu/OpenSoundControl/ ;; http://www.cnmat.berkeley.edu/OpenSoundControl/
;; ;;
;; - doesnt send nested bundles or timetags later than 'now' ;; - doesnt send nested bundles or timetags later than 'now'
;; - will most likely crash if the input is malformed ;; - malformed input -> exception
;; - int32 en/de-coding based on code (c) Walter C. Pelissero ;; - int32 en/de-coding based on code (c) Walter C. Pelissero
;; - unknown types are sent as 'blobs' which may or may not be an issue
;; ;;
;; see the README file for more details... ;; see the README file for more details...
;; ;;
@ -90,7 +91,8 @@
i => #(105) => int32 i => #(105) => int32
f => #(102) => float f => #(102) => float
s => #(115) => string s => #(115) => string
b => #(98) => blob" b => #(98) => blob
and considers non int/float/string data to be a blob."
(let ((lump (make-array 0 :adjustable t (let ((lump (make-array 0 :adjustable t
:fill-pointer t :fill-pointer t
@ -104,10 +106,9 @@
(integer (write-to-vector #\i)) (integer (write-to-vector #\i))
(float (write-to-vector #\f)) (float (write-to-vector #\f))
(simple-string (write-to-vector #\s)) (simple-string (write-to-vector #\s))
(simple-vector (write-to-vector #\b)) (t (write-to-vector #\b)))))
(t (error "can only encode ints, floats or strings"))))
(cat lump (cat lump
(pad (padding-length (length lump))))))) (pad (padding-length (length lump))))))
(defun encode-data (data) (defun encode-data (data)
"encodes data in a format suitable for an OSC message" "encodes data in a format suitable for an OSC message"
@ -119,8 +120,7 @@
(integer (enc encode-int32)) (integer (enc encode-int32))
(float (enc encode-float32)) (float (enc encode-float32))
(simple-string (enc encode-string)) (simple-string (enc encode-string))
(simple-vector (enc encode-blob)) (t (enc encode-blob))))
(t (error "wrong type. turn back"))))
lump))) lump)))
@ -197,11 +197,11 @@
result) result)
(setf acc (subseq acc pointer)))) (setf acc (subseq acc pointer))))
((eq x (char-code #\b)) ((eq x (char-code #\b))
(let ((size (decode-int32 (subseq acc 0 4)))) (let* ((size (decode-int32 (subseq acc 0 4)))
(let ((end (padded-length (+ 4 size)))) (end (padded-length (+ 4 size))))
(push (decode-blob (subseq acc 0 end)) (push (decode-blob (subseq acc 0 end))
result) result)
(setf acc (subseq acc end))))) (setf acc (subseq acc end))))
(t (error "unrecognised typetag")))) (t (error "unrecognised typetag"))))
tags) tags)
(nreverse result)))) (nreverse result))))
@ -323,7 +323,7 @@
(+ s (- 4 (mod s 4)))) (+ s (- 4 (mod s 4))))
(defun string-padding (string) (defun string-padding (string)
"returns the padding required for a given osc string" q "returns the padding required for a given osc string"
(declare (type simple-string string)) (declare (type simple-string string))
(pad (- 4 (mod (length string) 4)))) (pad (- 4 (mod (length string) 4))))