From e424fb577ab6a33bd993209031608bd70edff9ac Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Tue, 24 Oct 2023 21:53:38 +0200 Subject: [PATCH] first wip of seq func --- src/API.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/API.ts b/src/API.ts index f66d43b..deecdf4 100644 --- a/src/API.ts +++ b/src/API.ts @@ -1280,6 +1280,25 @@ export class UserAPI { // Time Filters // ============================================================= + + public seq = (expr: string, duration: number): boolean => { + let len = expr.length * duration + let output: number[] = []; + + for (let i = 1; i <= len + 1; i += duration) { + output.push(Math.floor(i * 10) / 10); + } + output.pop() + + output = output.filter((_, idx) => { + const exprIdx = idx % expr.length; + return expr[exprIdx] === 'x'; + }); + + return this.oncount(output, len) + } + + public beat = (n: number | number[] = 1, nudge: number = 0): boolean => { /** * Determine if the current pulse is on a specified beat, with optional nudge.