From 4c582b1cba24908643994b07f55eb87161a9a56e Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Sat, 19 Aug 2023 17:18:58 +0200 Subject: [PATCH] adding barslice function --- src/API.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/API.ts b/src/API.ts index becd941..a081e43 100644 --- a/src/API.ts +++ b/src/API.ts @@ -469,6 +469,12 @@ export class UserAPI { return current_chunk % 2 === 0; }; + public barslice = (chunk: number): boolean => { + const time_pos = this.bar() - 1; + const current_chunk = Math.floor(time_pos / chunk); + return current_chunk % 2 === 0; + }; + public seqslice = (...args: any): any => { const chunk_size = args[0]; // Get the first argument (chunk size) const elements = args.slice(1); // Get the rest of the arguments as an array @@ -994,6 +1000,11 @@ export class UserAPI { return results.some((value) => value === true); }; + public modbar = (...n: number[]): boolean[] => { + const results: boolean[] = n.map((value) => bar() % value === 0); + return results.some((value) => value === true); + }; + // mod = (...pulse: number[]): boolean => { // /** // * Returns true if the current pulse is a modulo of any of the given pulses. @@ -1004,17 +1015,6 @@ export class UserAPI { // return pulse.some((p) => this.app.clock.time_position.pulse % p === 0); // }; - modbar = (...bar: number[]): boolean => { - /** - * Returns true if the current bar is a modulo of any of the given bars. - * - * @param bar - The bar to check for - * @returns True if the current bar is a modulo of any of the given bars - * - */ - return bar.some((b) => this.app.clock.time_position.bar % b === 0); - }; - // ============================================================= // Rythmic generators // =============================================================