playlist importando sample track
Deploy / Deploy (push) Successful in 1m54s
Details
Deploy / Deploy (push) Successful in 1m54s
Details
This commit is contained in:
parent
7ec18a5f02
commit
7c42fa0580
|
|
@ -145,25 +145,22 @@ export async function loadAudioForClip(clip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const safeUrl = encodeURI(url).replace(/#/g, "%23");
|
const safeUrl = encodeURI(clip.sourcePath).replace(/#/g, "%23");
|
||||||
const response = await fetch(safeUrl);
|
const response = await fetch(safeUrl);
|
||||||
|
|
||||||
if (!response.ok)
|
if (!response.ok)
|
||||||
throw new Error(`Falha ao buscar áudio: ${clip.sourcePath}`);
|
throw new Error(`Falha ao buscar áudio: ${clip.sourcePath}`);
|
||||||
|
|
||||||
const arrayBuffer = await response.arrayBuffer();
|
const arrayBuffer = await response.arrayBuffer();
|
||||||
const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
|
const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
|
||||||
|
|
||||||
clip.buffer = audioBuffer;
|
clip.buffer = audioBuffer;
|
||||||
|
if (clip.durationInSeconds === 0) clip.durationInSeconds = audioBuffer.duration;
|
||||||
// --- Salva a duração original ---
|
|
||||||
if (clip.durationInSeconds === 0) {
|
|
||||||
clip.durationInSeconds = audioBuffer.duration;
|
|
||||||
}
|
|
||||||
// Salva a duração real do buffer para cálculos de stretch
|
|
||||||
clip.originalDuration = audioBuffer.duration;
|
clip.originalDuration = audioBuffer.duration;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Falha ao carregar áudio para o clipe ${clip.name}:`, error);
|
console.error(`Falha ao carregar áudio para o clipe ${clip.name}:`, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return clip;
|
return clip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue