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 | |
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')
-rwxr-xr-x | tests/test6/compil.sh | 1 | ||||
-rw-r--r-- | tests/test6/octave1.txt | 16 | ||||
-rw-r--r-- | tests/test6/test6.c | 36 |
3 files changed, 53 insertions, 0 deletions
diff --git a/tests/test6/compil.sh b/tests/test6/compil.sh new file mode 100755 index 0000000..4ac3ca3 --- /dev/null +++ b/tests/test6/compil.sh @@ -0,0 +1 @@ +gcc -Wall -g -o test6 test6.c -lm diff --git a/tests/test6/octave1.txt b/tests/test6/octave1.txt new file mode 100644 index 0000000..616628f --- /dev/null +++ b/tests/test6/octave1.txt @@ -0,0 +1,16 @@ +function s=son_pur(f,v,d,sr) + n = 1:(d*sr); + s = v*sin(2.*pi.*f*n/sr); +endfunction + +sr=8000; +f=440; +d=1; +v=0.9; + +s=son_pur(f,v,d,sr); +[y,c]=stft(s,128); +c +s2=synthesis(y,c); +sound(s2); + 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; +} + |