Add range2
This commit is contained in:
parent
0e5dc4f368
commit
3c31891774
2 changed files with 10 additions and 3 deletions
|
|
@ -525,6 +525,11 @@ class Pattern {
|
||||||
return this.mul(max-min).add(min);
|
return this.mul(max-min).add(min);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assumes source pattern of numbers in range -1..1
|
||||||
|
range2(min, max) {
|
||||||
|
return _fromBipolar(this).range(min,max);
|
||||||
|
}
|
||||||
|
|
||||||
union(other) {
|
union(other) {
|
||||||
return this._opleft(other, (a) => (b) => Object.assign({}, a, b));
|
return this._opleft(other, (a) => (b) => Object.assign({}, a, b));
|
||||||
}
|
}
|
||||||
|
|
@ -1108,6 +1113,7 @@ const mul = curry((a, pat) => pat.mul(a));
|
||||||
const div = curry((a, pat) => pat.div(a));
|
const div = curry((a, pat) => pat.div(a));
|
||||||
const union = curry((a, pat) => pat.union(a));
|
const union = curry((a, pat) => pat.union(a));
|
||||||
const range = curry((a, b, pat) => pat.range(a,b));
|
const range = curry((a, b, pat) => pat.range(a,b));
|
||||||
|
const range2 = curry((a, b, pat) => pat.range2(a,b));
|
||||||
const every = curry((i, f, pat) => pat.every(i, f));
|
const every = curry((i, f, pat) => pat.every(i, f));
|
||||||
const when = curry((binary, f, pat) => pat.when(binary, f));
|
const when = curry((binary, f, pat) => pat.when(binary, f));
|
||||||
const off = curry((t, f, pat) => pat.off(t, f));
|
const off = curry((t, f, pat) => pat.off(t, f));
|
||||||
|
|
@ -1266,6 +1272,7 @@ export {
|
||||||
div,
|
div,
|
||||||
union,
|
union,
|
||||||
range,
|
range,
|
||||||
|
range2,
|
||||||
every,
|
every,
|
||||||
when,
|
when,
|
||||||
off,
|
off,
|
||||||
|
|
|
||||||
|
|
@ -538,10 +538,10 @@ describe('Pattern', function() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe("range", () => {
|
describe("range2", () => {
|
||||||
it("Can change the range of a unipolar pattern", () => {
|
it("Can change the range of a bipolar pattern", () => {
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
sequence(0,0.25,0.5,0.75).range(1000,1100).firstCycle(),
|
sequence(-1,-0.5,0,0.5).range2(1000,1100).firstCycle(),
|
||||||
sequence(1000,1025,1050,1075).firstCycle()
|
sequence(1000,1025,1050,1075).firstCycle()
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue