From 22079050f23cd4e019fc7dc98c25d5e06b1f8ead Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Fri, 8 Jun 2012 22:49:38 +0000 Subject: 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... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///var/svn/2012-violon-leds/trunk@14 6be1fa4d-33ac-4c33-becc-79fcb3794bb6 --- tests/test6/compil.sh | 1 + tests/test6/octave1.txt | 16 ++++++++++++++++ tests/test6/test6.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100755 tests/test6/compil.sh create mode 100644 tests/test6/octave1.txt create mode 100644 tests/test6/test6.c (limited to 'tests/test6') 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 +#include + +//#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; +} + -- cgit v1.2.3