Enlightenment CVS committal

Author  : tsauerbeck
Project : e17
Module  : apps/euphoria

Dir     : e17/apps/euphoria/src


Modified Files:
        callbacks.c callbacks.h euphoria.c 


Log Message:
added peak analyzer code
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/euphoria/src/callbacks.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- callbacks.c 16 Mar 2004 18:14:34 -0000      1.21
+++ callbacks.c 19 Mar 2004 20:45:22 -0000      1.22
@@ -1,5 +1,5 @@
 /*
- * $Id: callbacks.c,v 1.21 2004/03/16 18:14:34 tsauerbeck Exp $
+ * $Id: callbacks.c,v 1.22 2004/03/19 20:45:22 tsauerbeck Exp $
  * vim:noexpandtab:sw=4:sts=4:ts=4
  */
 
@@ -13,6 +13,9 @@
 #include "utils.h"
 #include "callbacks.h"
 
+#define FFT_BITS 10
+#define FFT_LEN (1 << FFT_BITS)
+
 typedef enum {
        PLAYBACK_STATE_STOPPED,
        PLAYBACK_STATE_PAUSED,
@@ -635,11 +638,34 @@
        if (!(ids = xmmscs_playlist_list(e->xmms)))
                return;
 
-       for (i = 0; ids[i]; i++) {
+       for (i = 0; ids[i]; i++)
                if ((pli = playlist_item_find_by_id(e->playlist, ids[i]))) {
                        e_container_element_remove(pli->container, pli->edje);
                        e_container_element_append(pli->container, pli->edje);
                } else
                        fprintf(stderr, "Unable to find %d: %d\n", i, ids[i]);
+}
+
+XMMS_CB(visdata) {
+       double *input = arg;
+       float spec[FFT_LEN / 2], sum, peak = 0.0;
+       int i, j;
+
+       for (i = 0; i < FFT_LEN / 2; i++)
+               spec[i] = input[i + 1];
+
+       for (i = 0; i < FFT_LEN / 32 / 2; i++) {
+               for (sum = 0.0, j = 0; j < 32; j++)
+                       sum += spec[i * 16 + j];
+
+               if (sum)
+                       sum = log(sum / 32);
+
+               sum = MIN(255, sum * 64);
+               peak = MAX(peak, sum);
        }
+
+       peak = 1 - (peak / 255);
+
+       edje_object_part_drag_value_set(e->gui.edje, "peak_analyzer", 0, peak);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/euphoria/src/callbacks.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- callbacks.h 1 Mar 2004 22:45:36 -0000       1.7
+++ callbacks.h 19 Mar 2004 20:45:22 -0000      1.8
@@ -2,7 +2,7 @@
 #define __CALLBACKS_H
 
 /*
- * $Id: callbacks.h,v 1.7 2004/03/01 22:45:36 atmosphere Exp $
+ * $Id: callbacks.h,v 1.8 2004/03/19 20:45:22 tsauerbeck Exp $
  * vim:noexpandtab:sw=4:sts=4:ts=4
  */
 
@@ -74,6 +74,7 @@
 XMMS_CB(playlist_remove);
 XMMS_CB(playlist_clear);
 XMMS_CB(playlist_shuffle);
+XMMS_CB(visdata);
 
 #endif
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/euphoria/src/euphoria.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- euphoria.c  16 Mar 2004 18:14:34 -0000      1.10
+++ euphoria.c  19 Mar 2004 20:45:22 -0000      1.11
@@ -1,5 +1,5 @@
 /*
- * $Id: euphoria.c,v 1.10 2004/03/16 18:14:34 tsauerbeck Exp $
+ * $Id: euphoria.c,v 1.11 2004/03/19 20:45:22 tsauerbeck Exp $
  * vim:noexpandtab:sw=4:sts=4:ts=4
  */
 
@@ -104,6 +104,8 @@
                           (XmmsCb) on_xmms_playlist_clear, e);
        xmmsc_set_callback(e->xmms, XMMS_SIGNAL_PLAYLIST_SHUFFLE,
                           (XmmsCb) on_xmms_playlist_shuffle, e);
+       xmmsc_set_callback(e->xmms, XMMS_SIGNAL_VISUALISATION_SPECTRUM,
+                          (XmmsCb) on_xmms_visdata, e);
 
        return true;
 }




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to