From 94343c63269b1e343f4e790fd9ef2b98f1fd36f8 Mon Sep 17 00:00:00 2001 From: JotaChina Date: Fri, 26 Dec 2025 20:04:50 -0300 Subject: [PATCH] tentando resolver conflitos do tone no mmpCreator --- assets/js/creations/file.js | 2 +- assets/js/creations/pattern/pattern_audio.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/assets/js/creations/file.js b/assets/js/creations/file.js index c0a01ca5..8e40419e 100755 --- a/assets/js/creations/file.js +++ b/assets/js/creations/file.js @@ -14,7 +14,7 @@ import { renderAll, getSamplePathMap } from "./ui.js"; import { DEFAULT_PAN, DEFAULT_VOLUME, NOTE_LENGTH } from "./config.js"; import { initializeAudioContext, getMainGainNode } from "./audio.js"; import { DEFAULT_PROJECT_XML, getSecondsPerStep, SAMPLE_SRC } from "./utils.js"; -import * as Tone from "https://esm.sh/tone"; +import * as Tone from "https://esm.sh/tone@14.7.77"; import { sendAction } from "./socket.js"; // ⚠️ vem do módulo de áudio (o mesmo que audio_ui usa) diff --git a/assets/js/creations/pattern/pattern_audio.js b/assets/js/creations/pattern/pattern_audio.js index 3157be04..f5c7174d 100755 --- a/assets/js/creations/pattern/pattern_audio.js +++ b/assets/js/creations/pattern/pattern_audio.js @@ -1,5 +1,5 @@ // js/pattern_audio.js -import * as Tone from "https://esm.sh/tone"; +import * as Tone from "https://esm.sh/tone@14.7.77"; import { appState } from "../state.js"; import { highlightStep } from "./pattern_ui.js"; @@ -632,7 +632,13 @@ export function startSongPatternPlaybackOnTransport() { if (patt.steps[stepInPattern]) { if (track.type === "sampler" && track.player) { track.player.restart = true; - try { track.player.start(time); } catch {} + try { + // Verifica se já está tocando. Se sim, para imediatamente antes de recomeçar. + if (track.player.state === "started") { + track.player.stop(); + } + track.player.start(time); } + catch {} } else if (track.type === "plugin" && track.instrument) { // plugin sem piano roll try { track.instrument.triggerAttackRelease("C5", "16n", time); } catch {}