tentando resolver conflitos do tone no mmpCreator
Deploy / Deploy (push) Successful in 2m1s
Details
Deploy / Deploy (push) Successful in 2m1s
Details
This commit is contained in:
parent
b7d3bc529a
commit
f847d92aa6
|
|
@ -313,23 +313,33 @@ function schedulePianoRoll() {
|
|||
}
|
||||
}, events).start(0);
|
||||
|
||||
// calcula até onde vai a última nota do pianoroll
|
||||
// Loop deve cobrir toda a extensão do pianoroll (última nota)
|
||||
const barsInput =
|
||||
parseInt(document.getElementById("bars-input")?.value || 1, 10) || 1;
|
||||
|
||||
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));
|
||||
|
||||
// len negativo acontece em alguns casos (one-shot/edge do LMMS)
|
||||
const lenTicks = rawLen < 0 ? TICKS_PER_STEP : rawLen;
|
||||
|
||||
// garante no mínimo 1 step
|
||||
const endTick = pos + Math.max(lenTicks, TICKS_PER_STEP);
|
||||
if (endTick > maxEndTick) maxEndTick = endTick;
|
||||
}
|
||||
|
||||
const totalStepsNeeded = Math.max(1, Math.ceil(maxEndTick / TICKS_PER_STEP));
|
||||
const barsNeeded = Math.max(1, Math.ceil(totalStepsNeeded / STEPS_PER_BAR));
|
||||
const stepsNeeded = Math.max(1, Math.ceil(maxEndTick / TICKS_PER_STEP));
|
||||
const barsNeeded = Math.max(1, Math.ceil(stepsNeeded / STEPS_PER_BAR));
|
||||
|
||||
// respeita o bars-input se o usuário colocar maior, mas nunca menor que o necessário
|
||||
const loopBars = Math.max(barsInput, barsNeeded);
|
||||
|
||||
part.loop = true;
|
||||
part.loopEnd = `${barsNeeded}m`;
|
||||
part.loopEnd = `${loopBars}m`;
|
||||
|
||||
|
||||
activeParts.push(part);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue