Skip to content

Commit

Permalink
Tactus tweaks - fixes for maintaining tactus and highlight locations (#…
Browse files Browse the repository at this point in the history
…1065)

* outer bind/join should keep outer tactus
* keep locations of outer pattern in stepJoin
  • Loading branch information
yaxu authored Apr 23, 2024
1 parent 9348a80 commit 267f58b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/core/pattern.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ export class Pattern {
}

outerBind(func) {
return this.bindWhole((a) => a, func);
return this.bindWhole((a) => a, func).setTactus(this.tactus);
}

outerJoin() {
// Flattens a pattern of patterns into a pattern, where wholes are
// taken from inner haps.
// taken from outer haps.
return this.outerBind(id);
}

Expand Down Expand Up @@ -2429,7 +2429,10 @@ export function _slices(haps) {
const breakpoints = flatten(haps.map((hap) => [hap.part.begin, hap.part.end]));
const unique = uniqsortr([Fraction(0), Fraction(1), ...breakpoints]);
const slicespans = pairs(unique);
return slicespans.map((s) => [s[1].sub(s[0]), stack(..._fitslice(new TimeSpan(...s), haps).map((x) => x.value))]);
return slicespans.map((s) => [
s[1].sub(s[0]),
stack(..._fitslice(new TimeSpan(...s), haps).map((x) => x.value.withHap((h) => h.setContext(h.combineContext(x))))),
]);
}

export function _fitslice(span, haps) {
Expand Down

0 comments on commit 267f58b

Please sign in to comment.