Add check for negative bpm & ppqn

This commit is contained in:
2023-09-03 00:36:41 +03:00
parent cee8c82c89
commit 7224218122
2 changed files with 3 additions and 2 deletions

View File

@ -127,7 +127,7 @@ export class Clock {
} }
set bpm(bpm: number) { set bpm(bpm: number) {
if(this._bpm !== bpm) { if(bpm>0 && this._bpm !== bpm) {
this._bpm = bpm; this._bpm = bpm;
this.transportNode?.setBPM(bpm); this.transportNode?.setBPM(bpm);
} }
@ -138,7 +138,7 @@ export class Clock {
} }
set ppqn(ppqn: number) { set ppqn(ppqn: number) {
if(this._ppqn !== ppqn) { if(ppqn>0 && this._ppqn !== ppqn) {
this._ppqn = ppqn; this._ppqn = ppqn;
this.transportNode?.setPPQN(ppqn); this.transportNode?.setPPQN(ppqn);
} }

View File

@ -24,6 +24,7 @@ class TransportProcessor extends AudioWorkletProcessor {
this.currentPulsePosition = 0; this.currentPulsePosition = 0;
} else if(message.data.type === 'ppqn') { } else if(message.data.type === 'ppqn') {
this.ppqn = message.data.value; this.ppqn = message.data.value;
this.currentPulsePosition = 0;
} }
}; };