breaking: arp use innerJoin instead of squeezeJoin

This commit is contained in:
Felix Roos 2023-01-11 23:28:17 +01:00
parent 500c0b6534
commit 6e315a50ed
3 changed files with 68 additions and 5 deletions

View File

@ -735,6 +735,7 @@ export class Pattern {
* Appends the given pattern(s) to the current pattern. Synonyms: .sequence .fastcat
* @name seq
* @memberof Pattern
* @synonyms sequence, fastcat
* @example
* s("hh*2").seq(
* note("c2(3,8)")
@ -748,6 +749,7 @@ export class Pattern {
* Appends the given pattern(s) to the next cycle. Synonym: .slowcat
* @name cat
* @memberof Pattern
* @synonyms slowcat
* @example
* s("hh*2").cat(
* note("c2(3,8)")
@ -830,15 +832,25 @@ Pattern.prototype.collect = function () {
);
};
// applies func to each array of congruent haps
/**
* Selects indices in in stacked notes.
* @example
* note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
* .arp("0 [0,2] 1 [0,2]").slow(2)
* */
Pattern.prototype.arpWith = function (func) {
return this.collect()
.fmap((v) => reify(func(v)))
.squeezeJoin()
.innerJoin()
.withHap((h) => new Hap(h.whole, h.part, h.value.value, h.combineContext(h.value)));
};
// applies pattern of indices to each array of congruent haps
/**
* Selects indices in in stacked notes.
* @example
* note("<[c,eb,g]!2 [c,f,ab] [d,f,ab]>")
* .arp("0 [0,2] 1 [0,2]").slow(2)
* */
Pattern.prototype.arp = function (pat) {
return this.arpWith((haps) => pat.fmap((i) => haps[i % haps.length]));
};

View File

@ -822,6 +822,40 @@ exports[`runs examples > example "apply" example index 0 1`] = `
]
`;
exports[`runs examples > example "arp" example index 0 1`] = `
[
"[ 0/1 → 1/2 | note:c ]",
"[ 1/2 → 1/1 | note:c ]",
"[ 1/2 → 1/1 | note:g ]",
"[ 1/1 → 3/2 | note:eb ]",
"[ 3/2 → 2/1 | note:c ]",
"[ 3/2 → 2/1 | note:g ]",
"[ 2/1 → 5/2 | note:c ]",
"[ 5/2 → 3/1 | note:c ]",
"[ 5/2 → 3/1 | note:g ]",
"[ 3/1 → 7/2 | note:eb ]",
"[ 7/2 → 4/1 | note:c ]",
"[ 7/2 → 4/1 | note:g ]",
]
`;
exports[`runs examples > example "arpWith" example index 0 1`] = `
[
"[ 0/1 → 1/2 | note:c ]",
"[ 1/2 → 1/1 | note:c ]",
"[ 1/2 → 1/1 | note:g ]",
"[ 1/1 → 3/2 | note:eb ]",
"[ 3/2 → 2/1 | note:c ]",
"[ 3/2 → 2/1 | note:g ]",
"[ 2/1 → 5/2 | note:c ]",
"[ 5/2 → 3/1 | note:c ]",
"[ 5/2 → 3/1 | note:g ]",
"[ 3/1 → 7/2 | note:eb ]",
"[ 7/2 → 4/1 | note:c ]",
"[ 7/2 → 4/1 | note:g ]",
]
`;
exports[`runs examples > example "attack" example index 0 1`] = `
[
"[ 0/1 → 1/2 | note:c3 attack:0 ]",
@ -3418,3 +3452,20 @@ exports[`runs examples > example "when" example index 0 1`] = `
"[ 11/3 → 4/1 | note:50 ]",
]
`;
exports[`runs examples > example "withValue" example index 0 1`] = `
[
"[ 0/1 → 1/3 | 10 ]",
"[ 1/3 → 2/3 | 11 ]",
"[ 2/3 → 1/1 | 12 ]",
"[ 1/1 → 4/3 | 10 ]",
"[ 4/3 → 5/3 | 11 ]",
"[ 5/3 → 2/1 | 12 ]",
"[ 2/1 → 7/3 | 10 ]",
"[ 7/3 → 8/3 | 11 ]",
"[ 8/3 → 3/1 | 12 ]",
"[ 3/1 → 10/3 | 10 ]",
"[ 10/3 → 11/3 | 11 ]",
"[ 11/3 → 4/1 | 12 ]",
]
`;

View File

@ -857,7 +857,7 @@ export const arpoon = `// licensed with CC BY-NC-SA 4.0 https://creativecommons.
await samples('github:tidalcycles/Dirt-Samples/master')
"<<Am7 C^7> C7 F^7 [Fm7 E7b9]>".voicings('lefthand')
.arp("[0,3] 2 [1,3] 2".fast(3)).legato(2)
.arp("[0,3] 2 [1,3] 2".fast(3).lastOf(4, fast(2))).legato(2)
.add(perlin.range(0,0.2)).sub("<0 -12>/8")
.note().cutoff(perlin.range(500,4000)).resonance(12)
.gain("<.5 .8>*16")
@ -867,5 +867,5 @@ await samples('github:tidalcycles/Dirt-Samples/master')
.s('piano').clip(1)
.stack("<<A1 C2>!2 F2 [F2 E2]>".add.out("0 -5".fast(2)).add("0,.12").note().s('sawtooth').clip(1).cutoff(300))
.slow(4)
.stack(s("bd*4, [~ [hh hh? hh?]]*2,~ [sd ~ [sd:2? bd?]]").arp("0|1").bank('RolandTR909').gain(.5).slow(2))
.stack(s("bd*4, [~ [hh hh? hh?]]*2,~ [sd ~ [sd:2? bd?]]").bank('RolandTR909').gain(.5).slow(2))
`;