editando patterns na playlist

This commit is contained in:
JotaChina committed 2025-12-27 12:12:22 -03:00
1 parent ec772ad8aa
commit ef499e3df9
6 files changed
+234 -5

No files matched your search

+27 -1
View File
@@ -195,4 +195,30 @@ export function adjustValue(inputElement, step) {
inputElement.value = newValue;
inputElement.dispatchEvent(new Event("input", { bubbles: true }));
}
}
// ===============================
// LMMS ticks helpers (Song Editor)
// ===============================
export const LMMS_TICKS_PER_STEP = 12; // 1 step (1/16) = 12 ticks
export const STEPS_PER_BAR = 16; // 4/4: 16 steps por compasso
export const LMMS_TICKS_PER_BAR = LMMS_TICKS_PER_STEP * STEPS_PER_BAR; // 192
export function secondsToSongTicks(seconds, bpm = null) {
const b = bpm ?? (parseFloat(document.getElementById("bpm-input")?.value) || 120);
// stepIntervalSec = 60/(bpm*4) => ticksPerSec = 12/stepIntervalSec = bpm*0.8
const ticks = seconds * b * 0.8;
return Math.round(ticks);
}
export function songTicksToSeconds(ticks, bpm = null) {
const b = bpm ?? (parseFloat(document.getElementById("bpm-input")?.value) || 120);
// seconds = ticks / (bpm*0.8)
return ticks / (b * 0.8);
}
export function snapSongTicks(ticks, snap = LMMS_TICKS_PER_STEP) {
const s = Math.max(1, Math.floor(snap));
return Math.round(ticks / s) * s;
}