summaryrefslogtreecommitdiff
path: root/tran/fromobject.alg
diff options
context:
space:
mode:
Diffstat (limited to 'tran/fromobject.alg')
-rw-r--r--tran/fromobject.alg37
1 files changed, 37 insertions, 0 deletions
diff --git a/tran/fromobject.alg b/tran/fromobject.alg
new file mode 100644
index 0000000..f119a7f
--- /dev/null
+++ b/tran/fromobject.alg
@@ -0,0 +1,37 @@
+(FROMOBJ-ALG
+ (NAME "fromobject")
+ (ARGUMENTS ("time_type" "t0") ("rate_type" "sr") ("LVAL" "src"))
+ (SUPPORT-FUNCTIONS "
+/* IMPLEMENTATION NOTE:
+ * The src argument is an XLisp object that returns either a
+ * FLONUM sample or NIL. The output of fromobj is simply the
+ * sequence of the samples.
+ */
+
+#include \"samples.h\"
+")
+
+ (SAMPLE-RATE "sr")
+ (STATE
+ ("boolean" "done" "false")
+ ("LVAL" "src" "src"))
+
+ (OUTER-LOOP " if (susp->done) {
+ togo = 0; /* indicate termination */
+ break; /* we're done */
+ }
+")
+ (INNER-LOOP
+" LVAL rslt = xleval(cons(s_send, cons(src,
+ consa(s_next))));
+ if (floatp(rslt)) {
+ output = (sample_type) getflonum(rslt);
+ } else {
+ done = true;
+ /* adjust togo to what it should have been */
+ break;
+ }")
+ (CONSTANT "length" "samples" "array" "src")
+ (TERMINATE COMPUTED)
+)
+