melhorando a leitura de projetos no mmpCreator
Deploy / Deploy (push) Successful in 2m16s
Details
Deploy / Deploy (push) Successful in 2m16s
Details
This commit is contained in:
parent
73a61a96f4
commit
f9ae0d92a8
|
|
@ -586,26 +586,56 @@ export function startSongPatternPlaybackOnTransport() {
|
||||||
|
|
||||||
for (const hit of activePatternHits) {
|
for (const hit of activePatternHits) {
|
||||||
const patt = track.patterns?.[hit.patternIndex];
|
const patt = track.patterns?.[hit.patternIndex];
|
||||||
if (!patt?.steps) continue;
|
if (!patt) continue;
|
||||||
|
|
||||||
|
// ✅ 1) PLUGIN com piano roll (notes)
|
||||||
|
if (
|
||||||
|
track.type === "plugin" &&
|
||||||
|
track.instrument &&
|
||||||
|
Array.isArray(patt.notes) &&
|
||||||
|
patt.notes.length > 0
|
||||||
|
) {
|
||||||
|
const stepStartTick = hit.localStep * LMMS_TICKS_PER_STEP;
|
||||||
|
const stepEndTick = stepStartTick + LMMS_TICKS_PER_STEP;
|
||||||
|
|
||||||
|
for (const n of patt.notes) {
|
||||||
|
const nPos = Number(n.pos) || 0;
|
||||||
|
if (nPos < stepStartTick || nPos >= stepEndTick) continue;
|
||||||
|
|
||||||
|
const offsetTicks = nPos - stepStartTick;
|
||||||
|
const t2 = time + ticksToSec(offsetTicks, stepIntervalSec);
|
||||||
|
|
||||||
|
const lenTicks = Math.max(1, Number(n.len) || LMMS_TICKS_PER_STEP);
|
||||||
|
const durSec = Math.max(0.01, ticksToSec(lenTicks, stepIntervalSec));
|
||||||
|
|
||||||
|
const vel = Math.max(0, Math.min(1, (Number(n.vol) || 100) / 100));
|
||||||
|
const noteName = midiToNoteName(n.key);
|
||||||
|
|
||||||
|
try {
|
||||||
|
track.instrument.triggerAttackRelease(noteName, durSec, t2, vel);
|
||||||
|
} catch {
|
||||||
|
try {
|
||||||
|
track.instrument.triggerAttackRelease(noteName, durSec, t2);
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
continue; // 👈 importante: não cair na lógica de steps abaixo
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ 2) Lógica antiga de STEP (sampler / plugin sem notes)
|
||||||
|
if (!patt.steps) continue;
|
||||||
|
|
||||||
if (patt.steps[hit.localStep]) {
|
if (patt.steps[hit.localStep]) {
|
||||||
// SAMPLER
|
|
||||||
if (track.type === "sampler" && track.player) {
|
if (track.type === "sampler" && track.player) {
|
||||||
track.player.restart = true; // baterias precisam retrigger
|
track.player.restart = true;
|
||||||
try {
|
try { track.player.start(time); } catch {}
|
||||||
track.player.start(time);
|
} else if (track.type === "plugin" && track.instrument) {
|
||||||
} catch {}
|
// plugin sem piano roll
|
||||||
}
|
try { track.instrument.triggerAttackRelease("C5", "16n", time); } catch {}
|
||||||
// PLUGIN (step sem piano roll)
|
|
||||||
else if (track.type === "plugin" && track.instrument) {
|
|
||||||
const hasNotes = patt.notes && patt.notes.length > 0;
|
|
||||||
if (!hasNotes) {
|
|
||||||
try {
|
|
||||||
track.instrument.triggerAttackRelease("C5", "16n", time);
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "16n");
|
}, "16n");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue