changeset 171:9e51ffaca177 trunk

[svn] - add OnBeat container. children are only iterated on a detected beat.
author nenolod
date Tue, 31 Oct 2006 23:18:46 -0800
parents 13955c70fbec
children 5ed59f83526f
files ChangeLog src/paranormal/builtins.c src/paranormal/containers.c
diffstat 3 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Oct 31 23:13:49 2006 -0800
+++ b/ChangeLog	Tue Oct 31 23:18:46 2006 -0800
@@ -1,3 +1,14 @@
+2006-11-01 07:13:49 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [340]
+  - split out beat detection code into beatdetect.c
+  
+  trunk/src/paranormal/Makefile     |    1 +
+  trunk/src/paranormal/beatdetect.c |   15 +++++++++++++++
+  trunk/src/paranormal/containers.c |   11 +----------
+  trunk/src/paranormal/paranormal.h |    3 +++
+  4 files changed, 20 insertions(+), 10 deletions(-)
+
+
 2006-11-01 06:55:20 +0000  William Pitcock <nenolod@nenolod.net>
   revision [338]
   - another example preset showing the true power of on-beat branched execution
--- a/src/paranormal/builtins.c	Tue Oct 31 23:13:49 2006 -0800
+++ b/src/paranormal/builtins.c	Tue Oct 31 23:18:46 2006 -0800
@@ -11,6 +11,7 @@
 DECLARE_ACTUATOR (container_simple);
 DECLARE_ACTUATOR (container_once);
 DECLARE_ACTUATOR (container_cycle);
+DECLARE_ACTUATOR (container_onbeat);
 
 /* **************** cmaps **************** */
 
@@ -44,6 +45,8 @@
   &builtin_container_simple,
   &builtin_container_once,
   &builtin_container_cycle,
+  &builtin_container_onbeat,
+
   /* **************** cmaps **************** */
   &builtin_cmap_bwgradient,
   &builtin_cmap_gradient,
--- a/src/paranormal/containers.c	Tue Oct 31 23:13:49 2006 -0800
+++ b/src/paranormal/containers.c	Tue Oct 31 23:18:46 2006 -0800
@@ -211,3 +211,41 @@
   ACTUATOR_FLAG_CONTAINER, container_cycle_opts,
   container_cycle_init, container_cycle_cleanup, container_cycle_exec
 };
+
+/* **************** container_onbeat **************** */
+static void
+container_onbeat_init (GSList ***data)
+{
+  *data = g_new0 (GSList *, 1);
+}
+
+static void
+container_onbeat_cleanup (GSList **data)
+{
+  container_cleanup (data);
+  g_free (data);
+}
+
+static void
+container_onbeat_exec (const struct pn_actuator_option *opts,
+		     GSList **data)
+{
+  GSList *child;
+
+  if (pn_is_new_beat() == TRUE)
+    {
+      for (child = *data; child; child = child->next)
+        exec_actuator ((struct pn_actuator *) child->data);
+    }
+}
+
+struct pn_actuator_desc builtin_container_onbeat =
+{
+  "container_onbeat",
+  "OnBeat Container",
+  "A simple container which only triggers on a beat."
+  ACTUATOR_FLAG_CONTAINER, NULL,
+  PN_ACTUATOR_INIT_FUNC (container_onbeat_init),
+  PN_ACTUATOR_CLEANUP_FUNC (container_onbeat_cleanup),
+  PN_ACTUATOR_EXEC_FUNC (container_onbeat_exec)
+};