Merge pull request #1314 from daslyfe/jade/alias

small feat: Add alias for segment and ribbon
This commit is contained in:
Jade (Rose) Rowland 2025-03-26 12:01:04 -04:00 committed by GitHub
commit 9b4574c7b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 112 additions and 43 deletions

View File

@ -2105,11 +2105,13 @@ export const linger = register(
/** /**
* Samples the pattern at a rate of n events per cycle. Useful for turning a continuous pattern into a discrete one. * Samples the pattern at a rate of n events per cycle. Useful for turning a continuous pattern into a discrete one.
* @name segment
* @synonyms seg
* @param {number} segments number of segments per cycle * @param {number} segments number of segments per cycle
* @example * @example
* note(saw.range(40,52).segment(24)) * note(saw.range(40,52).segment(24))
*/ */
export const segment = register('segment', function (rate, pat) { export const { segment, seg } = register(['segment', 'seg'], function (rate, pat) {
return pat.struct(pure(true)._fast(rate)).setSteps(rate); return pat.struct(pure(true)._fast(rate)).setSteps(rate);
}); });
@ -2485,16 +2487,24 @@ export const bypass = register(
); );
/** /**
* Loops the pattern inside at `offset` for `cycles`. * Loops the pattern inside an `offset` for `cycles`.
* If you think of the entire span of time in cycles as a ribbon, you can cut a single piece and loop it.
* @name ribbon
* @synonym rib
* @param {number} offset start point of loop in cycles * @param {number} offset start point of loop in cycles
* @param {number} cycles loop length in cycles * @param {number} cycles loop length in cycles
* @example * @example
* note("<c d e f>").ribbon(1, 2).fast(2) * note("<c d e f>").ribbon(1, 2)
* @example * @example
* // Looping a portion of randomness * // Looping a portion of randomness
* note(irand(8).segment(4).scale('C3 minor')).ribbon(1337, 2) * n(irand(8).segment(4)).scale("c:pentatonic").ribbon(1337, 2)
* @example
* // rhythm generator
* s("bd!16?").ribbon(29,.5)
*/ */
export const ribbon = register('ribbon', (offset, cycles, pat) => pat.early(offset).restart(pure(1).slow(cycles))); export const { ribbon, rib } = register(['ribbon', 'rib'], (offset, cycles, pat) =>
pat.early(offset).restart(pure(1).slow(cycles)),
);
export const hsla = register('hsla', (h, s, l, a, pat) => { export const hsla = register('hsla', (h, s, l, a, pat) => {
return pat.color(`hsla(${h}turn,${s * 100}%,${l * 100}%,${a})`); return pat.color(`hsla(${h}turn,${s * 100}%,${l * 100}%,${a})`);

View File

@ -526,6 +526,9 @@ export const degradeByWith = register(
* s("hh*8").degradeBy(0.2) * s("hh*8").degradeBy(0.2)
* @example * @example
* s("[hh?0.2]*8") * s("[hh?0.2]*8")
* @example
* //beat generator
* s("bd").segment(16).degradeBy(.5).ribbon(16,1)
*/ */
export const degradeBy = register( export const degradeBy = register(
'degradeBy', 'degradeBy',

View File

@ -2322,6 +2322,39 @@ exports[`runs examples > example "degradeBy" example index 1 1`] = `
] ]
`; `;
exports[`runs examples > example "degradeBy" example index 2 1`] = `
[
"[ 1/8 → 3/16 | s:bd ]",
"[ 1/4 → 5/16 | s:bd ]",
"[ 5/16 → 3/8 | s:bd ]",
"[ 1/2 → 9/16 | s:bd ]",
"[ 9/16 → 5/8 | s:bd ]",
"[ 11/16 → 3/4 | s:bd ]",
"[ 15/16 → 1/1 | s:bd ]",
"[ 9/8 → 19/16 | s:bd ]",
"[ 5/4 → 21/16 | s:bd ]",
"[ 21/16 → 11/8 | s:bd ]",
"[ 3/2 → 25/16 | s:bd ]",
"[ 25/16 → 13/8 | s:bd ]",
"[ 27/16 → 7/4 | s:bd ]",
"[ 31/16 → 2/1 | s:bd ]",
"[ 17/8 → 35/16 | s:bd ]",
"[ 9/4 → 37/16 | s:bd ]",
"[ 37/16 → 19/8 | s:bd ]",
"[ 5/2 → 41/16 | s:bd ]",
"[ 41/16 → 21/8 | s:bd ]",
"[ 43/16 → 11/4 | s:bd ]",
"[ 47/16 → 3/1 | s:bd ]",
"[ 25/8 → 51/16 | s:bd ]",
"[ 13/4 → 53/16 | s:bd ]",
"[ 53/16 → 27/8 | s:bd ]",
"[ 7/2 → 57/16 | s:bd ]",
"[ 57/16 → 29/8 | s:bd ]",
"[ 59/16 → 15/4 | s:bd ]",
"[ 63/16 → 4/1 | s:bd ]",
]
`;
exports[`runs examples > example "delay" example index 0 1`] = ` exports[`runs examples > example "delay" example index 0 1`] = `
[ [
"[ 0/1 → 1/2 | s:bd delay:0 ]", "[ 0/1 → 1/2 | s:bd delay:0 ]",
@ -7123,35 +7156,76 @@ exports[`runs examples > example "rev" example index 0 1`] = `
exports[`runs examples > example "ribbon" example index 0 1`] = ` exports[`runs examples > example "ribbon" example index 0 1`] = `
[ [
"[ 0/1 → 1/2 | note:d ]", "[ 0/1 → 1/1 | note:d ]",
"[ 1/2 → 1/1 | note:e ]", "[ 1/1 → 2/1 | note:e ]",
"[ 1/1 → 3/2 | note:d ]", "[ 2/1 → 3/1 | note:d ]",
"[ 3/2 → 2/1 | note:e ]", "[ 3/1 → 4/1 | note:e ]",
"[ 2/1 → 5/2 | note:d ]",
"[ 5/2 → 3/1 | note:e ]",
"[ 3/1 → 7/2 | note:d ]",
"[ 7/2 → 4/1 | note:e ]",
] ]
`; `;
exports[`runs examples > example "ribbon" example index 1 1`] = ` exports[`runs examples > example "ribbon" example index 1 1`] = `
[ [
"[ 0/1 → 1/4 | note:G3 ]", "[ 0/1 → 1/4 | note:A3 ]",
"[ 1/4 → 1/2 | note:C3 ]", "[ 1/4 → 1/2 | note:C3 ]",
"[ 1/2 → 3/4 | note:D3 ]", "[ 1/2 → 3/4 | note:D3 ]",
"[ 3/4 → 1/1 | note:F3 ]", "[ 3/4 → 1/1 | note:G3 ]",
"[ 1/1 → 5/4 | note:Eb3 ]", "[ 1/1 → 5/4 | note:E3 ]",
"[ 5/4 → 3/2 | note:Ab3 ]", "[ 5/4 → 3/2 | note:C4 ]",
"[ 3/2 → 7/4 | note:G3 ]", "[ 3/2 → 7/4 | note:A3 ]",
"[ 7/4 → 2/1 | note:C4 ]", "[ 7/4 → 2/1 | note:E4 ]",
"[ 2/1 → 9/4 | note:G3 ]", "[ 2/1 → 9/4 | note:A3 ]",
"[ 9/4 → 5/2 | note:C3 ]", "[ 9/4 → 5/2 | note:C3 ]",
"[ 5/2 → 11/4 | note:D3 ]", "[ 5/2 → 11/4 | note:D3 ]",
"[ 11/4 → 3/1 | note:F3 ]", "[ 11/4 → 3/1 | note:G3 ]",
"[ 3/1 → 13/4 | note:Eb3 ]", "[ 3/1 → 13/4 | note:E3 ]",
"[ 13/4 → 7/2 | note:Ab3 ]", "[ 13/4 → 7/2 | note:C4 ]",
"[ 7/2 → 15/4 | note:G3 ]", "[ 7/2 → 15/4 | note:A3 ]",
"[ 15/4 → 4/1 | note:C4 ]", "[ 15/4 → 4/1 | note:E4 ]",
]
`;
exports[`runs examples > example "ribbon" example index 2 1`] = `
[
"[ 1/16 → 1/8 | s:bd ]",
"[ 1/8 → 3/16 | s:bd ]",
"[ 3/16 → 1/4 | s:bd ]",
"[ 1/4 → 5/16 | s:bd ]",
"[ 3/8 → 7/16 | s:bd ]",
"[ 9/16 → 5/8 | s:bd ]",
"[ 5/8 → 11/16 | s:bd ]",
"[ 11/16 → 3/4 | s:bd ]",
"[ 3/4 → 13/16 | s:bd ]",
"[ 7/8 → 15/16 | s:bd ]",
"[ 17/16 → 9/8 | s:bd ]",
"[ 9/8 → 19/16 | s:bd ]",
"[ 19/16 → 5/4 | s:bd ]",
"[ 5/4 → 21/16 | s:bd ]",
"[ 11/8 → 23/16 | s:bd ]",
"[ 25/16 → 13/8 | s:bd ]",
"[ 13/8 → 27/16 | s:bd ]",
"[ 27/16 → 7/4 | s:bd ]",
"[ 7/4 → 29/16 | s:bd ]",
"[ 15/8 → 31/16 | s:bd ]",
"[ 33/16 → 17/8 | s:bd ]",
"[ 17/8 → 35/16 | s:bd ]",
"[ 35/16 → 9/4 | s:bd ]",
"[ 9/4 → 37/16 | s:bd ]",
"[ 19/8 → 39/16 | s:bd ]",
"[ 41/16 → 21/8 | s:bd ]",
"[ 21/8 → 43/16 | s:bd ]",
"[ 43/16 → 11/4 | s:bd ]",
"[ 11/4 → 45/16 | s:bd ]",
"[ 23/8 → 47/16 | s:bd ]",
"[ 49/16 → 25/8 | s:bd ]",
"[ 25/8 → 51/16 | s:bd ]",
"[ 51/16 → 13/4 | s:bd ]",
"[ 13/4 → 53/16 | s:bd ]",
"[ 27/8 → 55/16 | s:bd ]",
"[ 57/16 → 29/8 | s:bd ]",
"[ 29/8 → 59/16 | s:bd ]",
"[ 59/16 → 15/4 | s:bd ]",
"[ 15/4 → 61/16 | s:bd ]",
"[ 31/8 → 63/16 | s:bd ]",
] ]
`; `;

View File

@ -179,25 +179,7 @@ export function SettingsTab({ started }) {
value={togglePanelTrigger} value={togglePanelTrigger}
onChange={(value) => settingsMap.setKey('togglePanelTrigger', value)} onChange={(value) => settingsMap.setKey('togglePanelTrigger', value)}
items={{ click: 'Click', hover: 'Hover' }} items={{ click: 'Click', hover: 'Hover' }}
></ButtonGroup>
{/* <Checkbox
label="Click"
onChange={(cbEvent) => {
if (cbEvent.target.checked) {
settingsMap.setKey('togglePanelTrigger', 'click');
}
}}
value={togglePanelTrigger != 'hover'}
/> />
<Checkbox
label="Hover"
onChange={(cbEvent) => {
if (cbEvent.target.checked) {
settingsMap.setKey('togglePanelTrigger', 'hover');
}
}}
value={togglePanelTrigger == 'hover'}
/> */}
</FormItem> </FormItem>
<FormItem label="More Settings"> <FormItem label="More Settings">
<Checkbox <Checkbox