melhorando a leitura de projetos no mmpCreator
Deploy / Deploy (push) Successful in 2m5s
Details
Deploy / Deploy (push) Successful in 2m5s
Details
This commit is contained in:
parent
6beebe7ea2
commit
f7781827b8
|
|
@ -643,34 +643,32 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- CORREÇÃO: Usar o índice global ativo para manter a sincronia ---
|
||||||
|
// Se não houver índice definido no estado, usa 0 (primeiro pattern)
|
||||||
|
const currentPatternIndex = appState.pattern.activePatternIndex || 0;
|
||||||
|
|
||||||
instruments.forEach((inst) => {
|
instruments.forEach((inst) => {
|
||||||
// --- A. Nome do Instrumento ---
|
// --- A. Nome do Instrumento ---
|
||||||
const nameRow = document.createElement("div");
|
const nameRow = document.createElement("div");
|
||||||
nameRow.className = "instrument-row";
|
nameRow.className = "instrument-row";
|
||||||
|
|
||||||
const label = document.createElement("span");
|
// Exibe o nome do pattern também para debug (opcional)
|
||||||
label.innerText =
|
const displayLabel =
|
||||||
inst.instrument_name || inst.plugin_name || "Sem Nome";
|
inst.instrument_name || inst.plugin_name || "Sem Nome";
|
||||||
|
|
||||||
|
const label = document.createElement("span");
|
||||||
|
label.innerText = displayLabel;
|
||||||
nameRow.appendChild(label);
|
nameRow.appendChild(label);
|
||||||
nameContainer.appendChild(nameRow);
|
nameContainer.appendChild(nameRow);
|
||||||
|
|
||||||
// --- B. Steps (Correção Aqui) ---
|
// --- B. Steps (Lógica Corrigida) ---
|
||||||
let stepData = [];
|
let stepData = [];
|
||||||
|
|
||||||
if (inst.patterns && inst.patterns.length > 0) {
|
// Verifica se o instrumento tem patterns e se o índice atual existe
|
||||||
// Tenta encontrar um pattern que tenha pelo menos uma nota 'true'
|
if (inst.patterns && inst.patterns[currentPatternIndex]) {
|
||||||
const activePattern = inst.patterns.find((p) =>
|
stepData = inst.patterns[currentPatternIndex].steps;
|
||||||
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 {
|
} else {
|
||||||
|
// Se não existir pattern para este índice neste instrumento, cria vazio
|
||||||
stepData = Array(16).fill(false);
|
stepData = Array(16).fill(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -687,11 +685,12 @@
|
||||||
if (newState) stepBtn.classList.add("active");
|
if (newState) stepBtn.classList.add("active");
|
||||||
else stepBtn.classList.remove("active");
|
else stepBtn.classList.remove("active");
|
||||||
|
|
||||||
// Atualiza na memória (atenção: idealmente atualize todos os patterns desse inst)
|
// Atualiza o estado na memória no índice CORRETO
|
||||||
if (inst.patterns && inst.patterns.length > 0) {
|
if (inst.patterns && inst.patterns[currentPatternIndex]) {
|
||||||
inst.patterns.forEach((p) => {
|
inst.patterns[currentPatternIndex].steps[index] = newState;
|
||||||
if (p.steps[index] !== undefined) p.steps[index] = newState;
|
} else if (inst.patterns) {
|
||||||
});
|
// Caso extremo: o pattern ainda não existe, teríamos que criar (não implementado aqui para brevidade)
|
||||||
|
console.warn("Pattern index não existe para este instrumento");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -701,7 +700,6 @@
|
||||||
stepsContainer.appendChild(stepsRow);
|
stepsContainer.appendChild(stepsRow);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- FUNÇÃO GLOBAL PARA ABRIR O PIANO ROLL (JÁ EXISTENTE) ---
|
// --- FUNÇÃO GLOBAL PARA ABRIR O PIANO ROLL (JÁ EXISTENTE) ---
|
||||||
window.openPianoRoll = function (trackId) {
|
window.openPianoRoll = function (trackId) {
|
||||||
const track = appState.pattern.tracks.find((t) => t.id === trackId);
|
const track = appState.pattern.tracks.find((t) => t.id === trackId);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue