Commit 838c8625 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

got constructor working

parent a11f73ee
...@@ -183,7 +183,18 @@ typedef struct _disis_munger { ...@@ -183,7 +183,18 @@ typedef struct _disis_munger {
int x_discretepan; /* off by default */ int x_discretepan; /* off by default */
} t_disis_munger; } t_disis_munger;
static void *munger_alloc(t_disis_munger *x)
static void float_2d_alloc(t_float ***fp, int nrow, int ncol)
{
int i;
*fp = t_getbytes(nrow * sizeof(t_float*));
for (i = 0; i < nrow; i++)
{
(*fp)[i] = t_getbytes(ncol * sizeof(t_float));
}
}
static t_disis_munger *munger_alloc(t_disis_munger *x)
{ {
/* Heap allocated based on number of voices */ /* Heap allocated based on number of voices */
int nv = x->x_numvoices, nchan = x->x_num_channels; int nv = x->x_numvoices, nchan = x->x_num_channels;
...@@ -214,7 +225,6 @@ static void *munger_alloc(t_disis_munger *x) ...@@ -214,7 +225,6 @@ static void *munger_alloc(t_disis_munger *x)
/* This is its own type */ /* This is its own type */
x->x_gvoiceADSR = (t_stk_ADSR *)t_getbytes(nv * sizeof(t_stk_ADSR)); x->x_gvoiceADSR = (t_stk_ADSR *)t_getbytes(nv * sizeof(t_stk_ADSR));
x->x_gvoiceADSRon = (int *)t_getbytes(nv * sizeof(int)); x->x_gvoiceADSRon = (int *)t_getbytes(nv * sizeof(int));
x->x_noteTransp = (t_float *)t_getbytes(nv * sizeof(t_float)); x->x_noteTransp = (t_float *)t_getbytes(nv * sizeof(t_float));
x->x_noteSize = (t_float *)t_getbytes(nv * sizeof(t_float)); x->x_noteSize = (t_float *)t_getbytes(nv * sizeof(t_float));
...@@ -227,12 +237,9 @@ static void *munger_alloc(t_disis_munger *x) ...@@ -227,12 +237,9 @@ static void *munger_alloc(t_disis_munger *x)
x->x_noteDirection = (int *)t_getbytes(nv * sizeof(int)); x->x_noteDirection = (int *)t_getbytes(nv * sizeof(int));
/* nvoices x nchannels */ /* nvoices x nchannels */
x->x_gvoiceSpat = float_2d_alloc(&x->x_gvoiceSpat, nv, nchan);
(t_float **)t_getbytes(nv * nchan * sizeof(t_float)); float_2d_alloc(&x->x_notechannelGain, nv, nchan);
x->x_notechannelGain = float_2d_alloc(&x->x_notechannelGainSpread, nv, nchan);
(t_float **)t_getbytes(nv * nchan * sizeof(t_float));
x->x_notechannelGainSpread =
(t_float **)t_getbytes(nv * nchan * sizeof(t_float));
/* Heap allocated for signal vector x nchannels */ /* Heap allocated for signal vector x nchannels */
x->x_out = (t_float **)t_getbytes(nchan * sizeof(t_float*)); x->x_out = (t_float **)t_getbytes(nchan * sizeof(t_float*));
...@@ -385,7 +392,6 @@ static void *munger_new(t_symbol *s, int argc, t_atom *argv) ...@@ -385,7 +392,6 @@ static void *munger_new(t_symbol *s, int argc, t_atom *argv)
/* allocate a ton of fields */ /* allocate a ton of fields */
x = munger_alloc(x); x = munger_alloc(x);
/* bail if we couldn't allocate... */ /* bail if we couldn't allocate... */
if (!x) return 0; if (!x) return 0;
...@@ -444,14 +450,12 @@ static void *munger_new(t_symbol *s, int argc, t_atom *argv) ...@@ -444,14 +450,12 @@ static void *munger_new(t_symbol *s, int argc, t_atom *argv)
/* init the stk_ADSR elements */ /* init the stk_ADSR elements */
stk_ADSR_init(&x->x_gvoiceADSR[i]); stk_ADSR_init(&x->x_gvoiceADSR[i]);
stk_ADSR_setSampleRate(&x->x_gvoiceADSR[i], sys_getsr()); stk_ADSR_setSampleRate(&x->x_gvoiceADSR[i], sys_getsr());
for (j = 0; j < x->x_num_channels; j++) for (j = 0; j < x->x_num_channels; j++)
{ {
x->x_gvoiceSpat[i][j] = 0.; x->x_gvoiceSpat[i][j] = 0.;
x->x_notechannelGain[i][j] = 0.; x->x_notechannelGain[i][j] = 0.;
x->x_notechannelGainSpread[i][j] = 0.; x->x_notechannelGainSpread[i][j] = 0.;
} }
//note and oneshot inits //note and oneshot inits
x->x_noteTransp[i] = 0.; x->x_noteTransp[i] = 0.;
x->x_noteSize[i] = 100.; x->x_noteSize[i] = 100.;
...@@ -462,7 +466,6 @@ static void *munger_new(t_symbol *s, int argc, t_atom *argv) ...@@ -462,7 +466,6 @@ static void *munger_new(t_symbol *s, int argc, t_atom *argv)
x->x_noteSustain[i] = 0.3; x->x_noteSustain[i] = 0.3;
x->x_noteRelease[i] = 200.; x->x_noteRelease[i] = 200.;
} }
for (i = 0; i < x->x_num_channels; i++) for (i = 0; i < x->x_num_channels; i++)
{ {
x->x_channelGain[i] = 0.; x->x_channelGain[i] = 0.;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
lib.name = disis lib.name = disis
class.sources = disis_phasor~.c class.sources = disis_phasor~.c
disis_munger~.class.sources = disis_munger.c ADSR.c
define forLinux define forLinux
class.sources += disis_netsend.c disis_netreceive.c class.sources += disis_netsend.c disis_netreceive.c
disis_wiimote.class.sources = disis_wiimote.c disis_wiimote.class.sources = disis_wiimote.c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment