# HG changeset patch # User Chris Cannam # Date 1383128434 0 # Node ID 0541d0d722dfda7d2ceba53aa4111596effb8115 # Parent 8e39fa8a6a1f41ce93df29ccfcd3ac140bf297e9 Add pulseTrain diff -r 8e39fa8a6a1f -r 0541d0d722df src/may/stream/syntheticstream.yeti --- a/src/may/stream/syntheticstream.yeti Tue Oct 29 16:06:46 2013 +0000 +++ b/src/may/stream/syntheticstream.yeti Wed Oct 30 10:20:34 2013 +0000 @@ -34,6 +34,9 @@ whiteNoise rate = generated rate \((Math#random() * 2.0) - 1.0); +pulseTrain rate freq = + generated rate do n: if n % int (rate / freq) == 0 then 1 else 0 fi done; + silent rate = generated rate \0; @@ -116,6 +119,7 @@ precalculatedRepeated is number -> matrix -> stream, sinusoid is number -> number -> stream, whiteNoise is number -> stream, + pulseTrain is number -> number -> stream, silent is number -> stream, empty is number -> number -> stream, } diff -r 8e39fa8a6a1f -r 0541d0d722df src/may/stream/test/test_syntheticstream.yeti --- a/src/may/stream/test/test_syntheticstream.yeti Tue Oct 29 16:06:46 2013 +0000 +++ b/src/may/stream/test/test_syntheticstream.yeti Wed Oct 30 10:20:34 2013 +0000 @@ -37,6 +37,18 @@ compare str.position 6 ), +"pulseTrain": \( + // 2 pulses a second sampled 8 times a second + str = syn.pulseTrain 8 2; + compare str.position 0 and + compare str.channels 1 and + compare str.sampleRate 8 and + compare str.available (Infinite ()) and + compare str.finished? false and + compareApprox epsilon (vec.list (mat.getRow 0 (str.read 9))) [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ] and + compare str.position 9 +), + "silent": \( str = syn.silent 8; compare str.position 0 and