Added some drawing methods
This commit is contained in:
37
src/documentation/patterns/generators.ts
Normal file
37
src/documentation/patterns/generators.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { type Editor } from "../../main";
|
||||
import { makeExampleFactory } from "../../Documentation";
|
||||
|
||||
export const generators = (application: Editor): string => {
|
||||
const makeExample = makeExampleFactory(application);
|
||||
return `
|
||||
# Generator functions
|
||||
|
||||
|
||||
${makeExample(
|
||||
"More complex function generating chaotic frequencies",
|
||||
`
|
||||
function* strange(x = 0.1, y = 0, z = 0, rho = 28, beta = 8 / 3, zeta = 10) {
|
||||
while (true) {
|
||||
const dx = 10 * (y - x);
|
||||
const dy = x * (rho - z) - y;
|
||||
const dz = x * y - beta * z;
|
||||
|
||||
x += dx * 0.01;
|
||||
y += dy * 0.01;
|
||||
z += dz * 0.01;
|
||||
|
||||
const value = 300 + 30 * (Math.sin(x) + Math.tan(y) + Math.cos(z))
|
||||
yield value;
|
||||
}
|
||||
}
|
||||
|
||||
beat(0.25) :: sound("triangle")
|
||||
.freq(cache("stranger",strange(3,5,2)))
|
||||
.adsr(.15,.1,.1,.1)
|
||||
.log("freq").out()
|
||||
`,
|
||||
true,
|
||||
)};
|
||||
|
||||
`;
|
||||
};
|
||||
@ -190,7 +190,7 @@ ${makeExample(
|
||||
)}
|
||||
|
||||
${makeExample(
|
||||
"Chord transposition with roman numerals",
|
||||
"Chord inversions with roman numerals",
|
||||
`
|
||||
z1('i i v%-4 v%-2 vi%-5 vi%-3 iv%-2 iv%-1')
|
||||
.sound('triangle').adsr(1/16, 1/5, 0.1, 0)
|
||||
@ -201,7 +201,7 @@ ${makeExample(
|
||||
)}
|
||||
|
||||
${makeExample(
|
||||
"Chord transposition with named chords",
|
||||
"Chord inversion with named chords",
|
||||
`
|
||||
z1('1/4 Cmin!3 Fmin!3 Fmin%-1 Fmin%-2 Fmin%-1')
|
||||
.sound("sine").bpf(500 + usine(1/4) * 2000)
|
||||
|
||||
Reference in New Issue
Block a user