refactor: chord guide system
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
export interface ChordGuideItem {
|
||||
name: string;
|
||||
roman: string;
|
||||
notes: string[];
|
||||
source: string;
|
||||
note: string;
|
||||
}
|
||||
|
||||
export interface ChordGuideModeDefinition {
|
||||
T: ChordGuideItem[];
|
||||
S: ChordGuideItem[];
|
||||
D: ChordGuideItem[];
|
||||
}
|
||||
|
||||
export interface ChordGuideData {
|
||||
ionian: ChordGuideModeDefinition;
|
||||
aeolian: ChordGuideModeDefinition;
|
||||
}
|
||||
|
||||
export interface ResolvedChordGuideItem extends ChordGuideItem {
|
||||
resolvedNotes: string[];
|
||||
pitchClasses: number[];
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import { KGRegion } from './region/KGRegion';
|
||||
import { generateUniqueId } from '../util/miscUtil';
|
||||
import { KGCommand, KGCommandHistory } from './commands';
|
||||
import { getEffectiveBpmAtBeat } from '../util/globalTrackUtil';
|
||||
import type { ChordGuideData } from './ChordGuideTypes';
|
||||
|
||||
interface PlaybackStartOptions {
|
||||
preserveLoopPreroll?: boolean;
|
||||
@@ -28,6 +29,10 @@ export class KGCore {
|
||||
// Global music data resources
|
||||
public static ORIGINAL_FUNCTIONAL_CHORDS_DATA: Record<string, { name: string; steps: number[]; T: string[]; S: string[]; D: string[]; chords: Record<string, string[]> }> = {}; // Original functional chords loaded from functional_chords.json
|
||||
public static FUNCTIONAL_CHORDS_DATA: Record<string, { name: string; steps: number[]; T: string[]; S: string[]; D: string[]; chords: Record<string, string[]> }> = {}; // Active functional chords (either original or custom from user settings)
|
||||
public static CHORD_GUIDE_DATA: ChordGuideData = {
|
||||
ionian: { T: [], S: [], D: [] },
|
||||
aeolian: { T: [], S: [], D: [] },
|
||||
};
|
||||
|
||||
private currentProject: KGProject = new KGProject();
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { ResolvedChordGuideItem } from '../ChordGuideTypes';
|
||||
|
||||
/**
|
||||
* KGPianoRollState - State management for the piano roll
|
||||
* Implements the singleton pattern for global access
|
||||
@@ -21,8 +23,8 @@ export class KGPianoRollState {
|
||||
private sheetQuantization: string = '16,48';
|
||||
|
||||
// Chord guide state
|
||||
private currentSuitableChords: Record<string, string[]> = {}; // Map of chord symbols to note names (e.g., {"I": ["C", "E", "G"]})
|
||||
private currentSuitableChordsPitchClasses: Record<string, number[]> = {}; // Map of chord symbols to pitch classes (e.g., {"I": [0, 4, 7]})
|
||||
private currentSuitableChords: ResolvedChordGuideItem[] = [];
|
||||
private currentSuitableChordsPitchClasses: Record<string, number[]> = {};
|
||||
private currentMatchingChords: number[][] = [];
|
||||
private currentSelectedChordIndex: number = 0;
|
||||
private currentChordCursorPitch: number | null = null;
|
||||
@@ -119,11 +121,11 @@ export class KGPianoRollState {
|
||||
this.sheetQuantization = value;
|
||||
}
|
||||
|
||||
public getCurrentSuitableChords(): Record<string, string[]> {
|
||||
public getCurrentSuitableChords(): ResolvedChordGuideItem[] {
|
||||
return this.currentSuitableChords;
|
||||
}
|
||||
|
||||
public setCurrentSuitableChords(chords: Record<string, string[]>): void {
|
||||
public setCurrentSuitableChords(chords: ResolvedChordGuideItem[]): void {
|
||||
this.currentSuitableChords = chords;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user