feat: merge mode_list.json into functional_chords.json

This commit is contained in:
Xiaohan-Tian
2025-12-17 22:10:37 -08:00
parent 1650bd05b7
commit 610b81e4cc
7 changed files with 41 additions and 85 deletions
+1 -9
View File
@@ -16,15 +16,7 @@ import functionalChordsData from '../../public/resources/modes/functional_chords
describe('scaleUtil', () => {
// Setup: Mock KGCore with real chord data
beforeEach(() => {
// Mock MODE_DATA with ionian for basic tests
KGCore.MODE_DATA = [
{ id: 'ionian', name: 'Ionian', steps: [2, 2, 1, 2, 2, 2, 1] },
{ id: 'dorian', name: 'Dorian', steps: [2, 1, 2, 2, 2, 1, 2] },
{ id: 'aeolian', name: 'Aeolian', steps: [2, 1, 2, 2, 1, 2, 2] },
{ id: 'mixolydian', name: 'Mixolydian', steps: [2, 2, 1, 2, 2, 1, 2] }
]
// Use real functional chords data from JSON file
// Use real functional chords data from JSON file (includes name, steps, and chord data)
KGCore.FUNCTIONAL_CHORDS_DATA = functionalChordsData
})
+3 -3
View File
@@ -66,12 +66,12 @@ export const getScalePitchClasses = (rootNote: string, modeSteps: number[]): num
* @returns Array of interval steps, or default ionian if not found
*/
export const getModeSteps = (modeId: string): number[] => {
const modeData = KGCore.MODE_DATA.find(m => m.id === modeId);
if (!modeData) {
const functionalChords = KGCore.FUNCTIONAL_CHORDS_DATA[modeId];
if (!functionalChords || !functionalChords.steps) {
console.warn(`Mode not found: ${modeId}, defaulting to ionian`);
return [2, 2, 1, 2, 2, 2, 1]; // Default to ionian (major scale)
}
return modeData.steps;
return functionalChords.steps;
};
/**