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 {
|
||||
const safeUrl = encodeURI(url).replace(/#/g, "%23");
|
||||
const safeUrl = encodeURI(clip.sourcePath).replace(/#/g, "%23");
|
||||
const response = await fetch(safeUrl);
|
||||
|
||||
|
||||
if (!response.ok)
|
||||
throw new Error(`Falha ao buscar áudio: ${clip.sourcePath}`);
|
||||
|
||||
const arrayBuffer = await response.arrayBuffer();
|
||||
const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
|
||||
|
||||
clip.buffer = audioBuffer;
|
||||
|
||||
// --- 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
|
||||
if (clip.durationInSeconds === 0) clip.durationInSeconds = audioBuffer.duration;
|
||||
clip.originalDuration = audioBuffer.duration;
|
||||
} catch (error) {
|
||||
console.error(`Falha ao carregar áudio para o clipe ${clip.name}:`, error);
|
||||
}
|
||||
|
||||
return clip;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue