-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparse-vstpreset.ros
executable file
·45 lines (40 loc) · 1.41 KB
/
parse-vstpreset.ros
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
#|-*- mode:lisp -*-|#
#|
exec ros -Q -- $0 "$@"
|#
(progn ;;init forms
(ros:ensure-asdf)
#+quicklisp(ql:quickload '(:ieee-floats) :silent t)
)
(defpackage :ros.script.parse-vstpreset.3846062542
(:use :cl))
(in-package :ros.script.parse-vstpreset.3846062542)
(defun parse-vstpreset (stream)
(unless (and (= (read-byte stream nil :eof) (char-code #\V))
(= (read-byte stream nil :eof) (char-code #\S))
(= (read-byte stream nil :eof) (char-code #\T))
(= (read-byte stream nil :eof) (char-code #\3)))
(error "not vstpreset"))
(dotimes (n 4)
(read-byte stream))
(dotimes (n 32)
(read-byte stream))
(let ((bytes 0))
(dotimes (n 8)
(setf bytes (logior bytes (ash (read-byte stream nil :eof) (* 8 n)))))
(dotimes (n (floor bytes 8))
(format t "n = ~a: float = ~s~%"
n (loop
:named loop
:with bytes := 0
:for n :from 0 :below 8
:do (setf bytes (logior bytes (ash (read-byte stream nil :eof) (* 8 n))))
:finally (return-from loop (ieee-floats:decode-float64 bytes)))))))
(defun main (&rest argv)
(declare (ignorable argv))
(with-open-file (in (first argv)
:direction :input
:element-type '(unsigned-byte 8))
(parse-vstpreset in)))
;;; vim: set ft=lisp lisp: