@@ -37,25 +37,28 @@ double expected = 0;
3737 "y = a++;" \
3838 "next = now + period;"
3939
40- /* schedule next periodic event (explicit start time) */
41- #define NOW_W_START \
42- "period = %g;" \
43- "start = 10;" \
44- "y = 1;" \
45- "next = (floor((now - start) / period) + 1) * period + start;"
40+ /* schedule next periodic event from current time (explicit phase)
41+ * we "round up" when calculating num periods since start if closer than 0.999 */
42+ #define NOW_W_START \
43+ "period = %g;" \
44+ "start = 10;" \
45+ "y = 1;" \
46+ "next = (floor((now - start + 0.001) / period) + 1) * period + start;"
4647
47- /* schedule next periodic event (implicit start time) */
48+ /* better to schedule by incrementing the `next` timestamp for drift-free timing */
49+ /* schedule next periodic event (implicit phase) */
4850#define NEXT \
4951 "period = %g;" \
5052 "y = 1;" \
5153 "next += period;"
5254
53- /* better to schedule by incrementing the `next` timestamp for drift-free timing */
55+ /* schedule next periodic event (explicit phase)
56+ * we "round up" when calculating num periods since start if closer than 0.999 */
5457#define NEXT_W_START \
5558 "period = %g;" \
5659 "start = 10;" \
5760 "y = _x;" \
58- "next = (floor((next - start) / period) + 1) * period + start;"
61+ "next = (floor((next - start + 0.001 ) / period) + 1) * period + start;"
5962
6063/* if we track num_periods it is much cheaper to calculate `(n++)*period+start`
6164 * also have access to beat number which could be useful
@@ -112,6 +115,9 @@ double expected = 0;
112115 "y = period;" \
113116 "next += period;"
114117
118+ #define RANDOM \
119+ "p = %g; r = uniform(p) + p * 0.5; y = r; next += r;"
120+
115121//"new{-1}=0; period = ema(new?0.1:(t_x')
116122
117123/* TODO: need unmodified t_x to estimate timebase offset
@@ -167,10 +173,12 @@ test_config test_configs[] = {
167173 { 24 , DOWNSAMPLE , MPR_LOC_DST , 1.95 , 2.05 },
168174 { 25 , QUANTIZE , MPR_LOC_SRC , 1.65 , 1.90 },
169175 { 26 , QUANTIZE , MPR_LOC_DST , 1.65 , 1.90 },
170- // { 21, SYNC_LOCAL, MPR_LOC_SRC, 2.0, 2.0 },
171- // { 22, SYNC_LOCAL, MPR_LOC_DST, 2.0, 2.0 },
172- // { 23, SYNC_REMOTE, MPR_LOC_SRC, 2.0, 2.0 },
173- // { 24, SYNC_REMOTE, MPR_LOC_DST, 2.0, 2.0 },
176+ { 27 , RANDOM , MPR_LOC_SRC , 0.75 , 1.25 },
177+ { 28 , RANDOM , MPR_LOC_DST , 0.75 , 1.25 },
178+ // { 29, SYNC_LOCAL, MPR_LOC_SRC, 2.0, 2.0 },
179+ // { 30, SYNC_LOCAL, MPR_LOC_DST, 2.0, 2.0 },
180+ // { 31, SYNC_REMOTE, MPR_LOC_SRC, 2.0, 2.0 },
181+ // { 32, SYNC_REMOTE, MPR_LOC_DST, 2.0, 2.0 },
174182
175183};
176184const int NUM_TESTS = sizeof (test_configs )/sizeof (test_configs [0 ]);
0 commit comments