diff options
Diffstat (limited to 'tests/test5')
-rw-r--r-- | tests/test5/TOREAD | 2 | ||||
-rw-r--r-- | tests/test5/capture.c | 2 | ||||
-rw-r--r-- | tests/test5/compute.c | 26 | ||||
-rw-r--r-- | tests/test5/test5.c | 4 | ||||
-rw-r--r-- | tests/test5/win_main.c | 2 |
5 files changed, 18 insertions, 18 deletions
diff --git a/tests/test5/TOREAD b/tests/test5/TOREAD index e84ab7e..acb1aca 100644 --- a/tests/test5/TOREAD +++ b/tests/test5/TOREAD @@ -1,2 +1,4 @@ http://freedesktop.org/software/pulseaudio/doxygen/async.html#overv_sec +http://www.developpez.net/forums/d467150/autres-langages/algorithmes/fft-role/ + diff --git a/tests/test5/capture.c b/tests/test5/capture.c index 00d9c54..26d345c 100644 --- a/tests/test5/capture.c +++ b/tests/test5/capture.c @@ -195,8 +195,6 @@ void stream_read_callback(pa_stream *s, size_t nbytes, void *userdata) { //printf("debug : before call capture_sound_level_cb==%p\n", capture_sound_level_cb); my_process((float *)p,nbytes/sizeof(float), pa_stream_get_sample_spec(s)->channels); -// (*capture_sound_level_cb)(compute_level(p,nbytes), NULL); - //printf("debug : after call capture_sound_level_cb==%p\n", capture_sound_level_cb); pa_stream_drop(s); diff --git a/tests/test5/compute.c b/tests/test5/compute.c index 2658904..3a94efe 100644 --- a/tests/test5/compute.c +++ b/tests/test5/compute.c @@ -9,7 +9,7 @@ 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[MAX_SAMPLES]; + float input[MAX_SAMPLES], output[128]; float level; if (nsamples >= MAX_SAMPLES) { @@ -33,25 +33,23 @@ gfloat compute_level(const float *data, size_t nsamples, size_t nchan) { // printf("\n"); compute_spectrom(input, nsamples, rate, output); - - level=0; - for (i=0;i<nsamples;i++) { + level=0.f; + for (i=1;i<128;i++) { level+=output[i]; - //printf("\r%f ", output[i]); - //fflush(stdout); } - //printf("\n"); - - return level/nsamples; + level/=127.f; + //printf("%f\n", level); + return level; } // From Audacity void compute_spectrom(float * data, int width, double rate, float *output) { int i; - float processed[256]={ 0.0f }; - float in[256]; - float out[256]; + float processed[256]={0.0f}; +//TODO : remove init here + float in[256]={0.0f}; + float out[256]={0.0f}; int start = 0; int windows = 0; @@ -62,7 +60,6 @@ void compute_spectrom(float * data, int width, double rate, float *output) { // Hanning for (i=0; i<256; i++) in[i] *= 0.50 - 0.50 * cos(2 * M_PI * i / (256 - 1)); - break; PowerSpectrum(in, out); @@ -111,7 +108,8 @@ void PowerSpectrum(float *In, float *Out) for (i = 0; i < 128; i++) { tmpReal[i] = In[2 * i]; - tmpImag[i] = In[2 * i + 1]; + tmpImag[i] = In[2 * i + 1]; //FIXME : WTFFFF ? + tmpImag[i]=0; } FFT(128, 0, tmpReal, tmpImag, RealOut, ImagOut); diff --git a/tests/test5/test5.c b/tests/test5/test5.c index 809aaa6..9eadb65 100644 --- a/tests/test5/test5.c +++ b/tests/test5/test5.c @@ -34,7 +34,7 @@ int main (int argc, char **argv) { printf("debug : main my_process==%p\n", my_process); printf("debug : main (void *)my_process==%p\n", (void *)my_process); pthread_create (&audio_analyzer, (void *)NULL, (void *)audio_thread, (void *)my_process); - g_timeout_add (100, win_main_update_vumeters, (gpointer)vals_for_vumeters); + g_timeout_add (25, win_main_update_vumeters, (gpointer)vals_for_vumeters); gtk_main (); gdk_threads_leave(); @@ -49,7 +49,7 @@ void my_process(float *data, size_t nsamples, size_t nchan) { sound_level=compute_level(data, nsamples, nchan); // Update sound vumeter value (refreshed asynchronously) - *audio_vumeter_val=sound_level*65535; + *audio_vumeter_val=((int)sound_level*10.f); // Transfert Function audio2hsv_1(*audio_vumeter_val,light_h,light_s,light_v); diff --git a/tests/test5/win_main.c b/tests/test5/win_main.c index f44c940..66b2c6b 100644 --- a/tests/test5/win_main.c +++ b/tests/test5/win_main.c @@ -23,6 +23,7 @@ GtkWidget *win_main_build() { //TODO : gtk_vumeter_set_min_max (GTK_VU_METER(vumeter), min, max); vumeter_sound = gtk_vu_meter_new (TRUE); + gtk_vu_meter_set_min_max(GTK_VU_METER(vumeter_sound), -600, 0); gtk_box_pack_start(GTK_BOX(hbox1), vumeter_sound, FALSE, FALSE, 0); vumeter_h = gtk_vu_meter_new (TRUE); @@ -60,6 +61,7 @@ GtkWidget *win_main_build() { } gboolean win_main_update_vumeters(gpointer vals) { + printf("%i\n", ((gint*)vals)[0]); gtk_vu_meter_set_level(GTK_VU_METER(vumeter_sound), ((gint*)vals)[0]); gtk_vu_meter_set_level(GTK_VU_METER(vumeter_h), ((gint*)vals)[1]); gtk_vu_meter_set_level(GTK_VU_METER(vumeter_s), ((gint*)vals)[2]); |