Use mathematical mod in slowcat, fixes #85

This commit is contained in:
alex 2022-04-22 17:02:21 +01:00
parent 3742bf384c
commit 903c065e26

View File

@ -3,7 +3,7 @@ import Fraction from './fraction.mjs';
import Hap from './hap.mjs';
import State from './state.mjs';
import { isNote, toMidi, compose, removeUndefineds, flatten, id, listRange, curry } from './util.mjs';
import { isNote, toMidi, compose, removeUndefineds, flatten, id, listRange, curry, mod } from './util.mjs';
export class Pattern {
// the following functions will get patternFactories as nested functions:
@ -828,7 +828,7 @@ export function slowcat(...pats) {
pats = pats.map(reify);
const query = function (state) {
const span = state.span;
const pat_n = Math.floor(span.begin) % pats.length;
const pat_n = mod(span.begin.sam(), pats.length);
const pat = pats[pat_n];
if (!pat) {
// pat_n can be negative, if the span is in the past..