mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-27 21:48:27 +00:00
Test and fix chop / squeezebind
This commit is contained in:
parent
83c9200e7d
commit
51db0eaf40
@ -617,7 +617,7 @@ class Pattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_squeezeBind(func) {
|
_squeezeBind(func) {
|
||||||
return this.fmap(func).squeezeBind();
|
return this.fmap(func)._squeezeJoin();
|
||||||
}
|
}
|
||||||
|
|
||||||
_apply(func) {
|
_apply(func) {
|
||||||
@ -685,6 +685,15 @@ class Pattern {
|
|||||||
return this.fmap((x) => pure(x)._fast(factor))._squeezeJoin();
|
return this.fmap((x) => pure(x)._fast(factor))._squeezeJoin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_chop(n) {
|
||||||
|
const slices = Array.from({length: n}, (x, i) => i);
|
||||||
|
const slice_objects = slices.map(i => ({begin: i/n, end: (i+1)/n}));
|
||||||
|
const func = function(o) {
|
||||||
|
return(sequence(slice_objects.map(slice_o => Object.assign({}, o, slice_o))))
|
||||||
|
}
|
||||||
|
return(this._squeezeBind(func));
|
||||||
|
}
|
||||||
|
|
||||||
// cpm = cycles per minute
|
// cpm = cycles per minute
|
||||||
_cpm(cpm) {
|
_cpm(cpm) {
|
||||||
return this._fast(cpm / 60);
|
return this._fast(cpm / 60);
|
||||||
|
|||||||
@ -507,4 +507,16 @@ describe('Pattern', function() {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
describe("chop", () => {
|
||||||
|
it("Can chop(2)", () => {
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
sequence({sound: "a"}, {sound: "b"})._chop(2).firstCycle(),
|
||||||
|
sequence({sound: "a", begin: 0, end: 0.5},
|
||||||
|
{sound: "a", begin: 0.5, end: 1},
|
||||||
|
{sound: "b", begin: 0, end: 0.5},
|
||||||
|
{sound: "b", begin: 0.5, end: 1}
|
||||||
|
).firstCycle()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user