mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-23 03:28:33 +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;
|
this.lastEnd = end;
|
||||||
|
|
||||||
// query the pattern for events
|
// 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
|
const tickdeadline = phase - time; // time left until the phase is a whole number
|
||||||
this.lastTick = time + tickdeadline;
|
this.lastTick = time + tickdeadline;
|
||||||
|
|||||||
@ -340,9 +340,9 @@ export class Pattern {
|
|||||||
* silence
|
* silence
|
||||||
* @noAutocomplete
|
* @noAutocomplete
|
||||||
*/
|
*/
|
||||||
queryArc(begin, end) {
|
queryArc(begin, end, controls = {}) {
|
||||||
try {
|
try {
|
||||||
return this.query(new State(new TimeSpan(begin, end)));
|
return this.query(new State(new TimeSpan(begin, end), controls));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger(`[query]: ${err.message}`, 'error');
|
logger(`[query]: ${err.message}`, 'error');
|
||||||
return [];
|
return [];
|
||||||
@ -2341,14 +2341,19 @@ export const splice = register(
|
|||||||
'splice',
|
'splice',
|
||||||
function (npat, ipat, opat) {
|
function (npat, ipat, opat) {
|
||||||
const sliced = slice(npat, ipat, opat);
|
const sliced = slice(npat, ipat, opat);
|
||||||
return sliced.withHap(function (hap) {
|
return new Pattern((state) => {
|
||||||
return hap.withValue((v) => ({
|
// TODO - default cps to 0.5
|
||||||
...{
|
const cps = state.controls._cps || 1;
|
||||||
speed: (1 / v._slices / hap.whole.duration) * (v.speed || 1),
|
const haps = sliced.query(state);
|
||||||
unit: 'c',
|
return haps.map((hap) =>
|
||||||
},
|
hap.withValue((v) => ({
|
||||||
...v,
|
...{
|
||||||
}));
|
speed: (cps / v._slices / hap.whole.duration) * (v.speed || 1),
|
||||||
|
unit: 'c',
|
||||||
|
},
|
||||||
|
...v,
|
||||||
|
})),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
false, // turns off auto-patternification
|
false, // turns off auto-patternification
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user