tentando resolver conflitos do tone no mmpCreator
This commit is contained in:
1 parent
44d8250efb
commit
29b76f44a4
2 files changed
+174
-167
No files matched your search
+45
-17
@@ -345,20 +345,29 @@ function parseInstrumentNode(
|
||||
|
||||
const volFromFile = parseFloat(instrumentTrackNode.getAttribute("vol"));
|
||||
const panFromFile = parseFloat(instrumentTrackNode.getAttribute("pan"));
|
||||
const baseNoteFromFile = parseInt(instrumentTrackNode.getAttribute("basenote"), 10);
|
||||
const pitchFromFile = parseFloat(instrumentTrackNode.getAttribute("pitch"));
|
||||
|
||||
return {
|
||||
const baseNote = !isNaN(baseNoteFromFile) ? baseNoteFromFile : 60; // fallback C4 (MIDI 60)
|
||||
const pitch = !isNaN(pitchFromFile) ? pitchFromFile : 0;
|
||||
|
||||
|
||||
return {
|
||||
id: Date.now() + Math.random(),
|
||||
name: trackName,
|
||||
type: trackType,
|
||||
samplePath: finalSamplePath,
|
||||
patterns: patterns,
|
||||
//activePatternIndex: 0, // Sempre começa mostrando o primeiro pattern disponível
|
||||
patterns,
|
||||
activePatternIndex: 0, // ✅ evita index undefined
|
||||
baseNote, // ✅ importante p/ sample pitch
|
||||
pitch, // (opcional p/ transposição depois)
|
||||
volume: !isNaN(volFromFile) ? volFromFile / 100 : DEFAULT_VOLUME,
|
||||
pan: !isNaN(panFromFile) ? panFromFile / 100 : DEFAULT_PAN,
|
||||
instrumentName: instrumentName,
|
||||
instrumentName,
|
||||
instrumentXml: instrumentNode.innerHTML,
|
||||
parentBasslineId: parentBasslineId,
|
||||
parentBasslineId,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
@@ -566,21 +575,40 @@ export async function parseMmpContent(xmlString) {
|
||||
// Configura tamanho da timeline
|
||||
let isFirstTrackWithNotes = true;
|
||||
newTracks.forEach((track) => {
|
||||
if (track.type !== "bassline" && isFirstTrackWithNotes) {
|
||||
const activePattern = track.patterns[track.activePatternIndex || 0];
|
||||
if (
|
||||
activePattern &&
|
||||
activePattern.steps &&
|
||||
activePattern.steps.length > 0
|
||||
) {
|
||||
const bars = Math.ceil(activePattern.steps.length / 16);
|
||||
const barsInput = document.getElementById("bars-input");
|
||||
if (barsInput) barsInput.value = bars > 0 ? bars : 1;
|
||||
isFirstTrackWithNotes = false;
|
||||
}
|
||||
if (track.type === "bassline" || !isFirstTrackWithNotes) return;
|
||||
|
||||
const activePattern = track.patterns?.[track.activePatternIndex || 0];
|
||||
if (!activePattern) return;
|
||||
|
||||
let bars = 1;
|
||||
|
||||
// ✅ Se tiver piano roll, calcula pelo final da última nota
|
||||
if (activePattern.notes && activePattern.notes.length > 0) {
|
||||
const TICKS_PER_BAR = 192; // LMMS 4/4
|
||||
const TICKS_PER_STEP = 12; // 1/16
|
||||
|
||||
let maxEndTick = 0;
|
||||
activePattern.notes.forEach((n) => {
|
||||
const pos = parseInt(n.pos, 10) || 0;
|
||||
const rawLen = parseInt(n.len, 10) || 0;
|
||||
const len = rawLen < 0 ? TICKS_PER_STEP : rawLen; // fallback
|
||||
maxEndTick = Math.max(maxEndTick, pos + Math.max(len, TICKS_PER_STEP));
|
||||
});
|
||||
|
||||
bars = Math.max(1, Math.ceil(maxEndTick / TICKS_PER_BAR));
|
||||
}
|
||||
// ✅ Senão, cai no step sequencer normal
|
||||
else if (activePattern.steps && activePattern.steps.length > 0) {
|
||||
bars = Math.max(1, Math.ceil(activePattern.steps.length / 16));
|
||||
}
|
||||
|
||||
const barsInput = document.getElementById("bars-input");
|
||||
if (barsInput) barsInput.value = String(bars);
|
||||
|
||||
isFirstTrackWithNotes = false;
|
||||
});
|
||||
|
||||
|
||||
// Carrega samples/plugins
|
||||
try {
|
||||
const promises = newTracks
|
||||
|
||||
Reference in new issue
Block a user