summaryrefslogtreecommitdiff
path: root/src/compute.c
diff options
context:
space:
mode:
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;