Change name to setDefaultJoin

This commit is contained in:
Aria 2026-01-22 14:24:45 -06:00
parent d79d122f68
commit 0001d9c27b
3 changed files with 11 additions and 12 deletions

View file

@ -1257,20 +1257,19 @@ const ALIGNMENT_KEYS = ALIGNMENTS.map((how) => how.toLowerCase());
})(); })();
/** /**
* Sets the default [alignment](https://strudel.cc/technical-manual/alignment/) to be used by Strudel. * Sets the default method of combining events from two patterns (aka [alignment](https://strudel.cc/technical-manual/alignment/)) in Strudel.
* The default default alignment is `in`, meaning that patterns to the left will (typically) dictate * The default method is 'in', meaning that patterns to the left will (typically) dictate the event timings when combined with patterns to the right.
* the event timings when combined with patterns to the right. By changing alignment to `out`, the opposite * By changing alignment to 'out', the opposite will happen. With 'mix', they will combine their event timings.
* will happen. With `mix`, they will combine their event timings.
* *
* Note that we say the _default_ alignment, because alignments can also be set explicitly with calls like * Note that we say the _default_ method, because alignments can also be set explicitly with calls like
* `add.mix`, `set.squeeze`, etc. * 'add.mix', 'set.squeeze', etc.
* *
* @param {string} name Default alignment to use. Options: 'in', 'out', 'mix', 'squeeze', 'squeezeout', 'reset', 'restart', 'poly' * @param {string} method Default join method to use. Options: 'in', 'out', 'mix', 'squeeze', 'squeezeout', 'reset', 'restart', 'poly'
* @example * @example
* setDefaultAlignment('mix') // also try 'in', 'out', 'squeeze', etc. * setDefaultJoin('mix') // also try 'in', 'out', 'squeeze', etc.
* s("saw").vel("1 0.5").note("F A C E").delay("0 0.2 0.3") * s("saw").vel("1 0.5").note("F A C E").delay("0 0.2 0.3")
*/ */
export const setDefaultAlignment = (alignment) => { export const setDefaultJoin = (alignment) => {
alignment = alignment?.toLowerCase(); alignment = alignment?.toLowerCase();
if (DEFAULT_ALIGNMENT !== alignment && ALIGNMENT_KEYS.includes(alignment)) { if (DEFAULT_ALIGNMENT !== alignment && ALIGNMENT_KEYS.includes(alignment)) {
DEFAULT_ALIGNMENT = alignment; DEFAULT_ALIGNMENT = alignment;

View file

@ -10874,7 +10874,7 @@ exports[`runs examples > example "seqPLoop" example index 0 1`] = `
] ]
`; `;
exports[`runs examples > example "setDefaultAlignment" example index 0 1`] = ` exports[`runs examples > example "setDefaultJoin" example index 0 1`] = `
[ [
"[ 0/1 → 1/4 | s:saw velocity:1 note:F delay:0 ]", "[ 0/1 → 1/4 | s:saw velocity:1 note:F delay:0 ]",
"[ 1/4 → 1/3 | s:saw velocity:1 note:A delay:0 ]", "[ 1/4 → 1/3 | s:saw velocity:1 note:A delay:0 ]",

View file

@ -1,9 +1,9 @@
import { afterEach } from 'vitest'; import { afterEach } from 'vitest';
import { useRNG } from './packages/core/signal.mjs'; import { useRNG } from './packages/core/signal.mjs';
import { setDefaultAlignment } from './packages/core/pattern.mjs'; import { setDefaultJoin } from './packages/core/pattern.mjs';
afterEach(() => { afterEach(() => {
// Avoid bleed between tests // Avoid bleed between tests
useRNG('legacy'); useRNG('legacy');
setDefaultAlignment('in'); setDefaultJoin('in');
}); });