Tactus tweaks - fixes for maintaining tactus and highlight locations (#1065)

* outer bind/join should keep outer tactus
* keep locations of outer pattern in stepJoin
This commit is contained in:
Alex McLean 2024-04-23 14:14:30 +01:00 committed by GitHub
parent 9348a8015a
commit 267f58b7be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -257,12 +257,12 @@ export class Pattern {
} }
outerBind(func) { outerBind(func) {
return this.bindWhole((a) => a, func); return this.bindWhole((a) => a, func).setTactus(this.tactus);
} }
outerJoin() { outerJoin() {
// Flattens a pattern of patterns into a pattern, where wholes are // Flattens a pattern of patterns into a pattern, where wholes are
// taken from inner haps. // taken from outer haps.
return this.outerBind(id); return this.outerBind(id);
} }
@ -2429,7 +2429,10 @@ export function _slices(haps) {
const breakpoints = flatten(haps.map((hap) => [hap.part.begin, hap.part.end])); const breakpoints = flatten(haps.map((hap) => [hap.part.begin, hap.part.end]));
const unique = uniqsortr([Fraction(0), Fraction(1), ...breakpoints]); const unique = uniqsortr([Fraction(0), Fraction(1), ...breakpoints]);
const slicespans = pairs(unique); 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) { export function _fitslice(span, haps) {