mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-24 12:08:28 +00:00
attempt at fastGap, with failing test
This commit is contained in:
parent
c891dda8eb
commit
ab2cfdeeec
21
strudel.mjs
21
strudel.mjs
@ -426,6 +426,27 @@ class Pattern {
|
|||||||
return patterned
|
return patterned
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_fastGap (factor) {
|
||||||
|
// Maybe it's better without this fallback..
|
||||||
|
// if (factor < 1) {
|
||||||
|
// // there is no gap.. so maybe revert to _fast?
|
||||||
|
// return this._fast(factor)
|
||||||
|
// }
|
||||||
|
const qf = function(span) {
|
||||||
|
const cycle = span.begin.sam()
|
||||||
|
const begin = cycle.add(span.begin.sub(span.cycle).mul(factor).min(1))
|
||||||
|
const end = cycle.add(span.end.sub(span.cycle).mul(factor).min(1))
|
||||||
|
return new TimeSpan(begin, end)
|
||||||
|
}
|
||||||
|
const ef = function(span) {
|
||||||
|
const cycle = span.begin.sam()
|
||||||
|
const begin = cycle.add(span.begin.sub(span.cycle).div(factor).min(1))
|
||||||
|
const end = cycle.add(span.end.sub(span.cycle).div(factor).min(1))
|
||||||
|
return new TimeSpan(begin, end)
|
||||||
|
}
|
||||||
|
return this.withQuerySpan(qf).withEventSpan(ef)._splitQueries()
|
||||||
|
}
|
||||||
|
|
||||||
_fast(factor) {
|
_fast(factor) {
|
||||||
const fastQuery = this.withQueryTime(t => t.mul(factor))
|
const fastQuery = this.withQueryTime(t => t.mul(factor))
|
||||||
return fastQuery.withEventTime(t => t.div(factor))
|
return fastQuery.withEventTime(t => t.div(factor))
|
||||||
|
|||||||
@ -89,6 +89,24 @@ describe('Pattern', function() {
|
|||||||
assert.equal(pure("a")._fast(2).firstCycle.length, 2)
|
assert.equal(pure("a")._fast(2).firstCycle.length, 2)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
describe('_fastGap()', function () {
|
||||||
|
it('Makes things faster, with a gap', function () {
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
sequence("a", "b", "c")._fastGap(2).firstCycle,
|
||||||
|
sequence(["a","b","c"], silence).firstCycle
|
||||||
|
)
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
sequence("a", "b", "c")._fastGap(3).firstCycle,
|
||||||
|
sequence(["a","b","c"], silence, silence).firstCycle
|
||||||
|
)
|
||||||
|
})
|
||||||
|
it('Makes things faster, with a gap, when speeded up further', function () {
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
sequence("a", "b", "c")._fastGap(2).fast(2).firstCycle,
|
||||||
|
sequence(["a","b","c"], silence, ["a","b","c"], silence).firstCycle
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
describe('fast()', function () {
|
describe('fast()', function () {
|
||||||
it('Makes things faster', function () {
|
it('Makes things faster', function () {
|
||||||
assert.equal(pure("a").fast(2).firstCycle.length, 2)
|
assert.equal(pure("a").fast(2).firstCycle.length, 2)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user