add duration + legato

This commit is contained in:
Felix Roos 2022-03-06 10:35:23 +01:00
parent 05804262f0
commit 7e0b6d7f2a

View File

@ -722,26 +722,20 @@ class Pattern {
hush() { hush() {
return silence; return silence;
} }
/*
_resolveTies() { // sets absolute duration of events
return this._withEvents((events)=>{ _duration(value) {
return events.reduce((tied, event, i) => { return this.withEventSpan((span) => new TimeSpan(span.begin, span.begin.add(value)));
const value = event.value?.value || event.value; }
if (value !== '_') {
return tied.concat([event]); // sets event relative duration of events
} _legato(value) {
console.log('tie!', lastEvent); return this.withEventSpan((span) => new TimeSpan(span.begin, span.begin.add(span.end.sub(span.begin).mul(value))));
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;
}, []);
})
} */
} }
// methods of Pattern that get callable factories // methods of Pattern that get callable factories
Pattern.prototype.patternified = ['apply', 'fast', 'slow', 'early', 'late']; Pattern.prototype.patternified = ['apply', 'fast', 'slow', 'early', 'late', 'duration', 'legato'];
// methods that create patterns, which are added to patternified Pattern methods // 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}; 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) // the magic happens in Pattern constructor. Keeping this in prototype enables adding methods from the outside (e.g. see tonal.ts)