#include "compute.h" #include "fft.h" #include #define MIN_SAMPLES 256 #define MAX_SAMPLES 2048 //static inline float todB_a(const float *x); void compute_spectrum(float * data, int width, double rate, float *output); 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 value; int gain=20, range=80; if (nsamples >= 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); for (i=0;i 0.0) processed[i] = 10*log10(temp); else processed[i] = 0; } for(i=0;i<256/2;i++) output[i] = processed[i]; } void audio2hsv_1(gint audio_level, gint *light_h, gint *light_s, gint *light_v) { // Dummy code *light_h=-audio_level; *light_s=audio_level; *light_v=65535; } void hsv2rgb(gint h, gint s, gint v, gint *r, gint *g, gint *b) { /* * Purpose: * Convert HSV values to RGB values * All values are in the range [0..65535] */ float F, M, N, K; int I; if ( s == 0 ) { /* * Achromatic case, set level of grey */ *r = v; *g = v; *b = v; } else { I = (int) h/(65535/6); /* should be in the range 0..5 */ F = h - I; /* fractional part */ M = v * (1 - s); N = v * (1 - s * F); K = v * (1 - s * (1 - F)); if (I == 0) { *r = v; *g = K; *b = M; } if (I == 1) { *r = N; *g = v; *b = M; } if (I == 2) { *r = M; *g = v; *b = K; } if (I == 3) { *r = M; *g = N; *b = v; } if (I == 4) { *r = K; *g = M; *b = v; } if (I == 5) { *r = v; *g = M; *b = N; } } }