Added oneuclid for testing

This commit is contained in:
2023-08-31 21:28:10 +03:00
parent 323c6821d3
commit 1a95fb1339
2 changed files with 14 additions and 1 deletions

View File

@ -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
// ======================================================================

View File

@ -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())
);