Merge pull request #92 from Bubobubobubobubo/opti
Small optimisations before gig
This commit is contained in:
@ -93,26 +93,29 @@ export const blinkScript = (
|
|||||||
(app.interface.feedback as HTMLCanvasElement).width,
|
(app.interface.feedback as HTMLCanvasElement).width,
|
||||||
(app.interface.feedback as HTMLCanvasElement).height
|
(app.interface.feedback as HTMLCanvasElement).height
|
||||||
);
|
);
|
||||||
drawEmptyBlinkers(app);
|
|
||||||
}, blinkDuration);
|
}, blinkDuration);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a series of 9 white circles.
|
* Manages animation updates using requestAnimationFrame.
|
||||||
* @param app - The Editor application context.
|
* @param app - The Editor application context.
|
||||||
*/
|
*/
|
||||||
export const drawEmptyBlinkers = (app: Editor) => {
|
export const scriptBlinkers = () => {
|
||||||
for (let no = 1; no <= 9; no++) {
|
let lastFrameTime = Date.now();
|
||||||
const shiftAmount = no * 25;
|
const frameRate = 10;
|
||||||
drawCircle(
|
const minFrameDelay = 1000 / frameRate;
|
||||||
app,
|
|
||||||
50 + shiftAmount,
|
const update = () => {
|
||||||
app.interface.feedback.clientHeight - 15,
|
const now = Date.now();
|
||||||
8,
|
const timeSinceLastFrame = now - lastFrameTime;
|
||||||
"white"
|
|
||||||
);
|
if (timeSinceLastFrame >= minFrameDelay) {
|
||||||
}
|
lastFrameTime = now;
|
||||||
|
}
|
||||||
|
requestAnimationFrame(update);
|
||||||
|
};
|
||||||
|
requestAnimationFrame(update);
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface OscilloscopeConfig {
|
export interface OscilloscopeConfig {
|
||||||
@ -175,7 +178,7 @@ export const runOscilloscope = (
|
|||||||
app.osc.orientation === "horizontal" ? width / numBars : height / numBars;
|
app.osc.orientation === "horizontal" ? width / numBars : height / numBars;
|
||||||
let barHeight;
|
let barHeight;
|
||||||
let x = 0,
|
let x = 0,
|
||||||
y = 0;
|
y = 0;
|
||||||
|
|
||||||
canvasCtx.fillStyle = app.osc.color || `rgb(255, 255, 255)`;
|
canvasCtx.fillStyle = app.osc.color || `rgb(255, 255, 255)`;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { Prec } from "@codemirror/state";
|
|||||||
import { indentWithTab } from "@codemirror/commands";
|
import { indentWithTab } from "@codemirror/commands";
|
||||||
import {
|
import {
|
||||||
keymap,
|
keymap,
|
||||||
ViewUpdate,
|
|
||||||
lineNumbers,
|
lineNumbers,
|
||||||
highlightSpecialChars,
|
highlightSpecialChars,
|
||||||
drawSelection,
|
drawSelection,
|
||||||
@ -100,9 +99,6 @@ export const installEditor = (app: Editor) => {
|
|||||||
editorSetup,
|
editorSetup,
|
||||||
toposTheme,
|
toposTheme,
|
||||||
app.chosenLanguage.of(javascript()),
|
app.chosenLanguage.of(javascript()),
|
||||||
EditorView.updateListener.of((v: ViewUpdate) => {
|
|
||||||
v;
|
|
||||||
}),
|
|
||||||
];
|
];
|
||||||
app.dynamicPlugins = new Compartment();
|
app.dynamicPlugins = new Compartment();
|
||||||
app.state = EditorState.create({
|
app.state = EditorState.create({
|
||||||
|
|||||||
@ -135,10 +135,8 @@ export const registerOnKeyDown = (app: Editor) => {
|
|||||||
if (event.keyCode === keycode) {
|
if (event.keyCode === keycode) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
event.preventDefault();
|
|
||||||
app.api.script(keycode - 111);
|
app.api.script(keycode - 111);
|
||||||
} else {
|
} else {
|
||||||
event.preventDefault();
|
|
||||||
app.changeModeFromInterface("local");
|
app.changeModeFromInterface("local");
|
||||||
app.changeToLocalBuffer(index);
|
app.changeToLocalBuffer(index);
|
||||||
hideDocumentation();
|
hideDocumentation();
|
||||||
|
|||||||
@ -12,9 +12,9 @@ export class TransportNode extends AudioWorkletNode {
|
|||||||
|
|
||||||
/** @type {(this: MessagePort, ev: MessageEvent<any>) => any} */
|
/** @type {(this: MessagePort, ev: MessageEvent<any>) => any} */
|
||||||
handleMessage = (message) => {
|
handleMessage = (message) => {
|
||||||
if(message.data) {
|
if (message.data) {
|
||||||
if (message.data.type === "bang") {
|
if (message.data.type === "bang") {
|
||||||
if(this.app.clock.running) {
|
if (this.app.clock.running) {
|
||||||
if (this.app.settings.send_clock) {
|
if (this.app.settings.send_clock) {
|
||||||
this.app.api.MidiConnection.sendMidiClock();
|
this.app.api.MidiConnection.sendMidiClock();
|
||||||
}
|
}
|
||||||
@ -22,8 +22,10 @@ export class TransportNode extends AudioWorkletNode {
|
|||||||
this.app.clock.tick
|
this.app.clock.tick
|
||||||
);
|
);
|
||||||
this.app.clock.time_position = futureTimeStamp;
|
this.app.clock.time_position = futureTimeStamp;
|
||||||
this.timeviewer.innerHTML = `${zeroPad(futureTimeStamp.bar, 2)}:${futureTimeStamp.beat + 1
|
if (futureTimeStamp.pulse % this.app.clock.ppqn == 0) {
|
||||||
}:${zeroPad(futureTimeStamp.pulse, 2)} / ${this.app.clock.bpm}`;
|
this.timeviewer.innerHTML = `${zeroPad(futureTimeStamp.bar, 2)}:${futureTimeStamp.beat + 1
|
||||||
|
} / ${this.app.clock.bpm}`;
|
||||||
|
}
|
||||||
if (this.app.exampleIsPlaying) {
|
if (this.app.exampleIsPlaying) {
|
||||||
tryEvaluate(this.app, this.app.example_buffer);
|
tryEvaluate(this.app, this.app.example_buffer);
|
||||||
} else {
|
} else {
|
||||||
@ -60,6 +62,6 @@ export class TransportNode extends AudioWorkletNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
this.port.postMessage({type: "stop" });
|
this.port.postMessage({ type: "stop" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { OscilloscopeConfig, runOscilloscope } from "./AudioVisualisation";
|
import { OscilloscopeConfig, runOscilloscope, scriptBlinkers } from "./AudioVisualisation";
|
||||||
import { EditorState, Compartment } from "@codemirror/state";
|
import { EditorState, Compartment } from "@codemirror/state";
|
||||||
import { javascript } from "@codemirror/lang-javascript";
|
import { javascript } from "@codemirror/lang-javascript";
|
||||||
import { markdown } from "@codemirror/lang-markdown";
|
import { markdown } from "@codemirror/lang-markdown";
|
||||||
@ -27,7 +27,6 @@ import showdown from "showdown";
|
|||||||
import { makeStringExtensions } from "./extensions/StringExtensions";
|
import { makeStringExtensions } from "./extensions/StringExtensions";
|
||||||
import { installInterfaceLogic } from "./InterfaceLogic";
|
import { installInterfaceLogic } from "./InterfaceLogic";
|
||||||
import { installWindowBehaviors } from "./WindowBehavior";
|
import { installWindowBehaviors } from "./WindowBehavior";
|
||||||
import { drawEmptyBlinkers } from "./AudioVisualisation";
|
|
||||||
import { makeNumberExtensions } from "./extensions/NumberExtensions";
|
import { makeNumberExtensions } from "./extensions/NumberExtensions";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { registerSW } from "virtual:pwa-register";
|
import { registerSW } from "virtual:pwa-register";
|
||||||
@ -170,7 +169,7 @@ export class Editor {
|
|||||||
registerFillKeys(this);
|
registerFillKeys(this);
|
||||||
registerOnKeyDown(this);
|
registerOnKeyDown(this);
|
||||||
installInterfaceLogic(this);
|
installInterfaceLogic(this);
|
||||||
drawEmptyBlinkers(this);
|
scriptBlinkers();
|
||||||
|
|
||||||
// ================================================================================
|
// ================================================================================
|
||||||
// Building CodeMirror Editor
|
// Building CodeMirror Editor
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const vitePWAconfiguration = {
|
|||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
cleanupOutdatedCaches: true,
|
cleanupOutdatedCaches: true,
|
||||||
globPatterns: [
|
globPatterns: [
|
||||||
"**/*.{js,css,html,gif,png,json,woff,json,ogg,wav,mp3,ico,png,svg}",
|
"**/*.{js,css,html,gif,png,json,woff,woff2,json,ogg,wav,mp3,ico,png,svg}",
|
||||||
],
|
],
|
||||||
// Thanks Froos :)
|
// Thanks Froos :)
|
||||||
runtimeCaching: [
|
runtimeCaching: [
|
||||||
|
|||||||
Reference in New Issue
Block a user