Amostras de áudio funcionais até o momento. Agulha de tempo, mute/solo e ajustado com a velocidade de reprodução, loop funcional.

This commit is contained in:
JotaChina committed 2025-10-12 10:42:27 -03:00
1 parent 602df1db6d
commit d506332268
6 files changed
+163 -95

No files matched your search

+11 -8
View File
@@ -13,6 +13,7 @@ import {
updateMasterPan,
startAudioEditorPlayback,
stopAudioEditorPlayback,
restartAudioEditorIfPlaying,
} from "./audio.js";
import { handleFileLoad, generateMmpFile } from "./file.js";
import {
@@ -21,7 +22,7 @@ import {
loadAndRenderSampleBrowser,
showOpenProjectModal,
closeOpenProjectModal,
handleSampleUpload, // Importa handleSampleUpload, embora não seja mais usado diretamente
handleSampleUpload,
} from "./ui.js";
import { adjustValue, enforceNumericInput } from "./utils.js";
import { DEFAULT_PAN, DEFAULT_VOLUME } from "./config.js";
@@ -37,6 +38,7 @@ document.addEventListener("DOMContentLoaded", () => {
const stopBtn = document.getElementById("stop-btn");
const audioEditorPlayBtn = document.getElementById("audio-editor-play-btn");
const audioEditorStopBtn = document.getElementById("audio-editor-stop-btn");
const audioEditorLoopBtn = document.getElementById("audio-editor-loop-btn");
const rewindBtn = document.getElementById("rewind-btn");
const metronomeBtn = document.getElementById("metronome-btn");
const mmpFileInput = document.getElementById("mmp-file-input");
@@ -57,6 +59,7 @@ document.addEventListener("DOMContentLoaded", () => {
return;
Object.assign(appState, {
tracks: [],
audioTracks: [],
activeTrackId: null,
isPlaying: false,
playbackIntervalId: null,
@@ -166,8 +169,6 @@ document.addEventListener("DOMContentLoaded", () => {
uploadSampleBtn.addEventListener("click", () => sampleFileInput.click());
// --- INÍCIO DA CORREÇÃO ---
// Lógica de upload de sample para o servidor Flask
sampleFileInput.addEventListener("change", async (event) => {
const file = event.target.files[0];
if (!file) return;
@@ -176,7 +177,6 @@ document.addEventListener("DOMContentLoaded", () => {
formData.append("sampleFile", file);
try {
// ATENÇÃO: Verifique se a URL e a porta estão corretas para o seu servidor Flask
const response = await fetch('http://localhost:5000/upload-sample', {
method: 'POST',
body: formData,
@@ -186,7 +186,6 @@ document.addEventListener("DOMContentLoaded", () => {
if (response.ok) {
alert("Sample enviado com sucesso!");
// Recarrega a lista de samples para exibir o novo arquivo
await loadAndRenderSampleBrowser();
} else {
throw new Error(result.error || "Erro desconhecido no servidor.");
@@ -197,9 +196,8 @@ document.addEventListener("DOMContentLoaded", () => {
alert(`Falha no upload: ${error.message}`);
}
event.target.value = null; // Limpa o input para permitir o mesmo arquivo de novo
event.target.value = null;
});
// --- FIM DA CORREÇÃO ---
saveMmpBtn.addEventListener("click", generateMmpFile);
addInstrumentBtn.addEventListener("click", addTrackToState);
@@ -252,7 +250,6 @@ document.addEventListener("DOMContentLoaded", () => {
});
});
// Listeners para os controles do editor de áudio
audioEditorPlayBtn.addEventListener("click", () => {
if (appState.isAudioEditorPlaying) {
stopAudioEditorPlayback();
@@ -263,6 +260,12 @@ document.addEventListener("DOMContentLoaded", () => {
audioEditorStopBtn.addEventListener("click", stopAudioEditorPlayback);
audioEditorLoopBtn.addEventListener("click", () => {
appState.isAudioEditorLoopEnabled = !appState.isAudioEditorLoopEnabled;
audioEditorLoopBtn.classList.toggle("active", appState.isAudioEditorLoopEnabled);
restartAudioEditorIfPlaying();
});
loadAndRenderSampleBrowser();
renderApp();
setupMasterKnobs();