attempt at fastGap, with failing test
This commit is contained in:
parent
c891dda8eb
commit
ab2cfdeeec
2 changed files with 39 additions and 0 deletions
21
strudel.mjs
21
strudel.mjs
|
|
@ -426,6 +426,27 @@ class Pattern {
|
|||
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) {
|
||||
const fastQuery = this.withQueryTime(t => t.mul(factor))
|
||||
return fastQuery.withEventTime(t => t.div(factor))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue