adding the binrhythm function
This commit is contained in:
13
src/API.ts
13
src/API.ts
@ -1219,6 +1219,19 @@ export class UserAPI {
|
|||||||
return tobin[iterator % tobin.length];
|
return tobin[iterator % tobin.length];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public binrhythm = (div: number, n: number): boolean => {
|
||||||
|
/**
|
||||||
|
* Returns a binary cycle of size n, divided by div.
|
||||||
|
*
|
||||||
|
* @param div - The divisor of 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 this.mod(div) && tobin.div(div);
|
||||||
|
};
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// Low Frequency Oscillators
|
// Low Frequency Oscillators
|
||||||
// =============================================================
|
// =============================================================
|
||||||
|
|||||||
@ -182,6 +182,7 @@ rhythm(speed, 7, 12) :: snd('east').n(9).out()
|
|||||||
|
|
||||||
|
|
||||||
- <ic>bin(iterator: number, n: number): boolean</ic>: a binary rhythm generator. It transforms the given number into its binary representation (_e.g_ <ic>34</ic> becomes <ic>100010</ic>). It then returns a boolean value based on the iterator in order to generate a rhythm.
|
- <ic>bin(iterator: number, n: number): boolean</ic>: a binary rhythm generator. It transforms the given number into its binary representation (_e.g_ <ic>34</ic> becomes <ic>100010</ic>). It then returns a boolean value based on the iterator in order to generate a rhythm.
|
||||||
|
- <ic>binrhythm(divisor: number, n: number): boolean: boolean</ic>: iterator-less version of the binary rhythm generator.
|
||||||
|
|
||||||
${makeExample(
|
${makeExample(
|
||||||
"Change the integers for a surprise rhythm!",
|
"Change the integers for a surprise rhythm!",
|
||||||
@ -192,6 +193,15 @@ mod(.5) && bin($(2), 48) && snd('sd').out()
|
|||||||
true
|
true
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
${makeExample(
|
||||||
|
"binrhythm for fast cool binary rhythms!",
|
||||||
|
`
|
||||||
|
binrhythm(.5, 13) && snd('kick').out()
|
||||||
|
binrhythm(.5, 18) && snd('sd').out()
|
||||||
|
`,
|
||||||
|
true
|
||||||
|
)}
|
||||||
|
|
||||||
${makeExample(
|
${makeExample(
|
||||||
"Calling 911",
|
"Calling 911",
|
||||||
`
|
`
|
||||||
|
|||||||
Reference in New Issue
Block a user