Allow linger to accept non-fractions

This commit is contained in:
alex 2022-04-13 15:59:36 +01:00
parent dcc5f66691
commit ec3371c4ff
2 changed files with 11 additions and 1 deletions

View File

@ -706,6 +706,8 @@ class Pattern {
}
_zoom(s, e) {
e = Fraction(e)
s = Fraction(s)
const d = e.sub(s);
return this.withQuerySpan((span) => span.withCycle((t) => t.mul(d).add(s)))
.withEventSpan((span) => span.withCycle((t) => t.sub(s).div(d)))

View File

@ -1,6 +1,6 @@
import Fraction from 'fraction.js';
import { strict as assert } from 'assert';
import { deepStrictEqual, strict as assert } from 'assert';
import {
TimeSpan,
@ -656,4 +656,12 @@ describe('Pattern', function () {
);
});
});
describe('linger', () => {
it('Can linger on the first quarter of a cycle', () => {
assert.deepStrictEqual(
sequence(0, 1, 2, 3, 4, 5, 6, 7).linger(0.25).firstCycle(),
sequence(0, 1, 0, 1, 0, 1, 0, 1).firstCycle(),
);
});
});
});