Apply the same fix to square and randrun

This commit is contained in:
Tijmen Zwaan
2026-08-04 17:11:52 +02:00
parent 4484ee4e80
commit 04232370c2
+2 -2
View File
@@ -114,7 +114,7 @@ export const cosine2 = sine2._early(Fraction(1).div(4));
* n(square.segment(4).range(0,7)).scale("C:minor")
*
*/
export const square = signal((t) => Math.floor((t * 2) % 2));
export const square = signal((t) => Math.floor(_mod((t * 2), 2)));
/**
* A square signal between -1 and 1 (like `square`, but bipolar).
@@ -397,7 +397,7 @@ export const randrun = (n) => {
.map((n, i) => [n, i])
.sort((a, b) => (a[0] > b[0]) - (a[0] < b[0]))
.map((x) => x[1]);
const i = t.cyclePos().mul(n).floor() % n;
const i = _mod(t.cyclePos().mul(n).floor(), n);
return nums[i];
})._segment(n);
};