editando patterns na playlist

This commit is contained in:
JotaChina committed 2025-12-27 12:12:22 -03:00
1 parent ec772ad8aa
commit ef499e3df9
6 files changed
+234 -5

No files matched your search

+30
View File
@@ -706,6 +706,8 @@ function generateXmlFromState() {
});
}
applyPlaylistClipsToXml(xmlDoc);
const serializer = new XMLSerializer();
return serializer.serializeToString(xmlDoc);
}
@@ -717,6 +719,34 @@ export function syncPatternStateToServer() {
saveStateToSession();
}
function applyPlaylistClipsToXml(xmlDoc) {
const bbTrackNodes = Array.from(xmlDoc.querySelectorAll('track[type="1"]'));
if (!bbTrackNodes.length) return;
const basslines = appState.pattern.tracks
.filter((t) => t.type === "bassline" && Number.isFinite(Number(t.patternIndex)))
.slice()
.sort((a, b) => Number(a.patternIndex) - Number(b.patternIndex));
for (const b of basslines) {
const idx = Number(b.patternIndex);
const node = bbTrackNodes[idx];
if (!node) continue;
// remove bbtco existentes
Array.from(node.querySelectorAll(":scope > bbtco")).forEach((n) => n.remove());
const clips = (b.playlist_clips || []).slice().sort((x, y) => (x.pos ?? 0) - (y.pos ?? 0));
for (const c of clips) {
const el = xmlDoc.createElement("bbtco");
el.setAttribute("pos", String(Math.max(0, Math.floor(c.pos ?? 0))));
el.setAttribute("len", String(Math.max(12, Math.floor(c.len ?? 192))));
node.appendChild(el);
}
}
}
function createTrackXml(track) {
if (!track.patterns || track.patterns.length === 0) return "";