NEW 134060
Float denormal issue in JavaScript processor node in Web Audio API
https://bugs.webkit.org/show_bug.cgi?id=134060
Summary Float denormal issue in JavaScript processor node in Web Audio API
letz
Reported 2014-06-19 06:53:56 PDT
We successfully compile our C++ audio processing code with emcripten in asm.js to deploy on the web using the WebAudio API , so running the resulting asm.js code in a ScriptProcessorNode in the Web Audio API. Our C++ code uses the following denormalized float number protection code ("protection" is needed since denormalized float number computation is awfully slow and has to be avoided): #ifdef __SSE__ #include <xmmintrin.h> #ifdef __SSE2__ #define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8040) #else #define AVOIDDENORMALS _mm_setcsr(_mm_getcsr() | 0x8000) #endif #else #define AVOIDDENORMALS #endif Basically we add a call at AVOIDDENORMALS before each audio block processing. It seems this AVOIDDENORMALS is just removed by the emcripten compiler and so we get asm.js code that seems to produce denormalized floats and the speed issue occurs. The attached "piano.html" page contains a piano physical model that is compiled in asm.js and run as a Web Audio API ScriptProcessorNode. It you hit the "gate" button a sound is played. After some seconds the CPU use (seen in activity monitor on OSX) raises to 100%. ScriptProcessorNode node takes a lot of time to execute since float denormal issue happens ScriptProcessorNode should probably be processes in an context where flush denormals to zero is done automatically.
Attachments
Test file that contains a ScripProcessorNode that shows the problem (1.06 MB, text/html)
2014-06-19 06:56 PDT, letz
no flags
letz
Comment 1 2014-06-19 06:56:38 PDT
Created attachment 233358 [details] Test file that contains a ScripProcessorNode that shows the problem
Note You need to log in before you can comment on or make changes to this bug.