aboutsummaryrefslogtreecommitdiff
path: root/router_audio_sprinkler.c
diff options
context:
space:
mode:
Diffstat (limited to 'router_audio_sprinkler.c')
-rw-r--r--router_audio_sprinkler.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/router_audio_sprinkler.c b/router_audio_sprinkler.c
index 7558645..4c4ecf2 100644
--- a/router_audio_sprinkler.c
+++ b/router_audio_sprinkler.c
@@ -24,7 +24,7 @@
#define MAX_NOUTS 8
#define MAX_NMULT 2
-#define MAX_NPROPS 5
+#define MAX_NPROPS 6
typedef struct _plugstate_t plugstate_t;
typedef struct _plughandle_t plughandle_t;
@@ -32,6 +32,7 @@ typedef struct _plughandle_t plughandle_t;
struct _plugstate_t {
int32_t next_index;
int32_t prev_index;
+ int32_t roll_under_index;
int32_t roll_over_index;
int32_t current_index;
float switch_period;
@@ -78,7 +79,7 @@ _intercept_next_index(void *data, int64_t frames,
handle->state.current_index += 1;
if(handle->state.current_index > handle->state.roll_over_index)
- handle->state.current_index = 1;
+ handle->state.current_index = handle->state.roll_under_index;
props_set(&handle->props, &handle->notify.forge, frames,
handle->urid.sprinkler_nextIndex, &handle->notify.ref);
@@ -98,7 +99,7 @@ _intercept_prev_index(void *data, int64_t frames,
handle->state.prev_index = false;
handle->state.current_index -= 1;
- if(handle->state.current_index < 1)
+ if(handle->state.current_index < handle->state.roll_under_index)
handle->state.current_index = handle->state.roll_over_index;
props_set(&handle->props, &handle->notify.forge, frames,
@@ -109,6 +110,21 @@ _intercept_prev_index(void *data, int64_t frames,
}
static void
+_intercept_roll_under_index(void *data, int64_t frames,
+ props_impl_t *impl __attribute__((unused)))
+{
+ plughandle_t *handle = data;
+
+ if(handle->state.current_index < handle->state.roll_under_index)
+ {
+ handle->state.current_index = handle->state.roll_over_index;
+
+ props_set(&handle->props, &handle->notify.forge, frames,
+ handle->urid.sprinkler_currentIndex, &handle->notify.ref);
+ }
+}
+
+static void
_intercept_roll_over_index(void *data, int64_t frames,
props_impl_t *impl __attribute__((unused)))
{
@@ -116,7 +132,7 @@ _intercept_roll_over_index(void *data, int64_t frames,
if(handle->state.current_index > handle->state.roll_over_index)
{
- handle->state.current_index = 1;
+ handle->state.current_index = handle->state.roll_under_index;
props_set(&handle->props, &handle->notify.forge, frames,
handle->urid.sprinkler_currentIndex, &handle->notify.ref);
@@ -136,6 +152,13 @@ _intercept_current_index(void *data, int64_t frames,
props_set(&handle->props, &handle->notify.forge, frames,
handle->urid.sprinkler_currentIndex, &handle->notify.ref);
}
+ else if(handle->state.current_index < handle->state.roll_under_index)
+ {
+ handle->state.current_index = handle->state.roll_under_index;
+
+ props_set(&handle->props, &handle->notify.forge, frames,
+ handle->urid.sprinkler_currentIndex, &handle->notify.ref);
+ }
}
static void
@@ -163,6 +186,12 @@ static const props_def_t defs [MAX_NPROPS] = {
.event_cb = _intercept_prev_index
},
{
+ .property = ROUTER__rollUnderIndex,
+ .offset = offsetof(plugstate_t, roll_under_index),
+ .type = LV2_ATOM__Int,
+ .event_cb = _intercept_roll_under_index
+ },
+ {
.property = ROUTER__rollOverIndex,
.offset = offsetof(plugstate_t, roll_over_index),
.type = LV2_ATOM__Int,