- From: Stéphane Letz <letz@grame.fr>
- Date: Thu, 19 Jun 2014 14:39:13 +0200
- To: "public-audio@w3.org Group" <public-audio@w3.org>
Hi, 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. If we run the same kind of code in a pure native CoreAudio application on OSX, adding AVOIDDENORMALS is not needed once it seems the CoreAudio real-time thread is automatically protected for denormalization. Our understanding of the WebAudio API implementation is that ScriptProcessorNode code does not run in the audio real-time thread, so the code in not protected for denormalization. It is a know problem? Any solution others could have experimented? Thanks. Stéphane Letz
Received on Thursday, 19 June 2014 12:39:52 UTC