Commit a11f73ee authored by Jonathan Wilkes's avatar Jonathan Wilkes

now it even compiles under the makefile with ADSR.c included... testing time

parent e3fe52f3
#include "ADSR.h"
static t_float stk_ADSR_tick(t_stk_ADSR *x)
t_float stk_ADSR_tick(t_stk_ADSR *x)
{
switch (x->state)
{
case ATTACK:
x->value += x->attackRate;
if (x->value >= target)
if (x->value >= x->target)
{
x->value = x->target;
x->target = x->sustainLevel;
......@@ -15,7 +15,7 @@ static t_float stk_ADSR_tick(t_stk_ADSR *x)
break;
case DECAY:
if (x->x_value > x->sustainLevel)
if (x->value > x->sustainLevel)
{
x->value -= x->decayRate;
if (x->value <= x->sustainLevel)
......@@ -98,7 +98,7 @@ void stk_ADSR_keyOff(t_stk_ADSR *x)
void stk_ADSR_setAttackRate(t_stk_ADSR *x, t_float rate)
{
if (x->rate < 0.0)
if (rate < 0.0)
fprintf(stderr, "stk_ADSR_setAttackRate: argument must be >= 0.0!");
x->attackRate = rate;
}
......@@ -138,13 +138,13 @@ void stk_ADSR_setReleaseRate(t_stk_ADSR *x, t_float rate)
void stk_ADSR_setAttackTime(t_stk_ADSR *x, t_float time)
{
if (x->time <= 0.0)
if (time <= 0.0)
fprintf(stderr,
"ADSR::setAttackTime: negative or zero times not allowed!");
x->attackRate = 1.0 / (time * x->sampleRate);
}
void stk_ADSR_setDecayTime(t_float time)
void stk_ADSR_setDecayTime(t_stk_ADSR *x, t_float time)
{
if (time <= 0.0)
fprintf(stderr,
......@@ -152,7 +152,7 @@ void stk_ADSR_setDecayTime(t_float time)
x->decayRate = (1.0 - x->sustainLevel) / (time * x->sampleRate);
}
void stk_ADSR_setReleaseTime(t_float time)
void stk_ADSR_setReleaseTime(t_stk_ADSR *x, t_float time)
{
if (time <= 0.0)
fprintf(stderr,
......@@ -170,7 +170,7 @@ void stk_ADSR_setAllTimes(t_stk_ADSR *x, t_float aTime, t_float dTime,
stk_ADSR_setReleaseTime(x, rTime);
}
void stk_ADSR_setTarget(stk_ADSR *x, t_float target)
void stk_ADSR_setTarget(t_stk_ADSR *x, t_float target)
{
if (target < 0.0)
fprintf(stderr, "ADSR::setTarget: negative target not allowed!");
......@@ -181,7 +181,7 @@ void stk_ADSR_setTarget(stk_ADSR *x, t_float target)
if (x->value > x->target) x->state = DECAY;
}
void stk_ADSR_setValue(stk_ADSR *x, t_float value)
void stk_ADSR_setValue(t_stk_ADSR *x, t_float value)
{
x->state = SUSTAIN;
x->target = value;
......
#include "m_pd.h"
/* port of stk's ADSR class to C */
/* original class notes */
......@@ -83,7 +85,7 @@ void stk_ADSR_setAllTimes(t_stk_ADSR *x, t_float aTime, t_float dTime,
void stk_ADSR_setTarget(t_stk_ADSR *x, t_float target);
/* Return the current envelope state (ATTACK, DECAY, SUSTAIN, RELEASE, IDLE).*/
int stk_ADSR_getState(t_stk_ADSR *x);
t_env_state stk_ADSR_getState(t_stk_ADSR *x);
/* Set to state = ADSR::SUSTAIN with current and target values of value. */
void stk_ADSR_setValue(t_stk_ADSR *x, t_float value);
......
......@@ -243,7 +243,7 @@ static void *munger_alloc(t_disis_munger *x)
return x;
}
static void *munger_free(t_disis_munger *x)
static void munger_free(t_disis_munger *x)
{
/* Heap allocated based on number of voices */
int nv = x->x_numvoices, nchan = x->x_num_channels;
......@@ -1207,20 +1207,20 @@ static void munger_scale(t_disis_munger *x, t_symbol *s, int argc, t_atom *argv)
for (i = 0; i < PITCHTABLESIZE; i++)
x->x_pitchTable[i] = 0.;
if (argc > PITCHTABLESIZE)
argc = PITCHTABLESIZE;
for (i = 0; i < argc; i++)
{
x->x_pitchTable[i] = atom_getfloatarg(i, argc, argv);
}
x->x_scale_len = argc;
if (argc > PITCHTABLESIZE)
argc = PITCHTABLESIZE;
for (i = 0; i < argc; i++)
{
x->x_pitchTable[i] = atom_getfloatarg(i, argc, argv);
}
x->x_scale_len = argc;
i = 0;
//wrap input list through all of pitchTable
for (j = argc; j < PITCHTABLESIZE; j++) {
x->x_pitchTable[j] = x->x_pitchTable[i++];
if (i >= argc) i = 0;
}
i = 0;
//wrap input list through all of pitchTable
for (j = argc; j < PITCHTABLESIZE; j++) {
x->x_pitchTable[j] = x->x_pitchTable[i++];
if (i >= argc) i = 0;
}
}
static void munger_bufsize(t_disis_munger *x, t_symbol *s, int argc,
......@@ -1357,10 +1357,12 @@ static void munger_setvoices(t_disis_munger *x, t_symbol *s, int argc,
if (temp > x->x_maxvoices)
{
if (x->x_verbose > 0)
{
post("disis_munger~ %s error: voices has to be between "
"0 and maxvoices (currently %d)!",
x->x_munger_name->s_name, x->x_maxvoices);
temp = x->x_maxvoices;
}
temp = x->x_maxvoices;
}
if (x->x_verbose > 1)
post("disis_munger~ %s: setting voices to: %d ",
......@@ -1781,6 +1783,7 @@ static t_int *munger_perform(t_int *w)
}
}
}
return (w + 3 + x->x_num_channels);
}
static void munger_dsp(t_disis_munger *x, t_signal **sp)
......@@ -1826,7 +1829,8 @@ static void munger_dsp(t_disis_munger *x, t_signal **sp)
void disis_munger_tilde_setup(void)
{
disis_munger_class = class_new(gensym("disis_munger~"),
(t_newmethod)munger_new, 0, sizeof(t_disis_munger),
(t_newmethod)munger_new, (t_method)munger_free,
sizeof(t_disis_munger),
CLASS_DEFAULT, A_GIMME, 0);
CLASS_MAINSIGNALIN(disis_munger_class, t_disis_munger, x_f);
class_addmethod(disis_munger_class, (t_method)munger_dsp,
......
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