fix: top-level functions arp/arpWith
This commit is contained in:
parent
77ade0758e
commit
9b8761bc45
1 changed files with 9 additions and 6 deletions
|
|
@ -904,12 +904,13 @@ Pattern.prototype.collect = function () {
|
||||||
* note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
|
* note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
|
||||||
* .arpWith(haps => haps[2])
|
* .arpWith(haps => haps[2])
|
||||||
* */
|
* */
|
||||||
Pattern.prototype.arpWith = function (func) {
|
export const arpWith = register('arpWith', (func, pat) => {
|
||||||
return this.collect()
|
return pat
|
||||||
|
.collect()
|
||||||
.fmap((v) => reify(func(v)))
|
.fmap((v) => reify(func(v)))
|
||||||
.innerJoin()
|
.innerJoin()
|
||||||
.withHap((h) => new Hap(h.whole, h.part, h.value.value, h.combineContext(h.value)));
|
.withHap((h) => new Hap(h.whole, h.part, h.value.value, h.combineContext(h.value)));
|
||||||
};
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects indices in in stacked notes.
|
* Selects indices in in stacked notes.
|
||||||
|
|
@ -917,9 +918,11 @@ Pattern.prototype.arpWith = function (func) {
|
||||||
* note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
|
* note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
|
||||||
* .arp("0 [0,2] 1 [0,2]")
|
* .arp("0 [0,2] 1 [0,2]")
|
||||||
* */
|
* */
|
||||||
Pattern.prototype.arp = function (pat) {
|
export const arp = register(
|
||||||
return this.arpWith((haps) => pat.fmap((i) => haps[i % haps.length]));
|
'arp',
|
||||||
};
|
(indices, pat) => pat.arpWith((haps) => reify(indices).fmap((i) => haps[i % haps.length])),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Takes a time duration followed by one or more patterns, and shifts the given patterns in time, so they are
|
* Takes a time duration followed by one or more patterns, and shifts the given patterns in time, so they are
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue