# HG changeset patch # User nenolod # Date 1162365526 28800 # Node ID 9e51ffaca177c5613f57d7a9c6422794b38809e0 # Parent 13955c70fbec44cbf3c8dbd141bf1c7575fcc676 [svn] - add OnBeat container. children are only iterated on a detected beat. diff -r 13955c70fbec -r 9e51ffaca177 ChangeLog --- 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 + 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 revision [338] - another example preset showing the true power of on-beat branched execution diff -r 13955c70fbec -r 9e51ffaca177 src/paranormal/builtins.c --- 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, diff -r 13955c70fbec -r 9e51ffaca177 src/paranormal/containers.c --- 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) +};