Change clock starting point and add oncount method as alternative to onbeat

This commit is contained in:
2023-08-31 19:42:45 +03:00
parent dd014e9df3
commit 323c6821d3
5 changed files with 59 additions and 18 deletions

View File

@ -256,7 +256,7 @@ ${makeExample(
`
mod(2) :: speak("Topos!","fr",irand(0,5))
`,
false
true
)}
@ -265,7 +265,7 @@ You can also use speech by chaining methods to a string:
${makeExample(
"Chaining string",
`
onbeat(1,3) :: "Foobaba".voice(irand(0,10)).speak()
onbeat(4) :: "Foobaba".voice(irand(0,10)).speak()
`,
true
)}
@ -284,18 +284,19 @@ ${makeExample(
)}
${makeExample(
"String chaining with array chaining",
"Live coded poetry with array and string chaining",
`
const croissant = ["Croissant!", "Volant", "Arc-en-ciel", "Chocolat", "Dansant", "Nuage", "Tournant", "Galaxie", "Chatoyant", "Flamboyant", "Cosmique"];
bpm(70)
onbeat(1) :: croissant.bar()
.lang("fr")
.volume(rand(0.2,2.0))
.rate(rand(.4,.6))
.speak();
const croissant = ["Volant", "Arc-en-ciel", "Chocolat", "Dansant", "Nuage", "Tournant", "Galaxie", "Chatoyant", "Flamboyant", "Cosmique","Croissant!"];
onbeat(4) :: croissant.bar()
.lang("fr")
.volume(rand(0.2,2.0))
.rate(rand(.4,.6))
.speak();
`,
false
true
)}
`;
};

View File

@ -89,7 +89,32 @@ mod([.25, 1/8].div(1.5))::snd('hat').n(2)
false
)}
- <ic>oncount(beats: number[], meter: number)</ic>: This function is similar to <ic>onbeat</ic> but it allows you to specify a custom meter (time signature denominator) for the beats.
${makeExample(
"Using oncount to create more variation in the rhythm",
`
bpm(120)
z1('q (0 4 2 9)+(0 3 1 5)').sound('sine').cutoff(400).delay(0.5).out()
onbeat(1,1.5,2,3,4) :: sound('bd').gain(2.0).out()
oncount([1,3,5.5,7,7.5,8],8) :: sound('hh').gain(irand(1.0,4.0)).out()
`,
true
)}
${makeExample(
"Using oncount to create rhythms with a custom meter",
`
bpm(280)
oncount([1,5,9,13],16) :: sound('bd').gain(3.0).out()
oncount([5,6,13],16) :: sound('cp').gain(1.0).out()
oncount([2,3,3.5,6,7,10,15],16) :: sound('hh').n(8).gain(1.0).out()
oncount([1,4,5,8,9,10,11,12,13,14,15,16],16) ::
sound('hh').out()
`,
true
)}
## Rhythm generators
We included a bunch of popular rhythm generators in Topos such as the euclidian rhythms algorithms or the one to generate rhythms based on a binary sequence. They all work using _iterators_ that you will gradually learn to use for iterating over lists. Note that they are levaraging <ic>mod(...n:number[])</ic> that you just learned about!