Skip to content

Commit

Permalink
Merge pull request #959 from tidalcycles/euclid-inverted
Browse files Browse the repository at this point in the history
feat: can now invert euclid pulses with negative numbers
  • Loading branch information
felixroos authored Feb 29, 2024
2 parents 6a43eb6 + d4724b0 commit fa7c16d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/core/euclid.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ const _bjork = function (n, x) {
};

export const bjork = function (ons, steps) {
const inverted = ons < 0;
ons = Math.abs(ons);
const offs = steps - ons;
const x = Array(ons).fill([1]);
const y = Array(offs).fill([0]);
const result = _bjork([ons, offs], [x, y]);
return flatten(result[1][0]).concat(flatten(result[1][1]));
const p = flatten(result[1][0]).concat(flatten(result[1][1]));
if (inverted) {
return p.map((x) => (x === 0 ? 1 : 0));
}
return p;
};

/**
Expand Down

0 comments on commit fa7c16d

Please sign in to comment.