From fb149808ee372e54859d167b3d9c46c538965f82 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 23 Feb 2022 22:46:01 +0000 Subject: [PATCH 1/2] test div and mul --- test/pattern.test.mjs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/pattern.test.mjs b/test/pattern.test.mjs index 70e49974..3d6a58dd 100644 --- a/test/pattern.test.mjs +++ b/test/pattern.test.mjs @@ -80,6 +80,16 @@ describe('Pattern', function() { assert.equal(pure(3).sub(pure(4)).query(new TimeSpan(Fraction(0), Fraction(1)))[0].value, -1) }) }) + describe('mul()', function () { + it('Can multiply things', function() { + assert.equal(pure(3).mul(pure(2)).firstCycle[0].value, 6) + }) + }) + describe('div()', function () { + it('Can divide things', function() { + assert.equal(pure(3).div(pure(2)).firstCycle[0].value, 1.5) + }) + }) describe('union()', function () { it('Can union things', function () { assert.deepStrictEqual(pure({a: 4, b: 6}).union(pure({c: 7})).firstCycle[0].value, {a: 4, b: 6, c: 7}) From b323855b695837994e5ba6a48a72bec7e6b57a6d Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 24 Feb 2022 22:53:13 +0000 Subject: [PATCH 2/2] fix off() --- strudel.mjs | 2 +- test/pattern.test.mjs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/strudel.mjs b/strudel.mjs index 5fc4adf2..3e560c3f 100644 --- a/strudel.mjs +++ b/strudel.mjs @@ -618,7 +618,7 @@ class Pattern { const left = this.withValue(val => Object.assign({}, val, {pan: elem_or(val, "pan", 0.5) - by})) const right = this.withValue(val => Object.assign({}, val, {pan: elem_or(val, "pan", 0.5) + by})) - return stack([left,func(right)]) + return stack(left,func(right)) } // is there a different name for those in tidal? diff --git a/test/pattern.test.mjs b/test/pattern.test.mjs index 96a864c4..084156e9 100644 --- a/test/pattern.test.mjs +++ b/test/pattern.test.mjs @@ -383,7 +383,15 @@ describe('Pattern', function() { it("Can offset a transformed pattern from the original", () => { assert.deepStrictEqual( pure(30).off(0.25, add(2)).firstCycle, - stack(pure(30), pure(30).early(0.25).add(2)).firstCycle + stack(pure(30), pure(30).late(0.25).add(2)).firstCycle + ) + }) + }) + describe("jux", () => { + it("Can juxtapose", () => { + assert.deepStrictEqual( + pure({a: 1}).jux(fast(2))._sortEventsByPart().firstCycle, + stack(pure({a:1, pan: 0}), pure({a:1, pan: 1}).fast(2))._sortEventsByPart().firstCycle ) }) })