annotate utils/export.lisp @ 316:d9193c44b207
twiddle midi-db import example
Ignore-this: cf975529b1d8ad8af507e7dd2144ccea
darcs-hash:20100416180846-16a00-a91855cc12370a9198448353f4438647d4cdfdae.gz
author |
j.forth <j.forth@gold.ac.uk> |
date |
Fri, 16 Apr 2010 19:08:46 +0100 |
parents |
6af1f19a4475 |
children |
|
rev |
line source |
j@290
|
1 (cl:in-package #:amuse-utils)
|
j@290
|
2
|
j@290
|
3 (defun beats->seconds (composition &optional (stream t))
|
j@290
|
4 "Prints a table of beat timepoints in seconds."
|
j@290
|
5 (loop for i from 0 to (timepoint (cut-off composition))
|
j@290
|
6 do (format stream
|
j@290
|
7 "~A~C~F~%" i #\Tab
|
j@290
|
8 (amuse-utils:beats-to-seconds
|
j@290
|
9 (make-moment i) composition))))
|
j@290
|
10
|
j@290
|
11 (defun export-data-from-composition (function composition pathname)
|
j@290
|
12 "Function that applies another function to a composition, witing
|
j@290
|
13 the output to a file, e.g. use this to call beats->seconds."
|
j@290
|
14 (with-open-file (stream pathname
|
j@290
|
15 :direction :output
|
j@290
|
16 :if-exists :supersede)
|
j@290
|
17 (funcall function composition stream)))
|
j@290
|
18
|
j@290
|
19 (defun export-data-from-dataset (dataset function pathname)
|
j@290
|
20 "Same as above except that processes an entire amuse-dataset."
|
j@290
|
21 (loop for composition-identifier in
|
j@290
|
22 (%list-slot-sequence-data dataset)
|
j@290
|
23 do (with-open-file (stream
|
j@290
|
24 (concatenate 'string pathname
|
j@290
|
25 (princ-to-string
|
j@290
|
26 (composition-id
|
j@290
|
27 composition-identifier)))
|
j@290
|
28 :direction :output
|
j@290
|
29 :if-exists :supersede)
|
j@290
|
30 (funcall function
|
j@290
|
31 (get-composition composition-identifier) stream))))
|