From 1a95fb13390fbbcd9be20d3a31d2030839b5b0ec Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Thu, 31 Aug 2023 21:28:10 +0300 Subject: [PATCH] Added oneuclid for testing --- src/API.ts | 13 +++++++++++++ src/ArrayExtensions.ts | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/API.ts b/src/API.ts index b728ef8..380f1e2 100644 --- a/src/API.ts +++ b/src/API.ts @@ -1017,6 +1017,19 @@ export class UserAPI { return final_pulses.some((p) => p == true); }; + oneuclid = (pulses: number, length: number, rotate: number=0): boolean => { + /** + * Returns true if the current beat is in the given euclid sequence. + * @param pulses - The number of pulses in the cycle + * @param length - The length of the cycle + * @param rotate - Rotation of the euclidian sequence + * @returns True if the current beat is in the given euclid sequence + */ + const cycle = this._euclidean_cycle(pulses, length, rotate); + const beats = cycle.reduce((acc:number[], x:boolean, i:number) => { if(x) acc.push(i+1); return acc; }, []); + return this.oncount(beats, length); + }; + // ====================================================================== // Delay related functions // ====================================================================== diff --git a/src/ArrayExtensions.ts b/src/ArrayExtensions.ts index 3628fd0..905b188 100644 --- a/src/ArrayExtensions.ts +++ b/src/ArrayExtensions.ts @@ -121,7 +121,7 @@ export const makeArrayExtensions = (api: UserAPI) => { Array.prototype.div = function (divisor: number) { const chunk_size = divisor; // Get the first argument (chunk size) - const timepos = api.epulse(); + const timepos = api.app.clock.pulses_since_origin; const slice_count = Math.floor( timepos / Math.floor(chunk_size * api.ppqn()) );