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 +-- 5 files changed, 35 insertions(+), 25 deletions(-) (limited to 'tests/test5') 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