summaryrefslogtreecommitdiff
path: root/src/compute.c
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2012-06-17 09:28:18 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2012-06-17 09:28:18 +0000
commit96d4d223a6e2790e6269cd3b19b4944d99d61eb3 (patch)
treec62d0a1e02e7e9fe4a4415a6eeafb8ea35d10bf4 /src/compute.c
parent797149c5a9ee0c7c70947f72cbaece5efd3dd687 (diff)
download2012-violon-leds-96d4d223a6e2790e6269cd3b19b4944d99d61eb3.tar.gz
2012-violon-leds-96d4d223a6e2790e6269cd3b19b4944d99d61eb3.tar.bz2
2012-violon-leds-96d4d223a6e2790e6269cd3b19b4944d99d61eb3.zip
Premiere integraation de la partie DMX. Parfois le programme rate l'initialisation ou semble freezé !!
Mais l'iilumination fonctionne. La réactivité est géniale, il y a du boulot pour filtrer le plancher bruit et il y a encore un "flicker" pas sympa, je pense que ça a encore à voir avec la taille des buffers passés à la FFT... C'est très con ce pb... Les tests de cette version ont été faits avec le Netbook MSI (Ludo). git-svn-id: file:///var/svn/2012-violon-leds/trunk@21 6be1fa4d-33ac-4c33-becc-79fcb3794bb6
Diffstat (limited to 'src/compute.c')
-rw-r--r--src/compute.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/compute.c b/src/compute.c
index 272d6f8..54d6929 100644
--- a/src/compute.c
+++ b/src/compute.c
@@ -26,7 +26,9 @@ float compute_level(const float *data, size_t nsamples, int rate) {
}
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
+ return -120.f;
+ }
+ /* Replicate with symmetry the sound to obtain an input buffer of the minimal len
for (i=0;i<MIN_SAMPLES;i++) {
if ( (i/nsamples)%2==1 )
input[i]=data[i]; // First channel only
@@ -34,11 +36,11 @@ float compute_level(const float *data, size_t nsamples, int rate) {
input[i]=data[nsamples-i-1];
}
nsamples=MIN_SAMPLES;
- } else {
+ } else {*/
for (i=0;i<nsamples;i++) {
input[i]=data[i]; // First channel only
}
- }
+ //}
compute_spectrum(input, nsamples, pwrspec);
@@ -99,14 +101,15 @@ void compute_spectrum(float *data, int width, float output[PSHalf]) {
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;
+ float level_norm=(38.f+audio_level)/30.f;
- if (level_norm<0.f) level_norm=0.f;
+ if (level_norm<0.0f) level_norm=0.f;
+ //if (level_norm<0.1f) level_norm=0.f; //FIXME : ici cache misere pour le tremblement sur plancher bruit
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);
+// printf("%+3.1f %+1.3f\n", audio_level, level_norm);
// Dummy code
*light_h=hue;