# HG changeset patch # User Chris Cannam # Date 1369845147 -3600 # Node ID f3784641245f052cb42bf5b0b709b2c28f014f88 # Parent 7f000ae124dbf7322598238e80345b112811ca80 Start on un-framing (does not build) diff -r 7f000ae124db -r f3784641245f yetilab/stream/framer.yeti --- 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); diff -r 7f000ae124db -r f3784641245f yetilab/stream/syntheticstream.yeti --- 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, }