Fix Wavehello launch page to load and compute realistic sample on first load
This commit is contained in:
1 parent
105881f45a
commit
31c597877a
1 file changed
+24
-2
@@ -51,10 +51,32 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
}
|
||||
|
||||
function initializeSample() {
|
||||
// Create a sample visualization on load
|
||||
async function initializeSample() {
|
||||
try {
|
||||
// Fetch the sample audio file
|
||||
const response = await fetch('sample.wav');
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to load sample audio');
|
||||
}
|
||||
|
||||
const arrayBuffer = await response.arrayBuffer();
|
||||
|
||||
// Create audio context if needed
|
||||
if (!audioContext) {
|
||||
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
}
|
||||
|
||||
// Decode the audio data
|
||||
audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
|
||||
|
||||
// Visualize the audio buffer
|
||||
visualizeAudioBuffer(audioBuffer);
|
||||
} catch (error) {
|
||||
console.error('Error loading sample:', error);
|
||||
// Fallback to sample visualization if loading fails
|
||||
createSampleVisualization();
|
||||
}
|
||||
}
|
||||
|
||||
function createSampleVisualization() {
|
||||
// Clear previous content
|
||||
|
||||
Reference in new issue
Block a user