From 1162a42218d0c396891fb1caac2dc1631ee45f51 Mon Sep 17 00:00:00 2001 From: Aria Date: Sat, 11 Oct 2025 01:28:31 -0500 Subject: [PATCH] One more example --- packages/core/pattern.mjs | 11 ++++++++--- test/__snapshots__/examples.test.mjs.snap | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index de073db63..dd6850037 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -3535,7 +3535,7 @@ export const morph = (frompat, topat, bypat) => { return frompat.innerBind((from) => topat.innerBind((to) => bypat.innerBind((by) => _morph(from, to, by)))); }; -const TIMELINES = { +export const TIMELINES = { currentOffsets: {}, previousOffsets: {}, }; @@ -3554,10 +3554,15 @@ const TIMELINES = { * @example * s("tri").seg(8).n(irand(12)).scale("G#:minor").lpf(400).room(2) * .timeline("<1 -1 1 2>") + * @example + * $: n("[0 .. 6]/4").scale("F:minor") + * // Execute the following line at any point in the session + * // and it will always start on note 0 + * // $: n("[0 .. 6]/4").scale("F:minor").timeline(2) */ const timeline = register('timeline', (id, pat) => { - // TODO: This is only included to demonstrate the possible options. We should pick one - // before merging + // TODO: This hard-coding of `behavior` and the switch below are only included to demonstrate + // the possible reset options. We should pick one before merging const behavior = 0; if (typeof id !== 'number') { logger(`[query] ${id} is not a valid timeline id. Please ensure it is a number. Defaulting to timeline 1.`); diff --git a/test/__snapshots__/examples.test.mjs.snap b/test/__snapshots__/examples.test.mjs.snap index de668c88f..585871bfc 100644 --- a/test/__snapshots__/examples.test.mjs.snap +++ b/test/__snapshots__/examples.test.mjs.snap @@ -10846,6 +10846,21 @@ exports[`runs examples > example "take" example index 2 1`] = ` exports[`runs examples > example "timeline" example index 0 1`] = `[]`; +exports[`runs examples > example "timeline" example index 1 1`] = ` +[ + "[ 0/1 → 4/7 | note:F3 ]", + "[ (4/7 → 1/1) ⇝ 8/7 | note:G3 ]", + "[ 4/7 ⇜ (1/1 → 8/7) | note:G3 ]", + "[ 8/7 → 12/7 | note:Ab3 ]", + "[ (12/7 → 2/1) ⇝ 16/7 | note:Bb3 ]", + "[ 12/7 ⇜ (2/1 → 16/7) | note:Bb3 ]", + "[ 16/7 → 20/7 | note:C4 ]", + "[ (20/7 → 3/1) ⇝ 24/7 | note:Db4 ]", + "[ 20/7 ⇜ (3/1 → 24/7) | note:Db4 ]", + "[ 24/7 → 4/1 | note:Eb4 ]", +] +`; + exports[`runs examples > example "tour" example index 0 1`] = ` [ "[ 0/1 → 1/8 | note:e s:folkharp ]",