diff --git a/src/API.ts b/src/API.ts index f892863..95eebe6 100644 --- a/src/API.ts +++ b/src/API.ts @@ -400,6 +400,16 @@ export class UserAPI { return array[this.app.clock.time_position.beat % array.length] } + mel(iterator: number, array: T[]): T { + /** + * Returns an element from an array based on the current value of an iterator. + * + * @param iterator - The name of the iterator + * @param array - The array of values to pick from + */ + return array[iterator % array.length] + } + seqbar(...array: T[]): T { /** * Returns an element from an array based on the current bar. @@ -807,6 +817,19 @@ export class UserAPI { return cycle; } + bin(iterator: number, n: number): boolean { + /** + * Returns a binary cycle of size n. + * + * @param iterator - Iteration number in the binary cycle + * @param n - The number to convert to binary + * @returns boolean value based on the binary sequence + */ + let convert: string = n.toString(2); + let tobin: boolean[] = convert.split("").map((x: string) => x === "1"); + return tobin[iterator % tobin.length]; + } + // ============================================================= // Low Frequency Oscillators // =============================================================