Merge pull request 'fix: shuffle(1) returns source pattern' (#1968) from tyow/localstrudel:shuffleFix into main

Reviewed-on: https://codeberg.org/uzu/strudel/pulls/1968
This commit is contained in:
froos 2026-02-15 00:24:30 +01:00
commit aa49d9dcc2
2 changed files with 10 additions and 2 deletions

View file

@ -389,7 +389,9 @@ export const randL = (n) => {
export const randrun = (n) => {
return signal((t, controls) => {
// Without adding 0.5, the first cycle is always 0,1,2,3,...
const rands = getRandsAtTime(t.floor().add(0.5), n, controls.randSeed);
let rands = getRandsAtTime(t.floor().add(0.5), n, controls.randSeed);
// Support n = 1
if (!Array.isArray(rands)) rands = [rands];
const nums = rands
.map((n, i) => [n, i])
.sort((a, b) => (a[0] > b[0]) - (a[0] < b[0]))