Implement brak()

This commit is contained in:
alex 2022-05-09 16:56:08 +02:00
parent 73b0a3a0ef
commit 4fd843f8cf
2 changed files with 19 additions and 4 deletions

View File

@ -822,6 +822,16 @@ export class Pattern {
return slowcatPrime(...pats);
}
/**
* Returns a new pattern where every other cycle is played once, twice as
* fast, and offset in time by one quarter of a cycle. Creates a kind of
* breakbeat feel.
* @returns Pattern
*/
brak() {
return this.every(2, x => fastcat(x, silence)._late(0.25))
}
rev() {
const pat = this;
const query = function (state) {

View File

@ -277,10 +277,7 @@ describe('Pattern', function () {
);
});
it('can SqueezeOut() structure', () => {
sameFirst(
sequence(1, [2, 3]).keepifSqueezeOut(true, true, false),
sequence([1, [2, 3]], [1, [2, 3]], silence),
);
sameFirst(sequence(1, [2, 3]).keepifSqueezeOut(true, true, false), sequence([1, [2, 3]], [1, [2, 3]], silence));
});
});
describe('sub()', function () {
@ -589,6 +586,14 @@ describe('Pattern', function () {
);
});
});
describe('brak()', () => {
it('Can make something a bit breakbeaty', () => {
sameFirst(
sequence('a', 'b').brak()._fast(2),
sequence('a', 'b', fastcat(silence, 'a'), fastcat('b', silence))
)
});
});
describe('timeCat()', function () {
it('Can concatenate patterns with different relative durations', function () {
assert.deepStrictEqual(