Added oneuclid for testing
This commit is contained in:
13
src/API.ts
13
src/API.ts
@ -1017,6 +1017,19 @@ export class UserAPI {
|
|||||||
return final_pulses.some((p) => p == true);
|
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
|
// Delay related functions
|
||||||
// ======================================================================
|
// ======================================================================
|
||||||
|
|||||||
@ -121,7 +121,7 @@ export const makeArrayExtensions = (api: UserAPI) => {
|
|||||||
|
|
||||||
Array.prototype.div = function (divisor: number) {
|
Array.prototype.div = function (divisor: number) {
|
||||||
const chunk_size = divisor; // Get the first argument (chunk size)
|
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(
|
const slice_count = Math.floor(
|
||||||
timepos / Math.floor(chunk_size * api.ppqn())
|
timepos / Math.floor(chunk_size * api.ppqn())
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user