samples de áudio não reiniciavam ao fim da playlist
This commit is contained in:
1 parent
45ad819197
commit
a213f44554
1 file changed
+26
@@ -34,6 +34,29 @@ const timerDisplay = document.getElementById("timer-display");
|
|||||||
// Variável para armazenar as "Parts" (sequências melódicas) do Tone.js
|
// Variável para armazenar as "Parts" (sequências melódicas) do Tone.js
|
||||||
let activeParts = [];
|
let activeParts = [];
|
||||||
|
|
||||||
|
// =====================================================
|
||||||
|
// Proteção: não “vazar” loop do Pattern Editor pro Song
|
||||||
|
// =====================================================
|
||||||
|
let _transportLoopSnapshot = null;
|
||||||
|
|
||||||
|
function snapshotTransportLoopOnce() {
|
||||||
|
if (_transportLoopSnapshot) return;
|
||||||
|
_transportLoopSnapshot = {
|
||||||
|
loop: Tone.Transport.loop,
|
||||||
|
loopStart: Tone.Transport.loopStart,
|
||||||
|
loopEnd: Tone.Transport.loopEnd,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreTransportLoop() {
|
||||||
|
if (!_transportLoopSnapshot) return;
|
||||||
|
Tone.Transport.loop = _transportLoopSnapshot.loop;
|
||||||
|
Tone.Transport.loopStart = _transportLoopSnapshot.loopStart;
|
||||||
|
Tone.Transport.loopEnd = _transportLoopSnapshot.loopEnd;
|
||||||
|
_transportLoopSnapshot = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let currentStep = 0;
|
let currentStep = 0;
|
||||||
|
|
||||||
function updateStepHighlight(step) {
|
function updateStepHighlight(step) {
|
||||||
@@ -182,6 +205,7 @@ export function stopPlayback(rewind = true) {
|
|||||||
Tone.Transport.stop();
|
Tone.Transport.stop();
|
||||||
Tone.Transport.cancel();
|
Tone.Transport.cancel();
|
||||||
stopScheduledPianoRoll();
|
stopScheduledPianoRoll();
|
||||||
|
restoreTransportLoop();
|
||||||
|
|
||||||
// ✅ Pattern Editor: para apenas o preview (não mexe no track.player da playlist)
|
// ✅ Pattern Editor: para apenas o preview (não mexe no track.player da playlist)
|
||||||
appState.pattern.tracks.forEach((track) => {
|
appState.pattern.tracks.forEach((track) => {
|
||||||
@@ -255,6 +279,8 @@ export function schedulePianoRoll() {
|
|||||||
barsInput.dispatchEvent(new Event("input", { bubbles: true }));
|
barsInput.dispatchEvent(new Event("input", { bubbles: true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snapshotTransportLoopOnce();
|
||||||
|
|
||||||
Tone.Transport.loop = true;
|
Tone.Transport.loop = true;
|
||||||
Tone.Transport.loopStart = 0;
|
Tone.Transport.loopStart = 0;
|
||||||
Tone.Transport.loopEnd = `${barsNeeded}m`;
|
Tone.Transport.loopEnd = `${barsNeeded}m`;
|
||||||
|
|||||||
Reference in new issue
Block a user