aboutsummaryrefslogtreecommitdiff
path: root/cyclone/sickle
diff options
context:
space:
mode:
Diffstat (limited to 'cyclone/sickle')
-rw-r--r--cyclone/sickle/cycle.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/cyclone/sickle/cycle.c b/cyclone/sickle/cycle.c
index b88c13e..8acb364 100644
--- a/cyclone/sickle/cycle.c
+++ b/cyclone/sickle/cycle.c
@@ -31,24 +31,37 @@ static void cycle_gettable(t_cycle *x)
if (x->x_name)
{
int tabsize = 0;
- t_float *table = vefl_get(x->x_name, &tabsize, 1, (t_pd *)x);
+ t_word *table = vefl_get(x->x_name, &tabsize, 1, (t_pd *)x);
/* CHECKED buffer is copied */
if (table)
{
- int indx = x->x_offset + CYCLE_TABSIZE;
- t_float *ptr = x->x_usertable + CYCLE_TABSIZE;
- if (indx == tabsize)
+ int tablePtr;
+ int samplesFromTable = tabsize - x->x_offset;
+ int samplesToCopy = samplesFromTable < CYCLE_TABSIZE ?
+ samplesFromTable : CYCLE_TABSIZE;
+
+// post("samplesFromTable: %d, samplesToCopy: %d, tabsize: %d",
+// samplesFromTable, samplesToCopy, tabsize);
+ // copy the internal table from the external one as far as
+ // its size permits and fill the rest with zeroes.
+ for (tablePtr = 0; tablePtr < CYCLE_TABSIZE; tablePtr++)
{
- *ptr-- = *table;
- indx--;
- }
- if (indx < tabsize)
- {
- table += indx;
- indx -= x->x_offset;
- while (indx--) *ptr-- = *table--;
- x->x_table = x->x_usertable;
+ if (samplesToCopy > 0)
+ {
+ x->x_usertable[tablePtr] =
+ table[tablePtr + x->x_offset].w_float;
+ samplesToCopy--;
+ }
+ else
+ {
+ x->x_usertable[tablePtr] = 0;
+ }
}
+ // the 513th sample
+ x->x_usertable[tablePtr] = (samplesFromTable > 0) ?
+ table[x->x_offset + CYCLE_TABSIZE].w_float : 0;
+
+ x->x_table = x->x_usertable;
/* CHECKED else no complaint */
}
}