-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload-diss-wasm.js
43 lines (35 loc) · 1.25 KB
/
load-diss-wasm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import init, {
calculateDissonance,
dissonanceMatrix,
findOffender,
findOffenderGraph,
greet,
load,
selectCandidate,
updateTonicity,
} from './dissonance-wasm/dissonance_wasm.js';
async function loadDissWasm() {
console.log("Loading dissonance-wasm...")
const w = await init("/dissonance-wasm/dissonance_wasm_bg.wasm");
/*
REMINDER TO SELF:
DO NOT export w.calculateDissonance, etc... directly from the instance 'w', as it will use a
completely different relative closure than importing the functions from the module using ES6
modules.
it will NOT WORK and result in tons of memory errors and undefined behavior!
*/
console.log("dissonance-wasm webassembly loaded!")
// TODO: uncomment this once finish debugging. Commenting this will postpone computing lookup
// tables until the first note.
load();
console.dir(w);
window.calculateDissonance = calculateDissonance;
window.dissonanceMatrix = dissonanceMatrix;
window.findOffender = findOffender;
window.findOffenderGraph = findOffenderGraph;
window.greet = greet;
window.selectCandidate = selectCandidate;
window.updateTonicity = updateTonicity;
window.LOADED = true;
}
loadDissWasm();