summaryrefslogtreecommitdiff
path: root/tests/test4/test4.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test4/test4.c')
-rw-r--r--tests/test4/test4.c56
1 files changed, 45 insertions, 11 deletions
diff --git a/tests/test4/test4.c b/tests/test4/test4.c
index e5bca86..787f7c2 100644
--- a/tests/test4/test4.c
+++ b/tests/test4/test4.c
@@ -1,22 +1,56 @@
#include <gtk/gtk.h>
-//#include <locale.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include "gtkvumeter.h"
+#include "win_main.h"
+#include "compute.h"
+
+void audio_thread(void *args) {
+ gint min=-32767, max=32767;
+ gint *audio_vumeter_val=((gint*)args)+0;
+ gint *light_h=((gint*)args)+1;
+ gint *light_s=((gint*)args)+2;
+ gint *light_v=((gint*)args)+3;
+ gint *light_r=((gint*)args)+4;
+ gint *light_g=((gint*)args)+5;
+ gint *light_b=((gint*)args)+6;
+
+ while(1) {
+ // Dummy code for audio capture
+ *audio_vumeter_val=min+rand()/(float)RAND_MAX*(max-min);
+ usleep(10);
+
+ // Transfert Function
+ audio2hsv_1(*audio_vumeter_val,*light_h,*light_s,*light_v);
+
+ // Conversion
+ hsv2rgb(*light_h,*light_s,*light_v,light_r,light_g,light_b);
+
+ // Send to DMX
+ //TODO
+ }
+}
int main (int argc, char **argv)
{
GtkWidget *mainwin;
+ gint vals_for_vumeters[7]={0,0,0,0,0,0}; //sound,h,s,v,r,g,b
- /* Initialize i18n support */
- //setlocale(LC_ALL, ""); //(implicite)
- /* Initialize the widget set */
+ pthread_t audio_analyzer;
+
+ g_thread_init(NULL);
+ gdk_threads_init();
+ gdk_threads_enter();
gtk_init (&argc, &argv);
- /* Create the main window */
- mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- /* Set up our GUI elements */
- //...
- /* Show the application window */
+
+ mainwin=win_main_build();
gtk_widget_show_all (mainwin);
- /* Enter the main event loop, and wait for user interaction */
+
+ pthread_create (&audio_analyzer, (void *)NULL, (void *)audio_thread, (void *)vals_for_vumeters);
+ g_timeout_add (33, win_main_update_vumeters, (gpointer)vals_for_vumeters);
+
gtk_main ();
- /* The user lost interest */
+ gdk_threads_leave();
+
return 0;
}