diff --git a/src/App.jsx b/src/App.jsx index bd614e1..fc514d1 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -32,6 +32,7 @@ const API = { getPreset: (bank, program) => api("GET", `/api/presets/${bank}/${program}`), activatePreset:(bank, program) => api("POST", `/api/presets/${bank}/${program}/activate`), savePreset: (bank, program, name, tags) => api("PUT", "/api/presets", { bank, program, name, tags }), + setAudioProfile:(rate, period) => api("POST", "/api/audio/profile", { rate: parseInt(rate), period: parseInt(period) }), searchModels: (q) => api("GET", `/api/tonehub/search?q=${encodeURIComponent(q)}`), searchIrs: (q) => api("GET", `/api/tonehub/search/irs?q=${encodeURIComponent(q)}`), installModel: (url, name) => api("POST", "/api/models/tonedownload/install", { download_url: url, name }), @@ -587,7 +588,7 @@ export default function App(){ API.listPresets().then(data=>{ if(data?.banks){ const all=[]; - data.banks.forEach(b=>{(b.presets||[]).forEach((p,i)=>{if(p)all.push({num:i+1,bank:b.number,name:p.name,chain:p.chain});});}); + data.banks.forEach(b=>{(b.presets||[]).forEach((p,i)=>{if(p)all.push({num:i+1,bank:b.number+1,name:p.name,chain:p.chain});});}); if(all.length>0)setPresets(all); } }).catch(()=>{}); @@ -1010,6 +1011,7 @@ export default function App(){ setSettingsView(null)} onMasterVolume={(v)=>API.masterVolume(v).catch(()=>{})} + onAudioProfile={(rate, period)=>API.setAudioProfile(rate, period).catch(()=>{})} /> )} diff --git a/src/GlobalSettings.jsx b/src/GlobalSettings.jsx index ff3c84c..a1fb152 100644 --- a/src/GlobalSettings.jsx +++ b/src/GlobalSettings.jsx @@ -10,6 +10,22 @@ const T = { const SETTINGS = { "Audio": [ { key: "master_volume", label: "Master Volume", type: "slider", min: 0, max: 100, def: 72, unit: "%", icon: "🔊" }, + { key: "sample_rate", label: "Sample Rate", type: "select", def: "48000", + options: [ + { value: "22050", label: "22.05 kHz" }, + { value: "44100", label: "44.1 kHz" }, + { value: "48000", label: "48 kHz" }, + { value: "88200", label: "88.2 kHz" }, + { value: "96000", label: "96 kHz" }, + ], icon: "📊" }, + { key: "buffer_size", label: "Buffer Size", type: "select", def: "512", + options: [ + { value: "64", label: "64 (1.3ms)" }, + { value: "128", label: "128 (2.7ms)" }, + { value: "256", label: "256 (5.3ms)" }, + { value: "512", label: "512 (10.6ms)" }, + { value: "1024",label: "1024 (21.3ms)" }, + ], icon: "📦" }, { key: "input_pad", label: "Input Pad", type: "select", def: "off", options: [ { value: "off", label: "Off (0 dB)" }, @@ -275,7 +291,7 @@ function BpmWidget({ label, value, onChange }) { } // ── Global Settings ── -export default function GlobalSettings({ onClose, onMasterVolume }) { +export default function GlobalSettings({ onClose, onMasterVolume, onAudioProfile }) { const [values, setValues] = useState(() => { const init = {}; for (const group of Object.values(SETTINGS)) { @@ -294,7 +310,17 @@ export default function GlobalSettings({ onClose, onMasterVolume }) { if (key === "master_volume") { onMasterVolume?.(val); } - }, [onMasterVolume]); + // Fire external callback for audio profile changes + if (key === "sample_rate" || key === "buffer_size") { + // Get the latest values — use the new val for the changed key + setValues(prev => { + const rate = key === "sample_rate" ? val : (prev.sample_rate || "48000"); + const period = key === "buffer_size" ? val : (prev.buffer_size || "512"); + onAudioProfile?.(parseInt(rate), parseInt(period)); + return prev; + }); + } + }, [onMasterVolume, onAudioProfile]); return (