From 797149c5a9ee0c7c70947f72cbaece5efd3dd687 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 16 Jun 2012 22:29:33 +0000 Subject: Création du source tree princpal. Les routines de maths pour calculer le gain déconnent encore je trouve. Reste à intégrer la partie DMX et a améliorer tout ce qui a été laissé de côté... 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@20 6be1fa4d-33ac-4c33-becc-79fcb3794bb6 --- src/compute.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 src/compute.c (limited to 'src/compute.c') diff --git a/src/compute.c b/src/compute.c new file mode 100644 index 0000000..272d6f8 --- /dev/null +++ b/src/compute.c @@ -0,0 +1,116 @@ +#include "compute.h" + +#include "fft.h" +#include + +#define MIN_SAMPLES 256 +#define MAX_SAMPLES 2048 + +//#define MAX(a,b) (a>b?a:b) +//#define MIN(a,b) (a= MAX_SAMPLES) { + printf("WARN : nsamples >= MAX_SAMPLES : %i >= %i\n", nsamples, MAX_SAMPLES); + nsamples=MAX_SAMPLES; + } + if (nsamples < MIN_SAMPLES) { + printf("WARN : nsamples < MIN_SAMPLES : %i >= %i\n", nsamples, MIN_SAMPLES); + // Replicate with symmetry the sound to obtain an input buffer of the minimal len + for (i=0;i 0.0) + output[i] = 10*log10(temp); + else + output[i] = 0; + } +} + +void audio2hsv_1(float audio_level, float *light_h, float *light_s, float *light_v) { + static float hue=0; + + float level_norm=(50.f+audio_level)/30.f; + + if (level_norm<0.f) level_norm=0.f; + if (level_norm>1.f) level_norm=1.f; + hue=(hue+0.0002f); + if (hue>1.f) hue-=1.f; + + printf("%+3.1f %+1.3f\n", audio_level, level_norm); + + // Dummy code + *light_h=hue; + *light_s=1.f; + *light_v=level_norm; +} + -- cgit v1.2.3