44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
const { run_app } = wasm_bindgen;
|
|
|
|
async function loadWasm() {
|
|
let msg = 'This demo requires a current version of Firefox (e.g., 79.0)';
|
|
if (typeof SharedArrayBuffer !== 'function') {
|
|
alert('this browser does not have SharedArrayBuffer support enabled' + '\n\n' + msg);
|
|
return
|
|
}
|
|
|
|
// Test for bulk memory operations with passive data segments
|
|
// (module (memory 1) (data passive ""))
|
|
const buf = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00,
|
|
0x05, 0x03, 0x01, 0x00, 0x01, 0x0b, 0x03, 0x01, 0x01, 0x00]);
|
|
if (!WebAssembly.validate(buf)) {
|
|
alert('this browser does not support passive wasm memory, demo does not work' + '\n\n' + msg);
|
|
return
|
|
}
|
|
|
|
let res = await wasm_bindgen('/wasm/audioview_player_bg.wasm');
|
|
console.log(res);
|
|
//run_app();
|
|
}
|
|
|
|
window.addEventListener("DOMContentLoaded", () => {
|
|
console.log("Loading wasm module...");
|
|
loadWasm();
|
|
|
|
//console.log("Setting up audio worklet...");
|
|
|
|
//const ctx = new AudioContext();
|
|
//ctx.audioWorklet.addModule("worklet.js?t=" + new Date().getTime())
|
|
//.then(() => {
|
|
//const workletNode = new AudioWorkletNode(ctx, 'audio-worker');
|
|
|
|
//workletNode.connect(ctx.destination);
|
|
|
|
//fetch('audioview.wasm?t=' + new Date().getTime())
|
|
//.then(r => r.arrayBuffer())
|
|
//.then(r => workletNode.port.postMessage({ type: 'loadWasm', data: r }))
|
|
//.catch(err => console.log(err));
|
|
//})
|
|
//.catch(err => console.error(err));
|
|
});
|