Logging for testing message delay
This commit is contained in:
@ -41,6 +41,7 @@ export class Clock {
|
|||||||
time_position: TimePosition;
|
time_position: TimePosition;
|
||||||
private _ppqn: number;
|
private _ppqn: number;
|
||||||
tick: number;
|
tick: number;
|
||||||
|
running: boolean;
|
||||||
|
|
||||||
constructor(public app: Editor, ctx: AudioContext) {
|
constructor(public app: Editor, ctx: AudioContext) {
|
||||||
this.time_position = { bar: 0, beat: 0, pulse: 0 };
|
this.time_position = { bar: 0, beat: 0, pulse: 0 };
|
||||||
@ -52,6 +53,7 @@ export class Clock {
|
|||||||
this._ppqn = 48;
|
this._ppqn = 48;
|
||||||
this.transportNode = null;
|
this.transportNode = null;
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
this.running = true;
|
||||||
ctx.audioWorklet
|
ctx.audioWorklet
|
||||||
.addModule(TransportProcessor)
|
.addModule(TransportProcessor)
|
||||||
.then((e) => {
|
.then((e) => {
|
||||||
@ -138,7 +140,7 @@ export class Clock {
|
|||||||
set bpm(bpm: number) {
|
set bpm(bpm: number) {
|
||||||
if (bpm > 0 && this._bpm !== bpm) {
|
if (bpm > 0 && this._bpm !== bpm) {
|
||||||
this.transportNode?.setBPM(bpm);
|
this.transportNode?.setBPM(bpm);
|
||||||
this._bpm = bpm
|
this._bpm = bpm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +200,7 @@ export class Clock {
|
|||||||
* @remark also sends a MIDI message if a port is declared
|
* @remark also sends a MIDI message if a port is declared
|
||||||
*/
|
*/
|
||||||
this.app.audioContext.resume();
|
this.app.audioContext.resume();
|
||||||
|
this.running = true;
|
||||||
this.app.api.MidiConnection.sendStartMessage();
|
this.app.api.MidiConnection.sendStartMessage();
|
||||||
if (this.tick > 0) {
|
if (this.tick > 0) {
|
||||||
this.transportNode?.resume();
|
this.transportNode?.resume();
|
||||||
@ -212,6 +215,7 @@ export class Clock {
|
|||||||
*
|
*
|
||||||
* @remark also sends a MIDI message if a port is declared
|
* @remark also sends a MIDI message if a port is declared
|
||||||
*/
|
*/
|
||||||
|
this.running = false;
|
||||||
this.transportNode?.pause();
|
this.transportNode?.pause();
|
||||||
this.app.api.MidiConnection.sendStopMessage();
|
this.app.api.MidiConnection.sendStopMessage();
|
||||||
}
|
}
|
||||||
@ -222,6 +226,7 @@ export class Clock {
|
|||||||
*
|
*
|
||||||
* @remark also sends a MIDI message if a port is declared
|
* @remark also sends a MIDI message if a port is declared
|
||||||
*/
|
*/
|
||||||
|
this.running = false;
|
||||||
this.app.clock.tick = 0;
|
this.app.clock.tick = 0;
|
||||||
this.logicalTime = 0;
|
this.logicalTime = 0;
|
||||||
this.elapsed = 0;
|
this.elapsed = 0;
|
||||||
|
|||||||
@ -16,19 +16,24 @@ export class TransportNode extends AudioWorkletNode {
|
|||||||
if (message.data.type === "elapsed") {
|
if (message.data.type === "elapsed") {
|
||||||
this.app.clock.elapsed = message.data.value
|
this.app.clock.elapsed = message.data.value
|
||||||
} else if (message.data.type === "bang") {
|
} else if (message.data.type === "bang") {
|
||||||
if (this.app.settings.send_clock)
|
if(this.app.clock.running) {
|
||||||
this.app.api.MidiConnection.sendMidiClock();
|
if (this.app.settings.send_clock) {
|
||||||
this.app.clock.incrementTick();
|
this.app.api.MidiConnection.sendMidiClock();
|
||||||
const futureTimeStamp = this.app.clock.convertTicksToTimeposition(
|
}
|
||||||
this.app.clock.tick
|
const futureTimeStamp = this.app.clock.convertTicksToTimeposition(
|
||||||
);
|
this.app.clock.tick
|
||||||
this.app.clock.time_position = futureTimeStamp;
|
);
|
||||||
this.timeviewer.innerHTML = `${zeroPad(futureTimeStamp.bar, 2)}:${futureTimeStamp.beat + 1
|
this.app.clock.time_position = futureTimeStamp;
|
||||||
}:${zeroPad(futureTimeStamp.pulse, 2)} / ${this.app.clock.bpm}`;
|
this.timeviewer.innerHTML = `${zeroPad(futureTimeStamp.bar, 2)}:${futureTimeStamp.beat + 1
|
||||||
if (this.app.exampleIsPlaying) {
|
}:${zeroPad(futureTimeStamp.pulse, 2)} / ${this.app.clock.bpm}`;
|
||||||
tryEvaluate(this.app, this.app.example_buffer);
|
if (this.app.exampleIsPlaying) {
|
||||||
|
tryEvaluate(this.app, this.app.example_buffer);
|
||||||
|
} else {
|
||||||
|
tryEvaluate(this.app, this.app.global_buffer);
|
||||||
|
}
|
||||||
|
this.app.clock.incrementTick();
|
||||||
} else {
|
} else {
|
||||||
tryEvaluate(this.app, this.app.global_buffer);
|
console.log("STILLLLLLLLLLLLLLLL BANGING!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user