Browse Source

implement CV and control trigger

master
Alexandros Theodotou 3 years ago
parent
commit
cef7f883d2
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 12
      src/zlfo.c
  2. 35
      src/zlfo_math.h
  3. 2
      src/zlfo_ttl_gen.c

12
src/zlfo.c

@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
#define IS_FREERUN(x) (*x->freerun > 0.001f)
#define IS_STEP_MODE(x) (*x->step_mode > 0.001f)
#define IS_TRIGGERED(x) (*x->trigger > 0.001f)
typedef struct ZLFO
{
@ -489,6 +490,17 @@ run ( @@ -489,6 +490,17 @@ run (
((float) self->common.period_size /
grid_step_divisor);
/* handle triggers
*
* FIXME CV trigger requires splitting the cycle,
* but for now it applies to the whole cycle */
if (IS_TRIGGERED (self) ||
float_array_contains_nonzero (
self->cv_trigger, n_samples))
{
self->common.current_sample = 0;
}
for (uint32_t i = 0; i < n_samples; i++)
{
/* invert horizontally */

35
src/zlfo_math.h

@ -254,17 +254,18 @@ get_current_sample ( @@ -254,17 +254,18 @@ get_current_sample (
HostPosition * host_pos,
uint32_t period_size)
{
/* if beat_unit is 0 that means we don't know the
* time info yet */
if (freerunning || host_pos->beat_unit == 0)
if (freerunning)
{
if (!freerunning && host_pos->beat_unit == 0)
{
fprintf (
stderr,
"Host did not send time info. Beat "
"unit is unknown.\n");
}
return 0;
}
else if (host_pos->beat_unit == 0)
{
/* if beat_unit is 0 that means we don't
* know the time info yet */
fprintf (
stderr,
"Host did not send time info. Beat "
"unit is unknown.\n");
return 0;
}
else /* synced */
@ -273,6 +274,20 @@ get_current_sample ( @@ -273,6 +274,20 @@ get_current_sample (
}
}
static inline int
float_array_contains_nonzero (
const float * arr,
size_t size)
{
for (size_t i = 0; i < size; i++)
{
if (arr[i] > 0.0001f ||
arr[i] < - 0.0001f)
return 1;
}
return 0;
}
/**
* @param sine_multipler Position to save the sine
* multiplier in.

2
src/zlfo_ttl_gen.c

@ -122,7 +122,7 @@ int main ( @@ -122,7 +122,7 @@ int main (
lv2:default %f ;\n\
lv2:minimum %f ;\n\
lv2:maximum %f ;\n\
] , [\n", 0.0, -1.0, 1.0, 0.0, -1.0, 1.0);
] , [\n", 0.0, 0.0, 1.0, 0.0, 0.0, 1.0);
/* write input controls */
int index = ZLFO_GATE;

Loading…
Cancel
Save