melhorando a leitura de projetos no mmpCreator
Deploy / Deploy (push) Successful in 2m40s
Details
Deploy / Deploy (push) Successful in 2m40s
Details
This commit is contained in:
parent
08302947ad
commit
d619e533aa
|
|
@ -45,12 +45,12 @@ function resolveSamplePath(sampleName, pathMap) {
|
|||
return null;
|
||||
}
|
||||
|
||||
// helper: LMMS ticks -> seconds (1 beat = 192 ticks)
|
||||
function ticksToSeconds(ticks, bpm) {
|
||||
seconds = (ticks / 12) * getSecondsPerStep()
|
||||
function ticksToSeconds(ticks) {
|
||||
const seconds = (ticks / TICKS_PER_STEP) * getSecondsPerStep();
|
||||
return seconds;
|
||||
}
|
||||
|
||||
|
||||
export async function parseBeatIndexJson(data) {
|
||||
resetProjectState();
|
||||
initializeAudioContext();
|
||||
|
|
@ -263,9 +263,9 @@ function parseInstrumentNode(
|
|||
const patternSteps = parseInt(patternNode.getAttribute("steps"), 10) || 16;
|
||||
const steps = new Array(patternSteps).fill(false);
|
||||
const notes = [];
|
||||
|
||||
// Constante de conversão LMMS (192 ticks = 1 beat, 48 ticks = 1 step)
|
||||
const ticksPerStep = 48;
|
||||
// No XML base: 1 compasso (bar) = 192 ticks em 4/4,
|
||||
// então 1 beat = 48 ticks e 1 step (1/16) = 12 ticks.
|
||||
const ticksPerStep = 12;
|
||||
|
||||
patternNode.querySelectorAll("note").forEach((noteNode) => {
|
||||
const pos = parseInt(noteNode.getAttribute("pos"), 10);
|
||||
|
|
@ -277,14 +277,9 @@ function parseInstrumentNode(
|
|||
notes.push({ pos, len, key, vol, pan });
|
||||
|
||||
// Calcula qual step acender
|
||||
// Nota: B/B Editor no LMMS geralmente usa notas de len=48.
|
||||
// Se a nota for longa, isso marca apenas o step de início.
|
||||
const stepIndex = Math.round(pos / ticksPerStep);
|
||||
|
||||
if (stepIndex >= 0 && stepIndex < patternSteps) {
|
||||
steps[stepIndex] = true;
|
||||
}
|
||||
});
|
||||
const stepIndex = Math.floor(pos / ticksPerStep);
|
||||
if (stepIndex < patternSteps) steps[stepIndex] = true;
|
||||
});
|
||||
|
||||
return {
|
||||
name: patternName,
|
||||
|
|
@ -608,7 +603,7 @@ export function syncPatternStateToServer() {
|
|||
function createTrackXml(track) {
|
||||
if (!track.patterns || track.patterns.length === 0) return "";
|
||||
|
||||
const ticksPerStep = 48; // Sincronizado com o parsing
|
||||
const ticksPerStep = 12; // 1 step (1/16) no LMMS = 12 ticks (com bar=192 em 4/4)
|
||||
const lmmsVolume = Math.round(track.volume * 100);
|
||||
const lmmsPan = Math.round(track.pan * 100);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue