Sound is distorted.
workhorsy opened this issue · 2 comments
Look at vnes and jsnes too see why their sound is smooth, and ours is popping and distorted.
Just a guess, but this could be due to additional latency caused by calling JS from WASM. Basically, SDL does it's thing to generate sound but eventual this generated sound (raw wave form?) is pushed out to the browsers JavaScript API. The glue between these two spaces may cause enough latency that it could be an issue if being called too many times per second. Just a thought.
This explains the concept some https://hacks.mozilla.org/2018/10/calls-between-javascript-and-webassembly-are-finally-fast-%F0%9F%8E%89/
Not sure how likely it is that this is the issue, but since this is basically a SDL based sound synthesizer WASM is generating every cycle of the outgoing wave form. Also note that SDL is communicating with JS at the same time for video output as well.
It has been a long time since I worked on this.
It does have an option to run under SDL on the desktop. I just tried it, and it has messed up sound too. So it can't have anything to do with the browser. Thanks for looking into it though.