fix: honor the soundfont -> baseUrl config

This commit is contained in:
Xiaohan-Tian
2026-04-17 16:18:33 -07:00
parent cb4bf59de1
commit 206fa6fdf9
+10 -4
View File
@@ -1,5 +1,6 @@
import { SAMPLER_CONSTANTS } from '../../constants/coreConstants'; import { SAMPLER_CONSTANTS } from '../../constants/coreConstants';
import { FLUIDR3_INSTRUMENT_MAP } from '../../constants/generalMidiConstants'; import { FLUIDR3_INSTRUMENT_MAP } from '../../constants/generalMidiConstants';
import { ConfigManager } from '../config/ConfigManager';
import * as Tone from 'tone'; import * as Tone from 'tone';
/** /**
@@ -115,18 +116,23 @@ export class KGToneBuffersPool {
* Create ToneAudioBuffers for an instrument * Create ToneAudioBuffers for an instrument
*/ */
private async createToneAudioBuffers(name: string): Promise<Tone.ToneAudioBuffers> { private async createToneAudioBuffers(name: string): Promise<Tone.ToneAudioBuffers> {
const configManager = ConfigManager.instance();
if (!configManager.getIsInitialized()) {
await configManager.initialize();
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
// Get instrument configuration from constants
const fluidConfig = SAMPLER_CONSTANTS.TONE_SAMPLERS.FLUID;
const instrumentName = name; const instrumentName = name;
if (!instrumentName) { if (!instrumentName) {
throw new Error(`Unknown instrument: ${name}`); throw new Error(`Unknown instrument: ${name}`);
} }
// Generate URL mapping for all keys from A0 to Bb7 const baseUrl = (ConfigManager.instance().get('general.soundfont.base_url') as string)
const urls = this.generateKeyUrls(fluidConfig.url, instrumentName); || SAMPLER_CONSTANTS.TONE_SAMPLERS.FLUID.url;
const urls = this.generateKeyUrls(baseUrl, instrumentName);
console.log(`Loading ToneAudioBuffers for ${name} (${instrumentName})...`); console.log(`Loading ToneAudioBuffers for ${name} (${instrumentName})...`);