# HG changeset patch # User j.forth # Date 1298546598 0 # Node ID 87320b5ba2e59f17b2a21e9ea4b4c666624561ab # Parent 38593563153265e826a543d016ea2fa706142671 Add (David's) function for converting beats into seconds. Ignore-this: c720d6d4b4d8d7eec42cddc7bcd8f26 darcs-hash:20090716170208-16a00-6cca92c55db29b8378605f411e1dc4ff33f6d1b8.gz committer: Jamie Forth diff -r 385935631532 -r 87320b5ba2e5 utils/export.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils/export.lisp Thu Feb 24 11:23:18 2011 +0000 @@ -0,0 +1,31 @@ +(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))))