# HG changeset patch # User j.forth # Date 1247763728 -3600 # Node ID 6af1f19a44759402037666f3bd52c42a9ae7b7c4 # Parent 2519652145c3df305428ad65f0a9660882c68ad3 Add (David's) function for converting beats into seconds. Ignore-this: c720d6d4b4d8d7eec42cddc7bcd8f26 darcs-hash:20090716170208-16a00-6cca92c55db29b8378605f411e1dc4ff33f6d1b8.gz diff -r 2519652145c3 -r 6af1f19a4475 utils/export.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils/export.lisp Thu Jul 16 18:02:08 2009 +0100 @@ -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))))