summaryrefslogtreecommitdiff
path: root/src/compute.c
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2012-06-17 16:18:53 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2012-06-17 16:18:53 +0000
commitc8e2aaf6999da491d6ea8dab2bc99752fa94b6d4 (patch)
tree49ef9be6a6ce6044aa2780cc52d7292f2836ab61 /src/compute.c
parent71dad10fdabd700f036893c725f02c9b4b4ac49b (diff)
download2012-violon-leds-c8e2aaf6999da491d6ea8dab2bc99752fa94b6d4.tar.gz
2012-violon-leds-c8e2aaf6999da491d6ea8dab2bc99752fa94b6d4.tar.bz2
2012-violon-leds-c8e2aaf6999da491d6ea8dab2bc99752fa94b6d4.zip
Ajout d'une fonction pour linéariser un peu la réponse du projecteur (illuminate.c)
Ajout d'une moyenne sur 8 valeurs pour la luminosité (mais on garde la valeur instantanée pour altérer la couleur) Correction du vumeter qui s'initialisais à 1px par 1px au lancement de l'appli. Avec le lud-msi, le projo à Ju et les sons enregistrés par Laurent, ça pète pas mal :P git-svn-id: file:///var/svn/2012-violon-leds/trunk@24 6be1fa4d-33ac-4c33-becc-79fcb3794bb6
Diffstat (limited to 'src/compute.c')
-rw-r--r--src/compute.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/compute.c b/src/compute.c
index 54d6929..ce0575f 100644
--- a/src/compute.c
+++ b/src/compute.c
@@ -100,20 +100,38 @@ 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;
+ static float value_decay[8]={0.f};
+ static int decay_idx=0;
- float level_norm=(38.f+audio_level)/30.f;
+ int i;
+ float level_norm, temp;
+ // Testé avec micro externe sur lud-msi
+ //[-38dB;0dB] -> [0.0;1.0]
+ level_norm=(38.f+audio_level)/38.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;
+
+ if (decay_idx>=8) decay_idx=0;
+ value_decay[decay_idx++]=level_norm;
+
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_h=hue;
+ temp=hue+level_norm/3.f;
+ *light_h=temp-(int)temp; // Fractionnal part
+
*light_s=1.f;
- *light_v=level_norm;
+
+// *light_v=level_norm;
+ temp=0.f;
+ for(i=0;i<8;i++) temp+=value_decay[i];
+ temp/=8.f;
+ *light_v=temp;
}