FIX: sửa lỗi fluidsynth error khi toggle percussion kit
This commit is contained in:
+26
-9
@@ -14708,15 +14708,32 @@ const App = () => {
|
||||
setTimeout(() => lucide.createIcons(), 50);
|
||||
};
|
||||
const toggleTrackDrum = trackId => {
|
||||
setTracks(prev => prev.map(t => t.id === trackId ? {
|
||||
...t,
|
||||
is_percussion: !t.is_percussion,
|
||||
soundfont_bank: !t.is_percussion ? 128 : (t._saved_sf_bank !== undefined ? t._saved_sf_bank : 0),
|
||||
synth_engine: t.synth_engine ? {
|
||||
...t.synth_engine,
|
||||
soundfont_bank: !t.is_percussion ? 128 : 0
|
||||
} : t.synth_engine
|
||||
} : t));
|
||||
var mt = tracks || [];
|
||||
var tidx = mt.findIndex(function(tr) { return tr.id === trackId; });
|
||||
if (tidx < 0) tidx = 0;
|
||||
setTracks(prev => prev.map(t => {
|
||||
if (t.id !== trackId) return t;
|
||||
const becomingPercussion = !t.is_percussion;
|
||||
let newBank = becomingPercussion ? 128 : (t._saved_sf_bank !== undefined ? t._saved_sf_bank : 0);
|
||||
let newProgram = becomingPercussion ? 0 : (t._saved_sf_program !== undefined ? t._saved_sf_program : 0);
|
||||
let newCh = becomingPercussion ? 9 : (t._saved_sf_channel !== undefined ? t._saved_sf_channel : (tidx % 16));
|
||||
|
||||
return {
|
||||
...t,
|
||||
is_percussion: becomingPercussion,
|
||||
soundfont_bank: newBank,
|
||||
instrumentProgram: newProgram,
|
||||
midiChannel: newCh,
|
||||
_saved_sf_bank: becomingPercussion ? t.soundfont_bank : t._saved_sf_bank,
|
||||
_saved_sf_program: becomingPercussion ? t.instrumentProgram : t._saved_sf_program,
|
||||
_saved_sf_channel: becomingPercussion ? t.midiChannel : t._saved_sf_channel,
|
||||
synth_engine: t.synth_engine ? {
|
||||
...t.synth_engine,
|
||||
soundfont_bank: newBank,
|
||||
soundfont_program: newProgram
|
||||
} : t.synth_engine
|
||||
};
|
||||
}));
|
||||
setTimeout(() => lucide.createIcons(), 50);
|
||||
};
|
||||
const updateTrackVolumeDb = (trackId, val) => {
|
||||
|
||||
Reference in New Issue
Block a user