Mercurial > hg > may
changeset 474:0541d0d722df
Add pulseTrain
author | Chris Cannam |
---|---|
date | Wed, 30 Oct 2013 10:20:34 +0000 |
parents | 8e39fa8a6a1f |
children | ac3dd9a9d924 |
files | src/may/stream/syntheticstream.yeti src/may/stream/test/test_syntheticstream.yeti |
diffstat | 2 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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, }
--- 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