melhorando a leitura de projetos no mmpCreator
This commit is contained in:
1 parent
9f06aed297
commit
8dbf240928
3 files changed
+31
-20
No files matched your search
@@ -275,24 +275,25 @@ function schedulePianoRoll() {
|
||||
track.instrument
|
||||
) {
|
||||
// Converte notas para eventos Tone.js
|
||||
const events = pattern.notes.map((note) => {
|
||||
// --- CORREÇÃO DE TEMPO (PPQ) ---
|
||||
// LMMS usa 192 ticks por batida. Tone.js também usa 192 por padrão.
|
||||
// Precisamos converter o 'pos' (ticks absolutos) para tempo musical
|
||||
const bpm = parseInt(document.getElementById("bpm-input")?.value, 10) || 120;
|
||||
const stepSec = 60 / (bpm * 4); // 1/16
|
||||
|
||||
// 1 Beat = 192 ticks
|
||||
// Tone.Time("0:0:0").toTicks()
|
||||
const events = pattern.notes.map((note) => {
|
||||
const posSteps = (note.pos || 0) / TICKS_PER_STEP;
|
||||
|
||||
const rawLen = note.len || 0;
|
||||
const lenTicks = rawLen < 0 ? TICKS_PER_STEP : rawLen; // defesa extra
|
||||
const lenSteps = Math.max(1, lenTicks / TICKS_PER_STEP);
|
||||
|
||||
return {
|
||||
// Passamos 'ticks' diretamente. O Tone converte baseado no BPM.
|
||||
time:
|
||||
0 + (note.pos * (Tone.Transport.PPQ / 192)) / Tone.Transport.PPQ,
|
||||
time: posSteps * stepSec, // segundos
|
||||
midi: note.key,
|
||||
duration: note.len / 192 + "n", // Converte duração baseada em semínimas (192)
|
||||
duration: lenSteps * stepSec, // segundos
|
||||
velocity: (note.vol || 100) / 100,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
const part = new Tone.Part((time, value) => {
|
||||
if (track.muted) return;
|
||||
const freq = Tone.Frequency(value.midi, "midi");
|
||||
|
||||
Reference in new issue
Block a user