renderizando projetos no mmpCreator mudos
Deploy / Deploy (push) Successful in 2m8s
Details
Deploy / Deploy (push) Successful in 2m8s
Details
This commit is contained in:
parent
2a223afb21
commit
f1f4631db5
|
|
@ -498,7 +498,8 @@ export async function renderActivePatternToBlob() {
|
||||||
|
|
||||||
if (events.length > 0) {
|
if (events.length > 0) {
|
||||||
new Tone.Part((time) => {
|
new Tone.Part((time) => {
|
||||||
new Tone.Player(track.buffer).connect(volume).start(time);
|
const buf = track.buffer?.get?.() || track.buffer; // ✅ pega AudioBuffer se for ToneAudioBuffer
|
||||||
|
new Tone.Player(buf).connect(volume).start(time);
|
||||||
}, events).start(0);
|
}, events).start(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -519,21 +520,21 @@ export async function renderActivePatternToBlob() {
|
||||||
if (PluginClass) {
|
if (PluginClass) {
|
||||||
// INSTANCIA O PLUGIN NO MUNDO OFFLINE
|
// INSTANCIA O PLUGIN NO MUNDO OFFLINE
|
||||||
// Passamos 'track.params' ou 'track.pluginData' (ajuste conforme seu appState salva os dados)
|
// Passamos 'track.params' ou 'track.pluginData' (ajuste conforme seu appState salva os dados)
|
||||||
const instrumentInstance = new PluginClass(
|
const instrumentInstance = new PluginClass(Tone.getContext(), track.params || track.pluginData || {});
|
||||||
null,
|
|
||||||
track.params || track.pluginData || {}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Conecta na cadeia de áudio offline
|
// Conecta na cadeia de áudio offline
|
||||||
instrumentInstance.connect(volume);
|
instrumentInstance.connect(volume);
|
||||||
|
|
||||||
// 1. Agendar Notas do Piano Roll
|
// 1. Agendar Notas do Piano Roll
|
||||||
if (hasNotes) {
|
if (hasNotes) {
|
||||||
|
const TICKS_PER_BEAT = 192;
|
||||||
|
const TICKS_PER_STEP = 48; // 1/16
|
||||||
|
const SECONDS_PER_BEAT = 60 / bpm;
|
||||||
|
|
||||||
const events = pattern.notes.map((note) => ({
|
const events = pattern.notes.map((note) => ({
|
||||||
time: 0 + note.pos * (48 / 192) * stepInterval, // Conversão aproximada Ticks -> Segundos
|
time: (note.pos / TICKS_PER_BEAT) * SECONDS_PER_BEAT, // ✅ correto
|
||||||
// Se quiser precisão exata do Tone, use: note.pos * (Tone.Transport.PPQ / 192) / Tone.Transport.PPQ
|
|
||||||
midi: note.key,
|
midi: note.key,
|
||||||
duration: (note.len / 192) * (60 / bpm), // Duração em segundos
|
duration: (note.len / TICKS_PER_BEAT) * SECONDS_PER_BEAT, // ✅ já estava ok
|
||||||
velocity: (note.vol || 100) / 100,
|
velocity: (note.vol || 100) / 100,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -572,6 +573,11 @@ export async function renderActivePatternToBlob() {
|
||||||
transport.start();
|
transport.start();
|
||||||
}, duration);
|
}, duration);
|
||||||
|
|
||||||
|
const ch = buffer.getChannelData(0);
|
||||||
|
let peak = 0;
|
||||||
|
for (let i = 0; i < ch.length; i++) peak = Math.max(peak, Math.abs(ch[i]));
|
||||||
|
console.log("[Render] peak =", peak);
|
||||||
|
|
||||||
const blob = bufferToWave(buffer);
|
const blob = bufferToWave(buffer);
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
|
@ -1261,6 +1267,11 @@ export async function renderProjectToBlob({ tailSec = 0.25 } = {}) {
|
||||||
transport.start();
|
transport.start();
|
||||||
}, duration);
|
}, duration);
|
||||||
|
|
||||||
|
const ch = buffer.getChannelData(0);
|
||||||
|
let peak = 0;
|
||||||
|
for (let i = 0; i < ch.length; i++) peak = Math.max(peak, Math.abs(ch[i]));
|
||||||
|
console.log("[Render] peak =", peak);
|
||||||
|
|
||||||
return bufferToWave(buffer);
|
return bufferToWave(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue