Introduce isquare and isquare2 for signal parity

This commit is contained in:
Tijmen Zwaan
2026-08-13 01:00:33 +02:00
parent 9e946f1d14
commit bd54c8003a
+16
View File
@@ -124,6 +124,22 @@ export const square = signal((t) => Math.floor(_mod(t * 2, 2)));
*/
export const square2 = square.toBipolar();
/**
* A square signal between 1 and 0 (like `square` but flipped).
*
* @return {Pattern}
* @tags generators
*/
export const isquare = signal((t) => 1 - Math.floor(_mod(t * 2, 2)));
/**
* A square signal between 1 and -1 (like `isquare`, but bipolar).
*
* @return {Pattern}
* @tags generators
*/
export const isquare2 = isquare.toBipolar();
/**
* A triangle signal between 0 and 1.
*