diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2012-06-08 22:49:38 +0000 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2012-06-08 22:49:38 +0000 |
commit | 22079050f23cd4e019fc7dc98c25d5e06b1f8ead (patch) | |
tree | 6352c24dcf0ed4e87172f880ee06e61fb4ef93d6 /tests/test6/test6.c | |
parent | 438cfc61ee3fae8875dbbf24a44fa7d75969f2b3 (diff) | |
download | 2012-violon-leds-22079050f23cd4e019fc7dc98c25d5e06b1f8ead.tar.gz 2012-violon-leds-22079050f23cd4e019fc7dc98c25d5e06b1f8ead.tar.bz2 2012-violon-leds-22079050f23cd4e019fc7dc98c25d5e06b1f8ead.zip |
Bon, la détection de volume commence à ressembler à qque chose mais les valeurs semblent pas forcément bonnes. Le filtre A n'est pas appliqué encore.
Dans le test6, quelques essais de maths...
git-svn-id: file:///var/svn/2012-violon-leds/trunk@14 6be1fa4d-33ac-4c33-becc-79fcb3794bb6
Diffstat (limited to 'tests/test6/test6.c')
-rw-r--r-- | tests/test6/test6.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test6/test6.c b/tests/test6/test6.c new file mode 100644 index 0000000..fc99598 --- /dev/null +++ b/tests/test6/test6.c @@ -0,0 +1,36 @@ +#include <math.h> +#include <stdio.h> + +//#if 1 //(UGLY_IEEE754_FLOAT32_HACK :-) +/* +static inline float todB_a(const float *x){ + return (float)((*(int *)x)&0x7fffffff) * 7.17711438e-7f -764.6161886f; +} +*/ +static inline float todB_a(const float *x){ + union { + //int32_t i; + int i; + float f; + } ix; + ix.f = *x; + ix.i = ix.i&0x7fffffff; + return (float)(ix.i * 7.17711438e-7f -764.6161886f); +} +//#else + +static inline float todB_a2(const float *x){ + return (*(x)==0?-400.f:logf(*(x)**(x))*4.34294480f); +} + +//#endif + +int main() { + float f; + + for(f=1.f;f<100000000.f;f*=1.2f) + printf("%f\t%f\n", todB_a(&f), todB_a2(&f)); + + return 0; +} + |