Account for deviation

This commit is contained in:
2023-10-27 10:00:21 +02:00
parent 0e205b6b6c
commit 0c5437e1c5
2 changed files with 8 additions and 4 deletions

View File

@ -152,6 +152,10 @@ export class Clock {
return this.elapsed;
}
get deviation(): number {
return Math.abs(this.logicalTime - this.realTime)
}
set ppqn(ppqn: number) {
if (ppqn > 0 && this._ppqn !== ppqn) {
this._ppqn = ppqn;
@ -215,8 +219,8 @@ export class Clock {
*
* @remark also sends a MIDI message if a port is declared
*/
this.app.clock.tick = -1;
this.time_position = { bar: -1, beat: -1, pulse: -1 };
this.app.clock.tick = 0;
this.time_position = { bar: 0, beat: 0, pulse: 0 };
this.app.api.MidiConnection.sendStopMessage();
this.transportNode?.stop();
}

View File

@ -463,10 +463,10 @@ export class SoundEvent extends AudibleEvent {
this.values.chord.forEach((obj: { [key: string]: number }) => {
const copy = { ...this.values };
copy.freq = obj.freq;
superdough(copy, this.nudge, this.values.dur);
superdough(copy, this.nudge - this.app.clock.deviation, this.values.dur);
});
} else {
superdough(this.values, this.nudge, this.values.dur);
superdough(this.values, this.nudge - this.app.clock.deviation, this.values.dur);
}
};
}