# MIDI sounds drunk in html5

**URL:** https://qa.fmod.com/t/midi-sounds-drunk-in-html5/13917
**Category:** FMOD Engine
**Created:** [June 1, 2018, 2:20am UTC](https://qa.fmod.com/t/midi-sounds-drunk-in-html5/13917 "2018-06-01T02:20:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![RTSeth](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/rtseth/32/3429_2.png) [@RTSeth](https://qa.fmod.com/u/RTSeth)
#### Post date: [June 1, 2018, 2:20am UTC](https://qa.fmod.com/t/midi-sounds-drunk-in-html5/13917/1 "2018-06-01T02:20:14Z")

</div>

Is there a FMOD MIDI html5 demo/example anywhere that shows this working?

My game Dink Smallwood (open source at svn://rtsoft.com/rtsvn/projects/RTDink ) uses FMOD and it runs fine on Win/Mac/iOS/Android, but the html5 version plays notes out of tune.

I’m using the latest HTML5 FMOD studio (1.10.05) (low level lib)

I’ve tried a few different dls instrument packs, but they all play with incorrect pitches and sound out of tune.

If you want to hear it, click [https://rtsoft.com/web/dink](https://rtsoft.com/web/dink) then click “New”. (the title music is an mp3 so that won’t show any issue, but after clicking new, a MIDI is used, it will sound weird/bad on firefox/chrome/etc)

I’ve tried with various setDSPBufferSize/voices, but this doesn’t seem related to performance, more like … mixing buffers using wrong sample rate for midi notes or something.

[http://www.fmod.org/public/js/](http://www.fmod.org/public/js/) doesn’t appear to have a MIDI example

Sorry, I can’t figure out how to add tags to this message. Maybe my many ad blockers are doing something.

---

<div class="post-metadata">

### Author: ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)
#### Post date: [June 1, 2018, 4:21am UTC](https://qa.fmod.com/t/midi-sounds-drunk-in-html5/13917/2 "2018-06-01T04:21:08Z")

</div>

Hi Seth,  
Looks like we’ve run afoul of precision issues in emscripten. I found this [https://groups.google.com/forum/#!topic/emscripten-discuss/JqopAJKSaFo](https://groups.google.com/forum/#!topic/emscripten-discuss/JqopAJKSaFo) which funnily enough even mentions the same midi pitch function that has gone wrong in FMOD.

I’ve worked around the issue, ive put a fix in for the next release.

---

<div class="post-metadata">

### Author: ![RTSeth](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/rtseth/32/3429_2.png) [@RTSeth](https://qa.fmod.com/u/RTSeth)
#### Post date: [June 1, 2018, 4:26am UTC](https://qa.fmod.com/t/midi-sounds-drunk-in-html5/13917/3 "2018-06-01T04:26:23Z")

</div>

Excellent, will be eagerly waiting for the next build!

Edit: Adding -s PRECISE\_F32=2 to my emscripten build script did correct it for now - although I believe this has some performance implications so I’ll remove this flag after the updated build that doesn’t require this is ready

---

<div class="post-metadata">

### Author: ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)
#### Post date: [June 1, 2018, 4:44am UTC](https://qa.fmod.com/t/midi-sounds-drunk-in-html5/13917/4 "2018-06-01T04:44:55Z")

</div>

I’ve updated the [fmod.org/public/js](http://fmod.org/public/js) example folder with a new build.

Check [http://www.fmod.org/public/js/load\_from\_memory.html](http://www.fmod.org/public/js/load_from_memory.html) - I have added a dls so it can load midi files.
