Merge branch 'main' of github.com:Bubobubobubobubo/Topos

This commit is contained in:
2023-12-20 11:52:31 +01:00
2 changed files with 21 additions and 2 deletions

View File

@ -1488,7 +1488,7 @@ export class UserAPI {
}; };
public flipbar = (chunk: number = 1): boolean => { public flipbar = (chunk: number = 1): boolean => {
let realFlip = chunk * 2; let realFlip = chunk;
const time_pos = this.app.clock.time_position.bar; const time_pos = this.app.clock.time_position.bar;
const current_chunk = Math.floor(time_pos / realFlip); const current_chunk = Math.floor(time_pos / realFlip);
return current_chunk % 2 === 0; return current_chunk % 2 === 0;

View File

@ -120,7 +120,26 @@ beat(1)::sound(['kick', 'fsnare'].dur(3, 1))
true, true,
)} )}
## Iterating over lists ${makeExample(
"Patterning with ternary statements",
`
const dada = flipbar(2) ? [0,[3,5,-1].bar(3),2,3] : [9,8,9,6]
beat(0.5) :: sound('wt_hvoice:3')
.pitch(dada.beat(0.5))
.scale("88.0")
.adsr(0.05, 0.05, 0, 0)
.cutoff(500 + usine(1/8) * 5000)
.room(1.5)
.resonance(0.25)
.out()
beat(1) :: sound('kick').n(4).out()
onbeat([0.5,0.8].beat(1),2) :: sound('snare').out()
onbeat(0.5,0.8,1,1.5,2,2.5,3,4) :: sound('hh').out()
`,
true,
)}
## Iteration using a counter
- <ic>counter(name,limit?,step?)</ic>: return the next value on the list based on counter value. The limit is optional and defaults to the length of the list. The step is optional and defaults to 1. Setting / changing limit will reset the counter. - <ic>counter(name,limit?,step?)</ic>: return the next value on the list based on counter value. The limit is optional and defaults to the length of the list. The step is optional and defaults to 1. Setting / changing limit will reset the counter.
- <ic>$(name,limit?,step?)</ic>: shorter alias for the counter. - <ic>$(name,limit?,step?)</ic>: shorter alias for the counter.