changeset 282:f3784641245f

Start on un-framing (does not build)
author Chris Cannam
date Wed, 29 May 2013 17:32:27 +0100
parents 7f000ae124db
children e330ac62703b
files yetilab/stream/framer.yeti yetilab/stream/syntheticstream.yeti
diffstat 2 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/yetilab/stream/framer.yeti	Tue May 28 20:41:11 2013 +0100
+++ b/yetilab/stream/framer.yeti	Wed May 29 17:32:27 2013 +0100
@@ -13,6 +13,7 @@
 fft = load yetilab.transform.fft;
 mat = load yetilab.matrix;
 ch = load yetilab.stream.channels;
+syn = load yetilab.stream.syntheticstream;
 
 blockList framesize stream =
     if stream.finished? then
@@ -57,6 +58,35 @@
             framesize (map \(vec.zeros framesize) [0..stream.channels-1]);
     fi;
 
+streamContiguous rate framesize fr =
+    if empty? frames then
+        syn.empty rate 1
+    else
+        var position = 0;
+        var frames = fr;
+        var fini = false;
+        channels = mat.height (head frames); // so we don't need to keep head ptr
+        {
+            get position () = position,
+            get channels () = channels,
+            get sampleRate () = rate,
+            get available () = if fini then Known 0 else Unknown () fi,
+            get finished? () = fini,
+                            
+                            
+            close = \(),
+        }
+    fi;
+
+//!!! doc: convert frames back to a stream
+streamed rate { framesize, hop } frames =
+    if framesize == hop then
+        streamContiguous rate framesize frames
+    else
+        //!!! OLA
+        syn.empty rate 1;
+    fi;
+
 monoFrames params stream =
     map ch.mixedDown (frames params stream);
 
--- a/yetilab/stream/syntheticstream.yeti	Tue May 28 20:41:11 2013 +0100
+++ b/yetilab/stream/syntheticstream.yeti	Wed May 29 17:32:27 2013 +0100
@@ -52,12 +52,24 @@
         close = \(),
     });
 
+empty rate channels = // degenerate stream with no data in it, occasionally useful
+    {
+        get position () = 0,
+        get channels () = channels,
+        get sampleRate () = rate,
+        get available () = Known 0,
+        get finished? () = true,
+        read count = mat.zeroSizeMatrix (),
+        close = \(),
+    };
+
 {
     generated is number -> (number -> number) -> stream, 
     precalculated is number -> vector -> stream,
     sinusoid is number -> number -> stream, 
     whiteNoise is number -> stream,
     silent is number -> stream,
+    empty = number -> number -> stream,
 }