mirror of
https://github.com/eliasstepanik/strudel.git
synced 2026-01-11 05:38:35 +00:00
Make splice cps-aware (#932)
* make splice cps-aware * format * copypaste fix
This commit is contained in:
parent
a7f5d0e0c1
commit
738cea0025
@ -41,7 +41,7 @@ export class Cyclist {
|
||||
this.lastEnd = end;
|
||||
|
||||
// query the pattern for events
|
||||
const haps = this.pattern.queryArc(begin, end);
|
||||
const haps = this.pattern.queryArc(begin, end, { _cps: this.cps });
|
||||
|
||||
const tickdeadline = phase - time; // time left until the phase is a whole number
|
||||
this.lastTick = time + tickdeadline;
|
||||
|
||||
@ -340,9 +340,9 @@ export class Pattern {
|
||||
* silence
|
||||
* @noAutocomplete
|
||||
*/
|
||||
queryArc(begin, end) {
|
||||
queryArc(begin, end, controls = {}) {
|
||||
try {
|
||||
return this.query(new State(new TimeSpan(begin, end)));
|
||||
return this.query(new State(new TimeSpan(begin, end), controls));
|
||||
} catch (err) {
|
||||
logger(`[query]: ${err.message}`, 'error');
|
||||
return [];
|
||||
@ -2341,14 +2341,19 @@ export const splice = register(
|
||||
'splice',
|
||||
function (npat, ipat, opat) {
|
||||
const sliced = slice(npat, ipat, opat);
|
||||
return sliced.withHap(function (hap) {
|
||||
return hap.withValue((v) => ({
|
||||
...{
|
||||
speed: (1 / v._slices / hap.whole.duration) * (v.speed || 1),
|
||||
unit: 'c',
|
||||
},
|
||||
...v,
|
||||
}));
|
||||
return new Pattern((state) => {
|
||||
// TODO - default cps to 0.5
|
||||
const cps = state.controls._cps || 1;
|
||||
const haps = sliced.query(state);
|
||||
return haps.map((hap) =>
|
||||
hap.withValue((v) => ({
|
||||
...{
|
||||
speed: (cps / v._slices / hap.whole.duration) * (v.speed || 1),
|
||||
unit: 'c',
|
||||
},
|
||||
...v,
|
||||
})),
|
||||
);
|
||||
});
|
||||
},
|
||||
false, // turns off auto-patternification
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user