From 88f174d0b8b749cf96a38e284f266d3bdaa55ef4 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sun, 10 Jun 2012 20:22:56 +0000 Subject: Bon, on reprends à plat les problèmes de maths avec des fichiers en entrée pour valider tutes les étapes... 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@16 6be1fa4d-33ac-4c33-becc-79fcb3794bb6 --- tests/test5/TOREAD | 2 ++ tests/test5/capture.c | 1 + tests/test5/compute.c | 52 +++++++++++++++++++++++++++++--------------------- tests/test5/test5.c | 2 +- tests/test5/win_main.c | 3 +-- tests/test6/compil.sh | 1 + tests/test6/test6.c | 23 ++++++++++++++++++++-- 7 files changed, 57 insertions(+), 27 deletions(-) diff --git a/tests/test5/TOREAD b/tests/test5/TOREAD index b1abccf..c3acc33 100644 --- a/tests/test5/TOREAD +++ b/tests/test5/TOREAD @@ -5,3 +5,5 @@ http://www.developpez.net/forums/d467150/autres-langages/algorithmes/fft-role/ http://code.google.com/p/jivemodular/source/browse/trunk/apps/jive/src/model/plugins/meters/AudioSpecMeterEditor.cpp?r=67 http://en.wikipedia.org/wiki/Frequency_weighting +http://en.wikipedia.org/wiki/Root_mean_square#RMS_in_frequency_domain + diff --git a/tests/test5/capture.c b/tests/test5/capture.c index 26d345c..e8ca2fd 100644 --- a/tests/test5/capture.c +++ b/tests/test5/capture.c @@ -124,6 +124,7 @@ pa_stream *create_stream(pa_context *c, const pa_source_info *si) { .tlength=1024, .prebuf=-1, .minreq=-1, + // .minreq=256, //For FFT calculus .fragsize=512 }; diff --git a/tests/test5/compute.c b/tests/test5/compute.c index e8b03fc..d64f8c1 100644 --- a/tests/test5/compute.c +++ b/tests/test5/compute.c @@ -3,8 +3,9 @@ #include "fft.h" #include +#define MIN_SAMPLES 256 #define MAX_SAMPLES 2048 -static inline float todB_a(const float *x); +//static inline float todB_a(const float *x); void compute_spectrum(float * data, int width, double rate, float *output); @@ -13,42 +14,49 @@ gfloat compute_level(const float *data, size_t nsamples, size_t nchan) { double rate=44100; //TODO dynamique size_t i; float input[MAX_SAMPLES], output[128]; - float level; + float value; + int gain=20, range=80; if (nsamples >= MAX_SAMPLES) { printf("WARN : nsamples >= MAX_SAMPLES : %i >= %i\n", nsamples, MAX_SAMPLES); nsamples=MAX_SAMPLES; } -/* Just return the max peak - for (i=0;i= %i\n", nsamples, MIN_SAMPLES); + for (i=0;i #include +#include //#if 1 //(UGLY_IEEE754_FLOAT32_HACK :-) /* @@ -24,8 +25,7 @@ static inline float todB_a2(const float *x){ } //#endif - -int main() { +void test_todb_a() { float f, dbav[32]={0.f}, dbaf[32]={0.f}; int i=0; for(f=1024000.f;f>1.f;f/=2.f) { @@ -36,6 +36,25 @@ int main() { for (i=0;i<32;i++) printf("f==%f\tv==%f\n", dbaf[i], dbav[i]); +} + +void dump_testfile() { + int i,n; + float f[256]; + FILE *fh=fopen("./test.raw", "r"); + if (fh==NULL) return; + while ( (n=fread(f, sizeof(float), 256, fh)) > 0 ) { + for(i=0;i