tentando resolver conflitos do tone no mmpCreator

This commit is contained in:
JotaChina committed 2025-12-26 20:30:06 -03:00
1 parent 1abfc35ba1
commit 371f66b320
1 file changed
+17 -2
+17 -2
View File
@@ -12,6 +12,9 @@ import { SuperSaw } from "../../audio/plugins/SuperSaw.js";
import { Lb302 } from "../../audio/plugins/Lb302.js";
import { Kicker } from "../../audio/plugins/Kicker.js";
const TICKS_PER_STEP = 12; // LMMS: 12 ticks por 1/16
const STEPS_PER_BAR = 16; // 4/4 em 1/16
// Mapa para facilitar a criação dinâmica
const PLUGIN_CLASSES = {
tripleoscillator: TripleOscillator,
@@ -310,9 +313,21 @@ function schedulePianoRoll() {
}
}, events).start(0);
const bars = parseInt(document.getElementById("bars-input")?.value || 1);
// calcula até onde vai a última nota do pianoroll
let maxEndTick = 0;
for (const n of pattern.notes) {
const pos = Number(n.pos) || 0;
const rawLen = Number(n.len) || 0;
const len = rawLen < 0 ? TICKS_PER_STEP : rawLen;
maxEndTick = Math.max(maxEndTick, pos + Math.max(len, TICKS_PER_STEP));
}
const totalStepsNeeded = Math.max(1, Math.ceil(maxEndTick / TICKS_PER_STEP));
const barsNeeded = Math.max(1, Math.ceil(totalStepsNeeded / STEPS_PER_BAR));
part.loop = true;
part.loopEnd = bars + "m";
part.loopEnd = `${barsNeeded}m`;
activeParts.push(part);
}