Renamed slice to div, added pmod and added documentation.
This commit is contained in:
13
src/API.ts
13
src/API.ts
@ -483,7 +483,7 @@ export class UserAPI {
|
|||||||
// Sequencer related functions
|
// Sequencer related functions
|
||||||
// =============================================================
|
// =============================================================
|
||||||
|
|
||||||
public slice = (chunk: number): boolean => {
|
public div = (chunk: number): boolean => {
|
||||||
const time_pos = this.epulse();
|
const time_pos = this.epulse();
|
||||||
const current_chunk = Math.floor(
|
const current_chunk = Math.floor(
|
||||||
time_pos / Math.floor(chunk * this.ppqn())
|
time_pos / Math.floor(chunk * this.ppqn())
|
||||||
@ -491,13 +491,13 @@ export class UserAPI {
|
|||||||
return current_chunk % 2 === 0;
|
return current_chunk % 2 === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
public barslice = (chunk: number): boolean => {
|
public divbar = (chunk: number): boolean => {
|
||||||
const time_pos = this.bar() - 1;
|
const time_pos = this.bar() - 1;
|
||||||
const current_chunk = Math.floor(time_pos / chunk);
|
const current_chunk = Math.floor(time_pos / chunk);
|
||||||
return current_chunk % 2 === 0;
|
return current_chunk % 2 === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
public seqslice = (...args: any): any => {
|
public divseq = (...args: any): any => {
|
||||||
const chunk_size = args[0]; // Get the first argument (chunk size)
|
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
|
const elements = args.slice(1); // Get the rest of the arguments as an array
|
||||||
const timepos = this.epulse();
|
const timepos = this.epulse();
|
||||||
@ -1002,12 +1002,19 @@ export class UserAPI {
|
|||||||
return results.some((value) => value === true);
|
return results.some((value) => value === true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public modpulse = (...n: number[]): boolean => {
|
||||||
|
const results: boolean[] = n.map((value) => this.epulse() % value === 0);
|
||||||
|
return results.some((value) => value === true);
|
||||||
|
};
|
||||||
|
pmod = this.modpulse;
|
||||||
|
|
||||||
public modbar = (...n: number[]): boolean => {
|
public modbar = (...n: number[]): boolean => {
|
||||||
const results: boolean[] = n.map(
|
const results: boolean[] = n.map(
|
||||||
(value) => this.bar() % Math.floor(value * this.ppqn()) === 0
|
(value) => this.bar() % Math.floor(value * this.ppqn()) === 0
|
||||||
);
|
);
|
||||||
return results.some((value) => value === true);
|
return results.some((value) => value === true);
|
||||||
};
|
};
|
||||||
|
bmod = this.modbar;
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// Rythmic generators
|
// Rythmic generators
|
||||||
|
|||||||
@ -143,7 +143,12 @@ Some functions can be leveraged to play rhythms without thinking too much about
|
|||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
- <icode>onbar(...values: number[])</icode>: returns <icode>true</icode> if the bar is currently equal to any of the specified values.
|
- <icode>onbar(...values: number[])</icode>: returns <icode>true</icode> if the bar is currently equal to any of the specified values.
|
||||||
- <icode>modbar(...values: number[])</icode>: returns <icode>true</icode> if the bar is currently a multiple of any of the specified values.
|
- <icode>modbar(...values: number[]) or bmod(...)</icode>: returns <icode>true</icode> if the bar is currently a multiple of any of the specified values.
|
||||||
|
- <icode>modpulse(...values: number[]) or pmod(...)</icode>: returns <icode>true</icode> if the pulse is currently a multiple of any of the specified values.
|
||||||
|
|
||||||
|
- <icode>div(chunk: number)</icode>: returns <icode>true</icode> for every pulse in intervals of given number of beats
|
||||||
|
- <icode>divbar(chunk: number)</icode>: returns <icode>true</icode> for every pulse in intervals of given number of bars
|
||||||
|
- <icode>divseq(...values: number[])</icode>: returns <icode>true</icode> for every pulse in intervals of given number of beats returning different value each time.
|
||||||
|
|
||||||
## Rhythm generators
|
## Rhythm generators
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user