Mercurial > hg > amuse
view utils/export.lisp @ 242:66f9c2913ac7
twiddle midi-db import example
Ignore-this: cf975529b1d8ad8af507e7dd2144ccea
darcs-hash:20100416180846-16a00-a91855cc12370a9198448353f4438647d4cdfdae.gz
committer: Jamie Forth <j.forth@gold.ac.uk>
author | j.forth <j.forth@gold.ac.uk> |
---|---|
date | Thu, 24 Feb 2011 11:23:18 +0000 |
parents | 87320b5ba2e5 |
children |
line wrap: on
line source
(cl:in-package #:amuse-utils) (defun beats->seconds (composition &optional (stream t)) "Prints a table of beat timepoints in seconds." (loop for i from 0 to (timepoint (cut-off composition)) do (format stream "~A~C~F~%" i #\Tab (amuse-utils:beats-to-seconds (make-moment i) composition)))) (defun export-data-from-composition (function composition pathname) "Function that applies another function to a composition, witing the output to a file, e.g. use this to call beats->seconds." (with-open-file (stream pathname :direction :output :if-exists :supersede) (funcall function composition stream))) (defun export-data-from-dataset (dataset function pathname) "Same as above except that processes an entire amuse-dataset." (loop for composition-identifier in (%list-slot-sequence-data dataset) do (with-open-file (stream (concatenate 'string pathname (princ-to-string (composition-id composition-identifier))) :direction :output :if-exists :supersede) (funcall function (get-composition composition-identifier) stream))))