adjust flip function for more natural behavior
This commit is contained in:
@ -1084,8 +1084,9 @@ export class UserAPI {
|
||||
* @param ratio Optional ratio to influence the true/false output (0-100)
|
||||
* @returns Whether the function returns true or false based on ratio and time chunk
|
||||
*/
|
||||
let realChunk = chunk * 2;
|
||||
const time_pos = this.app.clock.pulses_since_origin;
|
||||
const full_chunk = Math.floor(chunk * this.ppqn());
|
||||
const full_chunk = Math.floor(realChunk * this.ppqn());
|
||||
// const current_chunk = Math.floor(time_pos / full_chunk);
|
||||
const threshold = Math.floor((ratio / 100) * full_chunk);
|
||||
const pos_within_chunk = time_pos % full_chunk;
|
||||
@ -1093,8 +1094,9 @@ export class UserAPI {
|
||||
};
|
||||
|
||||
public flipbar = (chunk: number = 1): boolean => {
|
||||
let realFlip = chunk * 2;
|
||||
const time_pos = this.app.clock.time_position.bar;
|
||||
const current_chunk = Math.floor(time_pos / chunk);
|
||||
const current_chunk = Math.floor(time_pos / realFlip);
|
||||
return current_chunk % 2 === 0;
|
||||
};
|
||||
|
||||
|
||||
@ -343,7 +343,7 @@ ${makeExample(
|
||||
"Clunky algorithmic rap music",
|
||||
`
|
||||
// Rap God VS Lil Wild -- Adel Faure
|
||||
if (flip(16)) {
|
||||
if (flip(8)) {
|
||||
// Playing this part for two bars
|
||||
beat(1.5)::snd('kick').out()
|
||||
beat(2)::snd('snare').out()
|
||||
@ -367,7 +367,7 @@ You can use it everywhere to spice things up, including as a method parameter pi
|
||||
${makeExample(
|
||||
"flip is great for parameter variation",
|
||||
`
|
||||
beat(.5)::snd(flip(4) ? 'kick' : 'hat').out()
|
||||
beat(.5)::snd(flip(2) ? 'kick' : 'hat').out()
|
||||
`,
|
||||
true
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user