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

@ -983,11 +983,14 @@ export class UserAPI {
* @param beat - The beats to check
* @returns True if the current beat is in the given list of beats
*/
const origin = this.app.clock.pulses_since_origin;
let final_pulses: boolean[] = [];
beat.forEach((b) => {
const pulses = Math.floor(b * this.ppqn());
return final_pulses.push(origin % pulses === 0);
const beat = b % this.nominator() || this.nominator();
const integral_part = Math.floor(beat);
const decimal_part = (beat - integral_part) * this.ppqn() + 1;
final_pulses.push(
integral_part === this.beat() && this.pulse() === decimal_part
);
});
return final_pulses.some((p) => p == true);
};