Add send midi clock checkbox to localstorage
This commit is contained in:
@ -44,6 +44,7 @@ export interface Settings {
|
|||||||
* @param line_numbers - Whether or not to show line numbers
|
* @param line_numbers - Whether or not to show line numbers
|
||||||
* @param time_position - Whether or not to show time position
|
* @param time_position - Whether or not to show time position
|
||||||
* @param tips - Whether or not to show tips
|
* @param tips - Whether or not to show tips
|
||||||
|
* @param send_clock - Whether or not to send midi clock
|
||||||
*/
|
*/
|
||||||
vimMode: boolean;
|
vimMode: boolean;
|
||||||
theme: string;
|
theme: string;
|
||||||
@ -54,6 +55,7 @@ export interface Settings {
|
|||||||
line_numbers: boolean;
|
line_numbers: boolean;
|
||||||
time_position: boolean;
|
time_position: boolean;
|
||||||
tips: boolean;
|
tips: boolean;
|
||||||
|
send_clock: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const template_universe = {
|
export const template_universe = {
|
||||||
@ -110,6 +112,7 @@ export class AppSettings {
|
|||||||
* @param line_numbers - Whether or not to show line numbers
|
* @param line_numbers - Whether or not to show line numbers
|
||||||
* @param time_position - Whether or not to show time position
|
* @param time_position - Whether or not to show time position
|
||||||
* @param tips - Whether or not to show tips
|
* @param tips - Whether or not to show tips
|
||||||
|
* @param send_clock - Whether or not to send midi clock
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -122,6 +125,7 @@ export class AppSettings {
|
|||||||
public line_numbers: boolean = true;
|
public line_numbers: boolean = true;
|
||||||
public time_position: boolean = true;
|
public time_position: boolean = true;
|
||||||
public tips: boolean = true;
|
public tips: boolean = true;
|
||||||
|
public send_clock: boolean = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const settingsFromStorage = JSON.parse(
|
const settingsFromStorage = JSON.parse(
|
||||||
@ -139,6 +143,7 @@ export class AppSettings {
|
|||||||
this.line_numbers = settingsFromStorage.line_numbers;
|
this.line_numbers = settingsFromStorage.line_numbers;
|
||||||
this.time_position = settingsFromStorage.time_position;
|
this.time_position = settingsFromStorage.time_position;
|
||||||
this.tips = settingsFromStorage.tips;
|
this.tips = settingsFromStorage.tips;
|
||||||
|
this.send_clock = settingsFromStorage.send_clock;
|
||||||
} else {
|
} else {
|
||||||
this.universes = template_universes;
|
this.universes = template_universes;
|
||||||
}
|
}
|
||||||
@ -162,6 +167,7 @@ export class AppSettings {
|
|||||||
line_numbers: this.line_numbers,
|
line_numbers: this.line_numbers,
|
||||||
time_position: this.time_position,
|
time_position: this.time_position,
|
||||||
tips: this.tips,
|
tips: this.tips,
|
||||||
|
send_clock: this.send_clock,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +189,7 @@ export class AppSettings {
|
|||||||
this.line_numbers = settings.line_numbers;
|
this.line_numbers = settings.line_numbers;
|
||||||
this.time_position = settings.time_position;
|
this.time_position = settings.time_position;
|
||||||
this.tips = settings.tips;
|
this.tips = settings.tips;
|
||||||
|
this.send_clock = settings.send_clock;
|
||||||
localStorage.setItem("topos", JSON.stringify(this.data));
|
localStorage.setItem("topos", JSON.stringify(this.data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { UserAPI } from "../API";
|
import { UserAPI } from "../API";
|
||||||
import { Clock } from "../Clock";
|
|
||||||
|
|
||||||
export class MidiConnection {
|
export class MidiConnection {
|
||||||
/**
|
/**
|
||||||
@ -223,7 +222,6 @@ export class MidiConnection {
|
|||||||
* Called when a MIDI clock message is received.
|
* Called when a MIDI clock message is received.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const SMOOTH = 0.1;
|
|
||||||
this.clockTicks += 1;
|
this.clockTicks += 1;
|
||||||
|
|
||||||
if(this.lastTimestamp > 0) {
|
if(this.lastTimestamp > 0) {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ 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 && message.data.type === "bang") {
|
if (message.data && message.data.type === "bang") {
|
||||||
this.app.api.MidiConnection.sendMidiClock();
|
if(this.app.settings.send_clock) this.app.api.MidiConnection.sendMidiClock();
|
||||||
this.app.clock.tick++;
|
this.app.clock.tick++;
|
||||||
const futureTimeStamp = this.app.clock.convertTicksToTimeposition(
|
const futureTimeStamp = this.app.clock.convertTicksToTimeposition(
|
||||||
this.app.clock.tick
|
this.app.clock.tick
|
||||||
|
|||||||
13
src/main.ts
13
src/main.ts
@ -80,7 +80,7 @@ export class Editor {
|
|||||||
exampleCounter: number = 0;
|
exampleCounter: number = 0;
|
||||||
exampleIsPlaying: boolean = false;
|
exampleIsPlaying: boolean = false;
|
||||||
|
|
||||||
settings = new AppSettings();
|
settings: AppSettings = new AppSettings();
|
||||||
editorExtensions: Extension[] = [];
|
editorExtensions: Extension[] = [];
|
||||||
userPlugins: Extension[] = [];
|
userPlugins: Extension[] = [];
|
||||||
state: EditorState;
|
state: EditorState;
|
||||||
@ -193,6 +193,10 @@ export class Editor {
|
|||||||
"show-tips"
|
"show-tips"
|
||||||
) as HTMLInputElement;
|
) as HTMLInputElement;
|
||||||
|
|
||||||
|
midi_clock_checkbox: HTMLInputElement = document.getElementById(
|
||||||
|
"send-midi-clock"
|
||||||
|
) as HTMLInputElement;
|
||||||
|
|
||||||
// Editor mode selection
|
// Editor mode selection
|
||||||
normal_mode_button: HTMLButtonElement = document.getElementById(
|
normal_mode_button: HTMLButtonElement = document.getElementById(
|
||||||
"normal-mode"
|
"normal-mode"
|
||||||
@ -241,6 +245,7 @@ export class Editor {
|
|||||||
this.line_numbers_checkbox.checked = this.settings.line_numbers;
|
this.line_numbers_checkbox.checked = this.settings.line_numbers;
|
||||||
this.time_position_checkbox.checked = this.settings.time_position;
|
this.time_position_checkbox.checked = this.settings.time_position;
|
||||||
this.tips_checkbox.checked = this.settings.tips;
|
this.tips_checkbox.checked = this.settings.tips;
|
||||||
|
this.midi_clock_checkbox.checked = this.settings.send_clock;
|
||||||
if (!this.settings.time_position) {
|
if (!this.settings.time_position) {
|
||||||
document.getElementById("timeviewer")!.classList.add("hidden");
|
document.getElementById("timeviewer")!.classList.add("hidden");
|
||||||
}
|
}
|
||||||
@ -559,6 +564,7 @@ export class Editor {
|
|||||||
this.line_numbers_checkbox.checked = this.settings.line_numbers;
|
this.line_numbers_checkbox.checked = this.settings.line_numbers;
|
||||||
this.time_position_checkbox.checked = this.settings.time_position;
|
this.time_position_checkbox.checked = this.settings.time_position;
|
||||||
this.tips_checkbox.checked = this.settings.tips;
|
this.tips_checkbox.checked = this.settings.tips;
|
||||||
|
this.midi_clock_checkbox.checked = this.settings.send_clock;
|
||||||
|
|
||||||
if (this.settings.vimMode) {
|
if (this.settings.vimMode) {
|
||||||
let vim = document.getElementById("vim-mode-radio") as HTMLInputElement;
|
let vim = document.getElementById("vim-mode-radio") as HTMLInputElement;
|
||||||
@ -654,6 +660,11 @@ export class Editor {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.midi_clock_checkbox.addEventListener("change", () => {
|
||||||
|
let checked = this.midi_clock_checkbox.checked ? true : false;
|
||||||
|
this.settings.send_clock = checked;
|
||||||
|
});
|
||||||
|
|
||||||
this.vim_mode_button.addEventListener("click", () => {
|
this.vim_mode_button.addEventListener("click", () => {
|
||||||
this.settings.vimMode = true;
|
this.settings.vimMode = true;
|
||||||
this.view.dispatch({
|
this.view.dispatch({
|
||||||
|
|||||||
Reference in New Issue
Block a user