From e199564415cc1f40d0887c41f4193b35021da08d Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 12 Apr 2022 12:22:04 +0100 Subject: [PATCH] Patternify chop() --- packages/core/strudel.mjs | 1 + packages/core/test/pattern.test.mjs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/core/strudel.mjs b/packages/core/strudel.mjs index 6ef8ff72..ec1eaa2e 100644 --- a/packages/core/strudel.mjs +++ b/packages/core/strudel.mjs @@ -891,6 +891,7 @@ Pattern.prototype.patternified = [ 'fast', 'slow', 'ply', + 'chop', 'cpm', 'early', 'late', diff --git a/packages/core/test/pattern.test.mjs b/packages/core/test/pattern.test.mjs index f833c4c9..9ebd7813 100644 --- a/packages/core/test/pattern.test.mjs +++ b/packages/core/test/pattern.test.mjs @@ -508,7 +508,7 @@ describe('Pattern', function() { }) }) describe("chop", () => { - it("Can chop(2)", () => { + it("Can _chop(2)", () => { assert.deepStrictEqual( sequence({sound: "a"}, {sound: "b"})._chop(2).firstCycle(), sequence({sound: "a", begin: 0, end: 0.5}, @@ -518,5 +518,16 @@ describe('Pattern', function() { ).firstCycle() ); }); + it("Can chop(2,3)", () => { + assert.deepStrictEqual( + pure({sound: "a"}).fast(2).chop(2,3)._sortEventsByPart().firstCycle(), + sequence([{sound: "a", begin: 0, end: 0.5}, + {sound: "a", begin: 0.5, end: 1}], + [{sound: "a", begin: 0, end: 1/3}, + {sound: "a", begin: 1/3, end: 2/3}, + {sound: "a", begin: 2/3, end: 1} + ])._sortEventsByPart().firstCycle() + ) + }) }) })