format
This commit is contained in:
parent
f44caf9096
commit
27073d6c17
2 changed files with 34 additions and 26 deletions
|
|
@ -1842,9 +1842,9 @@ export const { fastGap, fastgap } = register(['fastGap', 'fastgap'], function (f
|
||||||
const newWhole = !hap.whole
|
const newWhole = !hap.whole
|
||||||
? undefined
|
? undefined
|
||||||
: new TimeSpan(
|
: new TimeSpan(
|
||||||
newPart.begin.sub(begin.sub(hap.whole.begin).div(factor)),
|
newPart.begin.sub(begin.sub(hap.whole.begin).div(factor)),
|
||||||
newPart.end.add(hap.whole.end.sub(end).div(factor)),
|
newPart.end.add(hap.whole.end.sub(end).div(factor)),
|
||||||
);
|
);
|
||||||
return new Hap(newWhole, newPart, hap.value, hap.context);
|
return new Hap(newWhole, newPart, hap.value, hap.context);
|
||||||
};
|
};
|
||||||
return pat.withQuerySpanMaybe(qf).withHap(ef).splitQueries();
|
return pat.withQuerySpanMaybe(qf).withHap(ef).splitQueries();
|
||||||
|
|
@ -2528,10 +2528,9 @@ export const { fastchunk, fastChunk } = register(
|
||||||
* sound("bd sd ht lt bd - cp lt").chunkInto(4, hurry(2))
|
* sound("bd sd ht lt bd - cp lt").chunkInto(4, hurry(2))
|
||||||
* .bank("tr909")
|
* .bank("tr909")
|
||||||
*/
|
*/
|
||||||
export const { chunkinto, chunkInto } = register(['chunkinto', 'chunkInto'],
|
export const { chunkinto, chunkInto } = register(['chunkinto', 'chunkInto'], function (n, func, pat) {
|
||||||
function (n, func, pat) {
|
return pat.into(fastcat(true, ...Array(n - 1).fill(false))._iterback(n), func);
|
||||||
return pat.into(fastcat(true, ...Array(n - 1).fill(false))._iterback(n), func);
|
});
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like `chunkInto`, but moves backwards through the chunks.
|
* Like `chunkInto`, but moves backwards through the chunks.
|
||||||
|
|
@ -2542,10 +2541,14 @@ export const { chunkinto, chunkInto } = register(['chunkinto', 'chunkInto'],
|
||||||
* sound("bd sd ht lt bd - cp lt").chunkInto(4, hurry(2))
|
* sound("bd sd ht lt bd - cp lt").chunkInto(4, hurry(2))
|
||||||
* .bank("tr909")
|
* .bank("tr909")
|
||||||
*/
|
*/
|
||||||
export const { chunkbackinto, chunkBackInto } = register(['chunkbackinto', 'chunkBackInto'],
|
export const { chunkbackinto, chunkBackInto } = register(['chunkbackinto', 'chunkBackInto'], function (n, func, pat) {
|
||||||
function (n, func, pat) {
|
return pat.into(
|
||||||
return pat.into(fastcat(true, ...Array(n - 1).fill(false))._iter(n)._early(1), func);
|
fastcat(true, ...Array(n - 1).fill(false))
|
||||||
});
|
._iter(n)
|
||||||
|
._early(1),
|
||||||
|
func,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// TODO - redefine elsewhere in terms of mask
|
// TODO - redefine elsewhere in terms of mask
|
||||||
export const bypass = register(
|
export const bypass = register(
|
||||||
|
|
|
||||||
|
|
@ -1274,31 +1274,36 @@ describe('Pattern', () => {
|
||||||
describe('unjoin', () => {
|
describe('unjoin', () => {
|
||||||
it('destructures a pattern into subcycles', () => {
|
it('destructures a pattern into subcycles', () => {
|
||||||
sameFirst(
|
sameFirst(
|
||||||
fastcat('a', 'b', 'c', 'd').unjoin(fastcat(true, fastcat(true, true))).fmap(fast(2)).join(),
|
fastcat('a', 'b', 'c', 'd')
|
||||||
fastcat('a', 'b', 'a', 'b', 'c', 'c', 'd', 'd')
|
.unjoin(fastcat(true, fastcat(true, true)))
|
||||||
)
|
.fmap(fast(2))
|
||||||
})
|
.join(),
|
||||||
|
fastcat('a', 'b', 'a', 'b', 'c', 'c', 'd', 'd'),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('into', () => {
|
describe('into', () => {
|
||||||
it('applies a function to subcycles of a pattern', () => {
|
it('applies a function to subcycles of a pattern', () => {
|
||||||
sameFirst(
|
sameFirst(
|
||||||
fastcat('a', 'b', 'c', 'd').into(fastcat(fastcat('true', 'true'), 'true'), fast(2)),
|
fastcat('a', 'b', 'c', 'd').into(fastcat(fastcat('true', 'true'), 'true'), fast(2)),
|
||||||
fastcat('a', 'a', 'b', 'b', 'c', 'd', 'c', 'd')
|
fastcat('a', 'a', 'b', 'b', 'c', 'd', 'c', 'd'),
|
||||||
)
|
);
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
describe('chunkinto', () => {
|
describe('chunkinto', () => {
|
||||||
it('chunks into subcycles', () => {
|
it('chunks into subcycles', () => {
|
||||||
sameFirst(fastcat('a', 'b', 'c').chunkInto(3, fast(2)).fast(3),
|
sameFirst(
|
||||||
fastcat(fastcat('a', 'a'), 'b', 'c', 'a', fastcat('b', 'b'), 'c', 'a', 'b', fastcat('c', 'c'))
|
fastcat('a', 'b', 'c').chunkInto(3, fast(2)).fast(3),
|
||||||
)
|
fastcat(fastcat('a', 'a'), 'b', 'c', 'a', fastcat('b', 'b'), 'c', 'a', 'b', fastcat('c', 'c')),
|
||||||
})
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('chunkbackinto', () => {
|
describe('chunkbackinto', () => {
|
||||||
it('chunks into subcycles backwards', () => {
|
it('chunks into subcycles backwards', () => {
|
||||||
sameFirst(fastcat('a', 'b', 'c').chunkBackInto(3, fast(2)).fast(3),
|
sameFirst(
|
||||||
fastcat('a', 'b', fastcat('c', 'c'), 'a', fastcat('b', 'b'), 'c', fastcat('a', 'a'), 'b', 'c')
|
fastcat('a', 'b', 'c').chunkBackInto(3, fast(2)).fast(3),
|
||||||
)
|
fastcat('a', 'b', fastcat('c', 'c'), 'a', fastcat('b', 'b'), 'c', fastcat('a', 'a'), 'b', 'c'),
|
||||||
})
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue