changeset 25:a6b1cc001232

Don't use framer for playback -- it's mono only
author Chris Cannam
date Thu, 20 Dec 2012 15:25:46 +0000
parents ad5149048604
children 0d03455c105b
files framer.yeti playback.yeti
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/framer.yeti	Thu Dec 20 15:13:30 2012 +0000
+++ b/framer.yeti	Thu Dec 20 15:25:46 2012 +0000
@@ -1,6 +1,11 @@
 
 module framer;
 
+/**
+ * Framer expresses a stream (or a file) as a lazy list of (possibly
+ * overlapping) frames of mono data.
+ */
+
 vec = load fvector;
 block = load block;
 af = load audiofile;
--- a/playback.yeti	Thu Dec 20 15:13:30 2012 +0000
+++ b/playback.yeti	Thu Dec 20 15:25:46 2012 +0000
@@ -20,7 +20,6 @@
     bb#order(ByteOrder#LITTLE_ENDIAN);
     sb = bb#asShortBuffer();
     for [0..len-1] do i: sb#put(i, samples[i] * 32767.0); () done;
-    println "writing \(nb) bytes";
     actual = line#write(bytes, 0, nb); 
     ());
 
@@ -42,9 +41,11 @@
 playStream stream =
    (line = open { rate = stream.sampleRate, channels = stream.channels };
     blocksize = 10240;
-    line.play (map (ch.mixedFromInterleavedTo line.channels stream.channels)
-                   (fr.frames blocksize stream));
-    line.close());
+    not stream.finished? loop
+        line.play [(ch.mixedFromInterleavedTo line.channels stream.channels
+                    (stream.readInterleaved blocksize))];
+    line.close();
+    stream.close());
 
 playFile filename = playStream (af.open filename);