summaryrefslogtreecommitdiff
path: root/tests/test4/compute.c
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2012-05-26 17:43:24 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2012-05-26 17:43:24 +0000
commit50d600686c74fe2042d3d653427561b8832d5f70 (patch)
treed7e5378aad0ff54ac693c04d73c206999c8410c2 /tests/test4/compute.c
parenteaf60defac761cd8ff305c3fc3875346ad3478b2 (diff)
download2012-violon-leds-50d600686c74fe2042d3d653427561b8832d5f70.tar.gz
2012-violon-leds-50d600686c74fe2042d3d653427561b8832d5f70.tar.bz2
2012-violon-leds-50d600686c74fe2042d3d653427561b8832d5f70.zip
Ajout vu meters GTK
git-svn-id: file:///var/svn/2012-violon-leds/trunk@5 6be1fa4d-33ac-4c33-becc-79fcb3794bb6
Diffstat (limited to 'tests/test4/compute.c')
-rw-r--r--tests/test4/compute.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test4/compute.c b/tests/test4/compute.c
new file mode 100644
index 0000000..91a5455
--- /dev/null
+++ b/tests/test4/compute.c
@@ -0,0 +1,42 @@
+#include "compute.h"
+
+void function 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; }
+ }
+}