limit evaluation to once per pulse
This commit is contained in:
@ -2,8 +2,6 @@ import { Editor } from "./main";
|
|||||||
import { tryEvaluate } from "./Evaluator";
|
import { tryEvaluate } from "./Evaluator";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { ZZFX, zzfx } from "zzfx";
|
import { ZZFX, zzfx } from "zzfx";
|
||||||
// import * as Tone from 'tone';
|
|
||||||
|
|
||||||
|
|
||||||
export class UserAPI {
|
export class UserAPI {
|
||||||
|
|
||||||
|
|||||||
@ -10,14 +10,27 @@ export class TransportNode extends AudioWorkletNode {
|
|||||||
this.port.start();
|
this.port.start();
|
||||||
/** @type {HTMLSpanElement} */
|
/** @type {HTMLSpanElement} */
|
||||||
this.$clock = document.getElementById("clockviewer");
|
this.$clock = document.getElementById("clockviewer");
|
||||||
|
this.hasBeenEvaluated = false;
|
||||||
|
this.currentPulse = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {(this: MessagePort, ev: MessageEvent<any>) => any} */
|
/** @type {(this: MessagePort, ev: MessageEvent<any>) => any} */
|
||||||
handleMessage = (message) => {
|
handleMessage = (message) => {
|
||||||
if (message.data && message.data.type === "bang") {
|
if (message.data && message.data.type === "bang") {
|
||||||
let info = this.convertTimeToBarsBeats(message.data.currentTime);
|
let info = this.convertTimeToBarsBeats(message.data.currentTime);
|
||||||
this.app.clock.time_position = { bar: info.bar, beat: info.beat, pulse: info.ppqn }
|
this.app.clock.time_position = { bar: info.bar, beat: info.beat, pulse: info.ppqn }
|
||||||
this.$clock.innerHTML = `[${info.bar} | ${info.beat} | ${zeroPad(info.ppqn, '2')}]`
|
this.$clock.innerHTML = `[${info.bar} | ${info.beat} | ${zeroPad(info.ppqn, '2')}]`
|
||||||
tryEvaluate( this.app, this.app.global_buffer );
|
|
||||||
|
// Evaluate the global buffer only once per ppqn value
|
||||||
|
if (this.currentPulse !== info.ppqn) {
|
||||||
|
this.hasBeenEvaluated = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.hasBeenEvaluated) {
|
||||||
|
tryEvaluate( this.app, this.app.global_buffer );
|
||||||
|
this.hasBeenEvaluated = true;
|
||||||
|
this.currentPulse = info.ppqn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user