feat: added an option to control playhead animation fps

This commit is contained in:
Xiaohan-Tian
2025-12-21 22:42:01 -08:00
parent eaee036fc2
commit b44e6fb1ee
4 changed files with 48 additions and 4 deletions
+7 -3
View File
@@ -1,6 +1,5 @@
import type { Selectable } from '../components/interfaces';
import { KGProject } from './KGProject';
import { PLAYING_CONSTANTS } from '../constants/uiConstants';
import { KGAudioInterface } from './audio-interface/KGAudioInterface';
import { ConfigManager } from './config/ConfigManager';
import { KGMidiRegion } from './region/KGMidiRegion';
@@ -298,10 +297,15 @@ export class KGCore {
if (this.playbackIntervalId !== null) {
this.stopPlaybackUpdates(); // Clear any existing timer
}
// Get playhead update frequency from config (in fps)
const configManager = ConfigManager.instance();
const updateFrequency = (configManager.get('editor.playhead_update_frequency') as number) ?? 10;
const updateIntervalMs = 1000 / updateFrequency; // Convert fps to milliseconds
this.playbackIntervalId = window.setInterval(() => {
this.onPlaybackUpdate();
}, PLAYING_CONSTANTS.UPDATE_INTERVAL_MS);
}, updateIntervalMs);
}
private stopPlaybackUpdates(): void {
+6
View File
@@ -64,6 +64,9 @@ interface AppConfig {
qua_len_1_16: string;
};
};
editor: {
playhead_update_frequency: number;
};
chatbox: {
default_open: boolean;
};
@@ -225,6 +228,9 @@ export class ConfigManager {
qua_len_1_16: '0'
},
},
editor: {
playhead_update_frequency: 10
},
chatbox: {
default_open: true
},