Merge pull request 'Add strans and scaleTrans as synonyms of scaleTranspose' (#1488) from TodePond/strudel:lu/strans into main

Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1488
This commit is contained in:
daslyfe 2025-08-03 18:34:12 +02:00
commit 03090e399c

View file

@ -143,6 +143,7 @@ export const transpose = register(['transpose', 'trans'], function transposeFn(i
* @name scaleTranspose * @name scaleTranspose
* @param {offset} offset number of steps inside the scale * @param {offset} offset number of steps inside the scale
* @returns Pattern * @returns Pattern
* @synonyms scaleTrans, strans
* @example * @example
* "-8 [2,4,6]" * "-8 [2,4,6]"
* .scale('C4 bebop major') * .scale('C4 bebop major')
@ -150,7 +151,9 @@ export const transpose = register(['transpose', 'trans'], function transposeFn(i
* .note() * .note()
*/ */
export const scaleTranspose = register('scaleTranspose', function (offset /* : number | string */, pat) { export const scaleTranspose = register(
['scaleTranspose', 'scaleTrans', 'strans'],
function (offset /* : number | string */, pat) {
return pat.withHap((hap) => { return pat.withHap((hap) => {
if (!hap.context.scale) { if (!hap.context.scale) {
throw new Error('can only use scaleTranspose after .scale'); throw new Error('can only use scaleTranspose after .scale');
@ -165,7 +168,8 @@ export const scaleTranspose = register('scaleTranspose', function (offset /* : n
} }
return hap.withValue(() => scaleOffset(hap.context.scale, Number(offset), hap.value)); return hap.withValue(() => scaleOffset(hap.context.scale, Number(offset), hap.value));
}); });
}); },
);
/** /**
* Turns numbers into notes in the scale (zero indexed). Also sets scale for other scale operations, like {@link Pattern#scaleTranspose}. * Turns numbers into notes in the scale (zero indexed). Also sets scale for other scale operations, like {@link Pattern#scaleTranspose}.