Merge remote-tracking branch 'origin/main' into notes-and-numbers

This commit is contained in:
Felix Roos 2022-03-06 19:23:24 +01:00
commit af81626f43
15 changed files with 383 additions and 142 deletions

View file

@ -749,30 +749,23 @@ class Pattern {
return silence;
}
_len(value) {
// return this.withEventSpan((span) => new TimeSpan(span.begin, span.begin.add(span.end.sub(span.begin).mul(value))));
// sets absolute duration of events
_duration(value) {
return this.withEventSpan((span) => new TimeSpan(span.begin, span.begin.add(value)));
}
/*
_resolveTies() {
return this._withEvents((events)=>{
return events.reduce((tied, event, i) => {
const value = event.value?.value || event.value;
if (value !== '_') {
return tied.concat([event]);
}
console.log('tie!', lastEvent);
tied[i - 1] = tied[i - 1].withSpan((span) => span.withEnd((_) => event.part.end));
// above only works if the tie is not across a cycle boundary... how to do that???
// TODO: handle case that there is a gap between tied[i-1].part.end and event.part.begin => tie would make no sense
return tied;
}, []);
})
} */
// sets event relative duration of events
_legato(value) {
return this.withEventSpan((span) => new TimeSpan(span.begin, span.begin.add(span.end.sub(span.begin).mul(value))));
}
_velocity(velocity) {
return this._withContext((context) => ({ ...context, velocity: (context.velocity || 1) * velocity }));
}
}
// methods of Pattern that get callable factories
Pattern.prototype.patternified = ['apply', 'fast', 'slow', 'early', 'late', 'len'];
Pattern.prototype.patternified = ['apply', 'fast', 'slow', 'early', 'late', 'duration', 'legato', 'velocity'];
// methods that create patterns, which are added to patternified Pattern methods
Pattern.prototype.factories = { pure, stack, slowcat, fastcat, cat, timeCat, sequence, polymeter, pm, polyrhythm, pr};
// the magic happens in Pattern constructor. Keeping this in prototype enables adding methods from the outside (e.g. see tonal.ts)