feross / timidity

Play MIDI files in the browser w/ Web Audio, WebAssembly, and libtimidity
https://bitmidi.com
MIT License
364 stars 38 forks source link

fix wasm module loading, enhance source map #11

Closed connorjclark closed 3 years ago

connorjclark commented 3 years ago

I needed to debug why a particular set of midi files I had wasn't working with this library, so I checked out the repo to build a debug version. Even without the debug flags, I saw that a fresh build wasn't working, at least not with the latest version of emcc. Seems they switched to a native Promise implementation, so it broke some things here. It was a simple change to how the wasm module is loaded.

I also tacked on some sourceContents to the source map generated. Helps debugging a lot.

Confirmed these changes work. Also, via debugging in the browser I realized that my midi files had empty tracks, which broke the parser. I was able to trim the excess tracks and everything worked great.

I don't know anything about emcc or wasm, but I was able to hack this together. Hope it helps.

(sidenote: would you consider also publishing the debug wasm + source map to npm?)

feross commented 3 years ago

I just made my requested changes to speed things up and get this into a release: https://github.com/feross/timidity/pull/12

connorjclark commented 3 years ago

Great, thanks!

I'm not sure if this is a common practice, but it might be nice to also publish the debug files to npm:

libtimidity.debug.js
libtimidity.debug.wasm
libtimidity.debug.wasm.map

This would allow users to easily debug (w/o needing to locally install the project and build it)

feross commented 3 years ago

We could publish them to npm, but I've been trying to slim down my package sizes recently so I think I'd rather exclude these for now.