mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-24 20:08:33 +00:00
Implement inside/outside
This commit is contained in:
parent
a8d676641b
commit
aca3bea56b
@ -696,6 +696,14 @@ export class Pattern {
|
|||||||
return this._fast(Fraction(1).div(factor));
|
return this._fast(Fraction(1).div(factor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_inside(factor, f) {
|
||||||
|
return f(this._slow(factor))._fast(factor);
|
||||||
|
}
|
||||||
|
|
||||||
|
_outside(factor, f) {
|
||||||
|
return f(this._fast(factor))._slow(factor);
|
||||||
|
}
|
||||||
|
|
||||||
_ply(factor) {
|
_ply(factor) {
|
||||||
return this.fmap((x) => pure(x)._fast(factor))._squeezeJoin();
|
return this.fmap((x) => pure(x)._fast(factor))._squeezeJoin();
|
||||||
}
|
}
|
||||||
@ -1400,6 +1408,14 @@ Pattern.prototype.compress = function (...args) {
|
|||||||
args = args.map(reify);
|
args = args.map(reify);
|
||||||
return patternify2(Pattern.prototype._compress)(...args, this);
|
return patternify2(Pattern.prototype._compress)(...args, this);
|
||||||
};
|
};
|
||||||
|
Pattern.prototype.outside = function (...args) {
|
||||||
|
args = args.map(reify);
|
||||||
|
return patternify2(Pattern.prototype._outside)(...args, this);
|
||||||
|
};
|
||||||
|
Pattern.prototype.inside = function (...args) {
|
||||||
|
args = args.map(reify);
|
||||||
|
return patternify2(Pattern.prototype._inside)(...args, this);
|
||||||
|
};
|
||||||
|
|
||||||
// call this after all Patter.prototype.define calls have been executed! (right before evaluate)
|
// call this after all Patter.prototype.define calls have been executed! (right before evaluate)
|
||||||
Pattern.prototype.bootstrap = function () {
|
Pattern.prototype.bootstrap = function () {
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import {
|
|||||||
tri2,
|
tri2,
|
||||||
id,
|
id,
|
||||||
ply,
|
ply,
|
||||||
|
rev
|
||||||
} from '../index.mjs';
|
} from '../index.mjs';
|
||||||
|
|
||||||
import { steady } from '../signal.mjs';
|
import { steady } from '../signal.mjs';
|
||||||
@ -436,6 +437,20 @@ describe('Pattern', function () {
|
|||||||
// mini('eb3 [c3 g3]/2 ') always plays [c3 g3]
|
// mini('eb3 [c3 g3]/2 ') always plays [c3 g3]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('inside', () => {
|
||||||
|
it('can rev inside a cycle', () => {
|
||||||
|
sameFirst(sequence('a', 'b', 'c', 'd').inside(2, rev),
|
||||||
|
sequence('b', 'a', 'd', 'c')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('outside', () => {
|
||||||
|
it('can rev outside a cycle', () => {
|
||||||
|
sameFirst(sequence('a', 'b', 'c', 'd')._slow(2).outside(2, rev),
|
||||||
|
sequence('d', 'c')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
describe('_filterValues()', function () {
|
describe('_filterValues()', function () {
|
||||||
it('Filters true', function () {
|
it('Filters true', function () {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
@ -588,10 +603,7 @@ describe('Pattern', function () {
|
|||||||
});
|
});
|
||||||
describe('brak()', () => {
|
describe('brak()', () => {
|
||||||
it('Can make something a bit breakbeaty', () => {
|
it('Can make something a bit breakbeaty', () => {
|
||||||
sameFirst(
|
sameFirst(sequence('a', 'b').brak()._fast(2), sequence('a', 'b', fastcat(silence, 'a'), fastcat('b', silence)));
|
||||||
sequence('a', 'b').brak()._fast(2),
|
|
||||||
sequence('a', 'b', fastcat(silence, 'a'), fastcat('b', silence))
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('timeCat()', function () {
|
describe('timeCat()', function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user