Closed msh75 closed 1 year ago
There are two issues with your code:
This code will work (tested on codepen). In this example I used unpkg.com, but any other service could work:
<html>
<body>
<button id="btn">play</button>
</body>
<script type="module">
import { Soundfont } from "https://unpkg.com/smplr@0.10.0/dist/index.mjs"; // needs to be a url
const context = new AudioContext(); // create the audio context
const marimba = new Soundfont(context, { instrument: "marimba" }); // create the player
document.getElementById("btn").onclick = () => {
context.resume(); // enable audio context after a user interaction
marimba.start({ note: 60, velocity: 80 }); // play the note
}
</script>
</html>
Feel free to reopen if you still have problems.
Hi, I'm getting this error when trying to make a simple sound :
Uncaught TypeError: The specifier “smplr” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.
The code I run -after installing using 'npm i smplr' is like this: