I have this code in my index.html
:
<script type='module'>
import { Synthetizer } from "xxx.js";
window.test = () => {
const synth = new Synthetizer(context.destination,soundFontBuffer);
};
window.customfunction = () => {
//Here I need to use the variable `synth` created when `window.test` was executed.
synth.setProperty();
};
</script>
I have a div
element on my page and the onclick event of that element triggers the function customfunction();
however I cant find a way to access the variable synth
. I tried setting the synth
variable as global with var
however for some reason the library stops working, it only allows me to use const
when using that variable synth.
Any idea how I can solve this?