Synced ziffers to onbeat (on start) + merge

This commit is contained in:
2023-08-24 18:34:08 +03:00
parent f579d4a0ff
commit 0e275204fd
5 changed files with 30 additions and 27 deletions

View File

@ -10,6 +10,7 @@ export class Player extends Event {
input: string;
ziffers: Ziffers;
callTime: number = 0;
startBeat: number = 0;
played: boolean = false;
current!: Pitch|Chord|ZRest;
retro: boolean = false;
@ -21,6 +22,10 @@ export class Player extends Event {
this.ziffers = new Ziffers(input, options);
}
notStarted(): boolean {
return this.ziffers.notStarted();
}
next = (): Pitch|Chord|ZRest => {
this.current = this.ziffers.next() as Pitch|Chord|ZRest;
this.played = true;
@ -32,10 +37,15 @@ export class Player extends Event {
}
areWeThereYet = (): boolean => {
const howAboutNow = (this.ziffers.notStarted() ||
this.pulseToSecond(this.app.api.epulse()) >
this.pulseToSecond(this.callTime) +
this.current.duration * this.pulseToSecond(this.app.api.ppqn() * 4))
const howAboutNow = (
(this.notStarted()) ||
(
this.current &&
this.pulseToSecond(this.app.api.epulse()+1) >=
this.pulseToSecond(this.callTime) +
(this.current.duration*4) * this.pulseToSecond(this.app.api.ppqn())
)
);
if(howAboutNow) {
this.tick = 0;
} else {