Update sound source collection logic in utils.ts

This commit is contained in:
2026-07-14 09:30:32 +02:00
parent c4b0b81932
commit 892c05e5ea

View File

@@ -241,13 +241,21 @@ function getSoundsInfoFromProject(
if (keepUnusedPatterns) { if (keepUnusedPatterns) {
for (const pattern of data.groupPatterns) { for (const pattern of data.groupPatterns) {
for (const [source, notes] of Object.entries(pattern.notes)) { const sources = new Set(
if (notes.length === 0) { Object.entries(pattern.notes)
continue; .filter(([, notes]) => notes.length > 0)
.map(([source]) => Number(source)),
);
for (const event of pattern.events) {
if (event.type === 'midi' && event.source >= 0 && event.source < 12) {
sources.add(event.source);
}
} }
for (const source of sources) {
const pad = data.pads[pattern.group]?.find( const pad = data.pads[pattern.group]?.find(
(candidate) => candidate.pad === Number(source) + 1, (candidate) => candidate.pad === source + 1,
); );
if (pad?.soundId) { if (pad?.soundId) {
usedSoundIds.add(pad.soundId); usedSoundIds.add(pad.soundId);