fix _fastGap, add compressSpan

This commit is contained in:
alex
2022-02-09 22:41:44 +00:00
parent ab2cfdeeec
commit f5fb5857df
2 changed files with 25 additions and 4 deletions
+11
View File
@@ -3,6 +3,9 @@ import Fraction from 'fraction.js'
import { strict as assert } from 'assert';
import {TimeSpan, Hap, Pattern, pure, stack, fastcat, slowcat, cat, sequence, polyrhythm, silence, fast} from "../strudel.mjs";
//import { Time } from 'tone';
import pkg from 'tone';
const { Time } = pkg;
const ts = (begin, end) => new TimeSpan(Fraction(begin), Fraction(end));
const hap = (whole, part, value) => new Hap(whole, part, value)
@@ -107,6 +110,14 @@ describe('Pattern', function() {
)
})
})
describe('_compressSpan()', function () {
it('Can squash cycles of a pattern into a given timespan', function () {
assert.deepStrictEqual(
pure("a")._compressSpan(new TimeSpan(0.25, 0.5)).firstCycle,
sequence(silence, "a", silence, silence).firstCycle
)
})
})
describe('fast()', function () {
it('Makes things faster', function () {
assert.equal(pure("a").fast(2).firstCycle.length, 2)