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