tentando obter playlist real do projeto mmp

This commit is contained in:
JotaChina committed 2025-12-20 11:44:54 -03:00
1 parent b6023847c2
commit f86bc02ba9
108 files changed
+942 -126

No files matched your search

+21 -22
View File
@@ -622,21 +622,14 @@
window.openPatternEditor = function(basslineTrack) {
console.log("Abrindo editor para:", basslineTrack.track_name);
// 1. Identificar containers
// No seu HTML, 'sequencer-grid' está em cima e 'track-container' embaixo (na toolbar e body do editor)
const nameContainer = document.getElementById("track-container");
const stepsContainer = document.getElementById("sequencer-grid");
if(!nameContainer || !stepsContainer) {
console.error("Containers do editor não encontrados!");
return;
}
if(!nameContainer || !stepsContainer) return;
// 2. Limpar
nameContainer.innerHTML = "";
stepsContainer.innerHTML = "";
// 3. Iterar sobre os instrumentos internos
const instruments = basslineTrack.instruments || [];
if (instruments.length === 0) {
@@ -645,24 +638,31 @@
}
instruments.forEach(inst => {
// --- A. Nome do Instrumento (Coluna Esquerda) ---
// --- A. Nome do Instrumento ---
const nameRow = document.createElement("div");
nameRow.className = "instrument-row";
// Texto do nome
const label = document.createElement("span");
label.innerText = inst.instrument_name || inst.plugin_name || "Sem Nome";
nameRow.appendChild(label);
nameContainer.appendChild(nameRow);
// --- B. Steps (Coluna Direita - Grid) ---
// Recupera steps (True/False array)
// --- B. Steps (Correção Aqui) ---
let stepData = [];
if (inst.patterns && inst.patterns.length > 0) {
stepData = inst.patterns[0].steps;
// Tenta encontrar um pattern que tenha pelo menos uma nota 'true'
const activePattern = inst.patterns.find(p => p.steps.some(s => s === true));
if (activePattern) {
// Se achou um com notas, usa ele
stepData = activePattern.steps;
} else {
// Se todos estão vazios, usa o primeiro mesmo
stepData = inst.patterns[0].steps;
}
} else {
stepData = Array(16).fill(false); // Default
stepData = Array(16).fill(false);
}
const stepsRow = document.createElement("div");
@@ -673,18 +673,17 @@
stepBtn.className = "step-btn";
if (isActive) stepBtn.classList.add("active");
// Interação de Clique (Toggle)
stepBtn.addEventListener("click", () => {
// Inverte estado
const newState = !stepBtn.classList.contains("active");
if(newState) stepBtn.classList.add("active");
else stepBtn.classList.remove("active");
// Atualiza dado em memória
if(!inst.patterns) inst.patterns = [{steps: []}];
if(!inst.patterns[0]) inst.patterns[0] = {steps: []};
inst.patterns[0].steps[index] = newState;
// Atualiza na memória (atenção: idealmente atualize todos os patterns desse inst)
if(inst.patterns && inst.patterns.length > 0) {
inst.patterns.forEach(p => {
if(p.steps[index] !== undefined) p.steps[index] = newState;
});
}
});
stepsRow.appendChild(stepBtn);