Discrete emulation

- added node parameter to RC_(DIS)CHARGE_EXP
- added const where appropriate
- removed some dead code
This commit is contained in:
Couriersud 2009-09-06 19:53:02 +00:00
parent c15bc6c38b
commit 1b22c69b58
9 changed files with 96 additions and 105 deletions

View File

@ -255,9 +255,9 @@ static DISCRETE_STEP(dsd_555_astbl)
context->t_rc_bleed = DSD_555_ASTBL_T_RC_BLEED;
context->t_rc_charge = DSD_555_ASTBL_T_RC_CHARGE;
context->t_rc_discharge = DSD_555_ASTBL_T_RC_DISCHARGE;
context->exp_bleed = RC_CHARGE_EXP(context->t_rc_bleed);
context->exp_charge = RC_CHARGE_EXP(context->t_rc_charge);
context->exp_discharge = RC_CHARGE_EXP(context->t_rc_discharge);
context->exp_bleed = RC_CHARGE_EXP(node, context->t_rc_bleed);
context->exp_charge = RC_CHARGE_EXP(node, context->t_rc_charge);
context->exp_discharge = RC_CHARGE_EXP(node, context->t_rc_discharge);
context->last_r1 = DSD_555_ASTBL__R1;
context->last_r2 = DSD_555_ASTBL__R2;
context->last_c = DSD_555_ASTBL__C;
@ -418,11 +418,11 @@ static DISCRETE_RESET(dsd_555_astbl)
else
{
context->t_rc_bleed = DSD_555_ASTBL_T_RC_BLEED;
context->exp_bleed = RC_CHARGE_EXP(context->t_rc_bleed);
context->exp_bleed = RC_CHARGE_EXP(node, context->t_rc_bleed);
context->t_rc_charge = DSD_555_ASTBL_T_RC_CHARGE;
context->exp_charge = RC_CHARGE_EXP(context->t_rc_charge);
context->exp_charge = RC_CHARGE_EXP(node, context->t_rc_charge);
context->t_rc_discharge = DSD_555_ASTBL_T_RC_DISCHARGE;
context->exp_discharge = RC_CHARGE_EXP(context->t_rc_discharge);
context->exp_discharge = RC_CHARGE_EXP(node, context->t_rc_discharge);
}
context->output_is_ac = info->options & DISC_555_OUT_AC;
@ -506,7 +506,7 @@ static DISCRETE_STEP(dsd_555_mstbl)
else
{
/* Charging */
v_cap_next = v_cap + ((info->v_pos - v_cap) * RC_CHARGE_EXP(DSD_555_MSTBL__R * DSD_555_MSTBL__C));
v_cap_next = v_cap + ((info->v_pos - v_cap) * RC_CHARGE_EXP(node, DSD_555_MSTBL__R * DSD_555_MSTBL__C));
/* Has it charged past upper limit? */
/* If trigger is still enabled, then we keep charging,
@ -994,15 +994,15 @@ static DISCRETE_RESET(dsd_555_cc)
break;
}
context->exp_bleed = RC_CHARGE_EXP(DSD_555_CC_T_RC_BLEED);
context->exp_bleed = RC_CHARGE_EXP(node, DSD_555_CC_T_RC_BLEED);
context->t_rc_discharge_01 = DSD_555_CC_T_RC_DISCHARGE_01;
context->exp_discharge_01 = RC_CHARGE_EXP(context->t_rc_discharge_01);
context->exp_discharge_01 = RC_CHARGE_EXP(node, context->t_rc_discharge_01);
context->t_rc_discharge_no_i = DSD_555_CC_T_RC_DISCHARGE_NO_I;
context->exp_discharge_no_i = RC_CHARGE_EXP(context->t_rc_discharge_no_i);
context->exp_discharge_no_i = RC_CHARGE_EXP(node, context->t_rc_discharge_no_i);
context->t_rc_charge = DSD_555_CC_T_RC_CHARGE;
context->exp_charge = RC_CHARGE_EXP(context->t_rc_charge);
context->exp_charge = RC_CHARGE_EXP(node, context->t_rc_charge);
context->t_rc_discharge = DSD_555_CC_T_RC_DISCHARGE;
context->exp_discharge = RC_CHARGE_EXP(context->t_rc_discharge);
context->exp_discharge = RC_CHARGE_EXP(node, context->t_rc_discharge);
}
/* Step to set the output */

View File

@ -162,7 +162,7 @@ static DISCRETE_RESET(dst_crfilter)
{
struct dst_rcfilter_context *context = (struct dst_rcfilter_context *)node->context;
context->exponent = RC_CHARGE_EXP(DST_CRFILTER__R * DST_CRFILTER__C);
context->exponent = RC_CHARGE_EXP(node, DST_CRFILTER__R * DST_CRFILTER__C);
context->vCap = 0;
node->output[0] = DST_CRFILTER__IN;
}
@ -491,16 +491,16 @@ static DISCRETE_RESET(dst_op_amp_filt)
{
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1:
case DISC_OP_AMP_FILTER_IS_LOW_PASS_1M:
context->exponentC1 = RC_CHARGE_EXP(info->rF * info->c1);
context->exponentC1 = RC_CHARGE_EXP(node, info->rF * info->c1);
context->exponentC2 = 0;
break;
case DISC_OP_AMP_FILTER_IS_HIGH_PASS_1:
context->exponentC1 = RC_CHARGE_EXP(context->rTotal * info->c1);
context->exponentC1 = RC_CHARGE_EXP(node, context->rTotal * info->c1);
context->exponentC2 = 0;
break;
case DISC_OP_AMP_FILTER_IS_BAND_PASS_1:
context->exponentC1 = RC_CHARGE_EXP(info->rF * info->c1);
context->exponentC2 = RC_CHARGE_EXP(context->rTotal * info->c2);
context->exponentC1 = RC_CHARGE_EXP(node, info->rF * info->c1);
context->exponentC2 = RC_CHARGE_EXP(node, context->rTotal * info->c2);
break;
case DISC_OP_AMP_FILTER_IS_BAND_PASS_1M | DISC_OP_AMP_IS_NORTON:
context->rTotal = 1.0 / (1.0 / info->r1 + 1.0 / info->r2);
@ -525,12 +525,12 @@ static DISCRETE_RESET(dst_op_amp_filt)
break;
}
case DISC_OP_AMP_FILTER_IS_BAND_PASS_0 | DISC_OP_AMP_IS_NORTON:
context->exponentC1 = RC_CHARGE_EXP(RES_2_PARALLEL(info->r1, info->r2 + info->r3 + info->r4) * info->c1);
context->exponentC2 = RC_CHARGE_EXP(RES_2_PARALLEL(info->r1 + info->r2, info->r3 + info->r4) * info->c2);
context->exponentC3 = RC_CHARGE_EXP((info->r1 + info->r2 + info->r3 + info->r4) * info->c3);
context->exponentC1 = RC_CHARGE_EXP(node, RES_2_PARALLEL(info->r1, info->r2 + info->r3 + info->r4) * info->c1);
context->exponentC2 = RC_CHARGE_EXP(node, RES_2_PARALLEL(info->r1 + info->r2, info->r3 + info->r4) * info->c2);
context->exponentC3 = RC_CHARGE_EXP(node, (info->r1 + info->r2 + info->r3 + info->r4) * info->c3);
break;
case DISC_OP_AMP_FILTER_IS_HIGH_PASS_0 | DISC_OP_AMP_IS_NORTON:
context->exponentC1 = RC_CHARGE_EXP(info->r1 * info->c1);
context->exponentC1 = RC_CHARGE_EXP(node, info->r1 * info->c1);
break;
}
@ -641,8 +641,8 @@ static DISCRETE_RESET(dst_rcdisc2)
context->state = 0;
context->t = 0;
context->exponent0 = RC_DISCHARGE_EXP(DST_RCDISC2__R0 * DST_RCDISC2__C);
context->exponent1 = RC_DISCHARGE_EXP(DST_RCDISC2__R1 * DST_RCDISC2__C);
context->exponent0 = RC_DISCHARGE_EXP(node, DST_RCDISC2__R0 * DST_RCDISC2__C);
context->exponent1 = RC_DISCHARGE_EXP(node, DST_RCDISC2__R1 * DST_RCDISC2__C);
}
/************************************************************************
@ -723,8 +723,8 @@ static DISCRETE_RESET(dst_rcdisc3)
context->state = 0;
context->t = 0;
context->v_diode = DST_RCDISC3__DJV;
context->exponent0 = RC_CHARGE_EXP(DST_RCDISC3__R1 * DST_RCDISC3__C);
context->exponent1 = RC_CHARGE_EXP(RES_2_PARALLEL(DST_RCDISC3__R1, DST_RCDISC3__R2) * DST_RCDISC3__C);
context->exponent0 = RC_CHARGE_EXP(node, DST_RCDISC3__R1 * DST_RCDISC3__C);
context->exponent1 = RC_CHARGE_EXP(node, RES_2_PARALLEL(DST_RCDISC3__R1, DST_RCDISC3__R2) * DST_RCDISC3__C);
}
@ -820,14 +820,14 @@ static DISCRETE_RESET( dst_rcdisc4)
i = v / rT;
context->v[1] = i * r + .5;
rT = RES_2_PARALLEL(DST_RCDISC4__R2, r);
context->exp[1] = RC_CHARGE_EXP(rT * DST_RCDISC4__C1);
context->exp[1] = RC_CHARGE_EXP(node, rT * DST_RCDISC4__C1);
/* When the input is 0, R1 is out of circuit. */
rT = DST_RCDISC4__R2 + DST_RCDISC4__R3;
i = v / rT;
context->v[0] = i * DST_RCDISC4__R3 + .5;
rT = RES_2_PARALLEL(DST_RCDISC4__R2, DST_RCDISC4__R3);
context->exp[0] = RC_CHARGE_EXP(rT * DST_RCDISC4__C1);
context->exp[0] = RC_CHARGE_EXP(node, rT * DST_RCDISC4__C1);
break;
case 3:
@ -838,11 +838,11 @@ static DISCRETE_RESET( dst_rcdisc4)
r = 500.0 + DST_RCDISC4__R1;
context->v[1] = RES_VOLTAGE_DIVIDER(r, DST_RCDISC4__R2) * (5.0 - 0.5);
rT = RES_2_PARALLEL(r, DST_RCDISC4__R2);
context->exp[1] = RC_CHARGE_EXP(rT * DST_RCDISC4__C1);
context->exp[1] = RC_CHARGE_EXP(node, rT * DST_RCDISC4__C1);
/* When the input is 0, R1 is out of circuit. */
context->v[0] = 0;
context->exp[0] = RC_CHARGE_EXP(DST_RCDISC4__R2 * DST_RCDISC4__C1);
context->exp[0] = RC_CHARGE_EXP(node, DST_RCDISC4__R2 * DST_RCDISC4__C1);
break;
}
}
@ -902,7 +902,7 @@ static DISCRETE_RESET( dst_rcdisc5)
context->state = 0;
context->t = 0;
context->v_cap = 0;
context->exponent0 = RC_CHARGE_EXP(DST_RCDISC5__R * DST_RCDISC5__C);
context->exponent0 = RC_CHARGE_EXP(node, DST_RCDISC5__R * DST_RCDISC5__C);
}
@ -975,28 +975,28 @@ static DISCRETE_RESET(dst_rcdisc_mod)
/* DST_RCDISC_MOD__IN1 <= 0.5 */
rc[0] = DST_RCDISC_MOD__R1 + DST_RCDISC_MOD__R2;
if (rc[0] < 1) rc[0] = 1;
context->exp_low[0] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * rc[0]);
context->exp_low[0] = RC_DISCHARGE_EXP(node, DST_RCDISC_MOD__C * rc[0]);
context->gain[0] = RES_VOLTAGE_DIVIDER(rc[0], DST_RCDISC_MOD__R4);
/* DST_RCDISC_MOD__IN1 > 0.5 */
rc[1] = DST_RCDISC_MOD__R2;
if (rc[1] < 1) rc[1] = 1;
context->exp_low[1] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * rc[1]);
context->exp_low[1] = RC_DISCHARGE_EXP(node, DST_RCDISC_MOD__C * rc[1]);
context->gain[1] = RES_VOLTAGE_DIVIDER(rc[1], DST_RCDISC_MOD__R4);
/* DST_RCDISC_MOD__IN2 <= 0.6 */
rc2[0] = DST_RCDISC_MOD__R4;
/* DST_RCDISC_MOD__IN2 > 0.6 */
rc2[1] = RES_2_PARALLEL(DST_RCDISC_MOD__R3, DST_RCDISC_MOD__R4);
/* DST_RCDISC_MOD__IN1 <= 0.5 && DST_RCDISC_MOD__IN2 <= 0.6 */
context->exp_high[0] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[0] + rc2[0]));
context->exp_high[0] = RC_DISCHARGE_EXP(node, DST_RCDISC_MOD__C * (rc[0] + rc2[0]));
context->vd_gain[0] = RES_VOLTAGE_DIVIDER(rc[0], rc2[0]);
/* DST_RCDISC_MOD__IN1 > 0.5 && DST_RCDISC_MOD__IN2 <= 0.6 */
context->exp_high[1] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[1] + rc2[0]));
context->exp_high[1] = RC_DISCHARGE_EXP(node, DST_RCDISC_MOD__C * (rc[1] + rc2[0]));
context->vd_gain[1] = RES_VOLTAGE_DIVIDER(rc[1], rc2[0]);
/* DST_RCDISC_MOD__IN1 <= 0.5 && DST_RCDISC_MOD__IN2 > 0.6 */
context->exp_high[2] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[0] + rc2[1]));
context->exp_high[2] = RC_DISCHARGE_EXP(node, DST_RCDISC_MOD__C * (rc[0] + rc2[1]));
context->vd_gain[2] = RES_VOLTAGE_DIVIDER(rc[0], rc2[1]);
/* DST_RCDISC_MOD__IN1 > 0.5 && DST_RCDISC_MOD__IN2 > 0.6 */
context->exp_high[3] = RC_DISCHARGE_EXP(DST_RCDISC_MOD__C * (rc[1] + rc2[1]));
context->exp_high[3] = RC_DISCHARGE_EXP(node, DST_RCDISC_MOD__C * (rc[1] + rc2[1]));
context->vd_gain[3] = RES_VOLTAGE_DIVIDER(rc[1], rc2[1]);
context->v_cap = 0;
@ -1043,7 +1043,7 @@ static DISCRETE_RESET(dst_rcfilter)
{
struct dst_rcfilter_context *context = (struct dst_rcfilter_context *)node->context;
context->exponent = RC_CHARGE_EXP(DST_RCFILTER__R * DST_RCFILTER__C);
context->exponent = RC_CHARGE_EXP(node, DST_RCFILTER__R * DST_RCFILTER__C);
context->vCap = 0;
node->output[0] = 0;
}
@ -1128,7 +1128,7 @@ static DISCRETE_RESET(dst_rcfilter_sw)
for (i = 0; i < 4; i++)
{
context->vCap[i] = 0;
context->exp[i] = RC_CHARGE_EXP( CD4066_ON_RES * DST_RCFILTER_SW__C(i));
context->exp[i] = RC_CHARGE_EXP(node, CD4066_ON_RES * DST_RCFILTER_SW__C(i));
}
for (bits=0; bits < 15; bits++)
@ -1146,8 +1146,8 @@ static DISCRETE_RESET(dst_rcfilter_sw)
/* fast cases */
context->exp0 = RC_CHARGE_EXP((CD4066_ON_RES + DST_RCFILTER_SW__R) * DST_RCFILTER_SW__C(0));
context->exp1 = RC_CHARGE_EXP((CD4066_ON_RES + DST_RCFILTER_SW__R) * DST_RCFILTER_SW__C(1));
context->exp0 = RC_CHARGE_EXP(node, (CD4066_ON_RES + DST_RCFILTER_SW__R) * DST_RCFILTER_SW__C(0));
context->exp1 = RC_CHARGE_EXP(node, (CD4066_ON_RES + DST_RCFILTER_SW__R) * DST_RCFILTER_SW__C(1));
context->factor = RES_VOLTAGE_DIVIDER(DST_RCFILTER_SW__R, CD4066_ON_RES);
node->output[0] = 0;

View File

@ -327,7 +327,7 @@ static DISCRETE_START(dss_input_stream)
if (node->block->type == DSS_INPUT_BUFFER)
{
context->is_buffered = TRUE;
context->buffer_stream = stream_create(node->info->device, 0, 1, node->info->sample_rate, node, buffer_stream_update);
context->buffer_stream = stream_create(node->info->device, 0, 1, node->info->sample_rate, (void *) node, buffer_stream_update);
stream_set_input(node->info->discrete_stream, context->stream_in_number,
context->buffer_stream, 0, 1.0);

View File

@ -411,7 +411,7 @@ static DISCRETE_RESET(dst_dac_r1)
if (info->cFilter)
{
/* Setup filter constants */
context->exponent = RC_CHARGE_EXP(context->r_total * info->cFilter);
context->exponent = RC_CHARGE_EXP(node, context->r_total * info->cFilter);
}
}
@ -1138,7 +1138,7 @@ static DISCRETE_STEP(dst_mixer)
/* Re-calculate exponent if resistor is a node and has changed value */
if (*context->r_node[bit] != context->r_last[bit])
{
context->exponent_rc[bit] = RC_CHARGE_EXP(rTemp2 * info->c[bit]);
context->exponent_rc[bit] = RC_CHARGE_EXP(node, rTemp2 * info->c[bit]);
context->r_last[bit] = *context->r_node[bit];
}
}
@ -1194,7 +1194,7 @@ static DISCRETE_STEP(dst_mixer)
if (r_node_bit_flag != 0)
{
/* Re-calculate exponent if resistor nodes are used */
context->exponent_c_f = RC_CHARGE_EXP(r_total * info->cF);
context->exponent_c_f = RC_CHARGE_EXP(node, r_total * info->cF);
}
context->v_cap_f += (v - v_ref - context->v_cap_f) * context->exponent_c_f;
v = context->v_cap_f;
@ -1288,7 +1288,7 @@ static DISCRETE_RESET(dst_mixer)
break;
}
/* Setup filter constants */
context->exponent_rc[bit] = RC_CHARGE_EXP(rTemp * info->c[bit]);
context->exponent_rc[bit] = RC_CHARGE_EXP(node, rTemp * info->c[bit]);
}
}
@ -1303,7 +1303,7 @@ static DISCRETE_RESET(dst_mixer)
if (info->cF != 0)
{
/* Setup filter constants */
context->exponent_c_f = RC_CHARGE_EXP(((info->type == DISC_MIXER_IS_OP_AMP) ? info->rF : (1.0 / context->r_total)) * info->cF);
context->exponent_c_f = RC_CHARGE_EXP(node, ((info->type == DISC_MIXER_IS_OP_AMP) ? info->rF : (1.0 / context->r_total)) * info->cF);
}
context->v_cap_amp = 0;
@ -1313,7 +1313,7 @@ static DISCRETE_RESET(dst_mixer)
/* Setup filter constants */
/* We will use 100k ohms as an average final stage impedance. */
/* Your amp/speaker system will have more effect on incorrect filtering then any value used here. */
context->exponent_c_amp = RC_CHARGE_EXP(RES_K(100) * info->cAmp);
context->exponent_c_amp = RC_CHARGE_EXP(node, RES_K(100) * info->cAmp);
}
if (context->type == DISC_MIXER_IS_OP_AMP_WITH_RI) context->gain = info->rF / info->rI;
@ -1864,7 +1864,7 @@ static DISCRETE_RESET(dst_op_amp)
if (context->has_r4)
{
/* exponential charge */
context->exponent = RC_CHARGE_EXP(info->r4 * info->c);
context->exponent = RC_CHARGE_EXP(node, info->r4 * info->c);
}
else
/* linear charge */
@ -1935,9 +1935,9 @@ static DISCRETE_RESET(dst_op_amp_1sht)
const discrete_op_amp_1sht_info *info = (const discrete_op_amp_1sht_info *)node->custom;
struct dst_op_amp_1sht_context *context = (struct dst_op_amp_1sht_context *)node->context;
context->exponent1c = RC_CHARGE_EXP(RES_2_PARALLEL(info->r3, info->r4) * info->c1);
context->exponent1d = RC_CHARGE_EXP(info->r4 * info->c1);
context->exponent2 = RC_CHARGE_EXP(info->r2 * info->c2);
context->exponent1c = RC_CHARGE_EXP(node, RES_2_PARALLEL(info->r3, info->r4) * info->c1);
context->exponent1d = RC_CHARGE_EXP(node, info->r4 * info->c1);
context->exponent2 = RC_CHARGE_EXP(node, info->r2 * info->c2);
context->i_fixed = (info->vP - OP_AMP_NORTON_VBE) / info->r1;
context->v_cap1 = context->v_cap2 = 0;
context->v_max = info->vP - OP_AMP_NORTON_VBE;
@ -2062,23 +2062,23 @@ static DISCRETE_RESET(dst_tvca_op_amp)
context->v_cap1 = 0;
/* Charge rate thru r5 */
/* There can be a different charge rates depending on function F3. */
context->exponent_c[0] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r5, info->r6) * info->c1);
context->exponent_c[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r5, context->r67) * info->c1);
context->exponent_c[0] = RC_CHARGE_EXP(node, RES_2_PARALLEL(info->r5, info->r6) * info->c1);
context->exponent_c[1] = RC_CHARGE_EXP(node, RES_2_PARALLEL(info->r5, context->r67) * info->c1);
/* Discharge rate thru r6 + r7 */
context->exponent_d[1] = RC_CHARGE_EXP(context->r67 * info->c1);
context->exponent_d[1] = RC_CHARGE_EXP(node, context->r67 * info->c1);
/* Discharge rate thru r6 */
if (info->r6 != 0)
{
context->exponent_d[0] = RC_CHARGE_EXP(info->r6 * info->c1);
context->exponent_d[0] = RC_CHARGE_EXP(node, info->r6 * info->c1);
}
context->v_cap2 = 0;
context->v_trig2 = (info->v2 - 0.6 - OP_AMP_NORTON_VBE) * RES_VOLTAGE_DIVIDER(info->r8, info->r9);
context->exponent2[0] = RC_CHARGE_EXP(info->r9 * info->c2);
context->exponent2[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r8, info->r9) * info->c2);
context->exponent2[0] = RC_CHARGE_EXP(node, info->r9 * info->c2);
context->exponent2[1] = RC_CHARGE_EXP(node, RES_2_PARALLEL(info->r8, info->r9) * info->c2);
context->v_cap3 = 0;
context->v_trig3 = (info->v3 - 0.6 - OP_AMP_NORTON_VBE) * RES_VOLTAGE_DIVIDER(info->r10, info->r11);
context->exponent3[0] = RC_CHARGE_EXP(info->r11 * info->c3);
context->exponent3[1] = RC_CHARGE_EXP(RES_2_PARALLEL(info->r10, info->r11) * info->c3);
context->exponent3[0] = RC_CHARGE_EXP(node, info->r11 * info->c3);
context->exponent3[1] = RC_CHARGE_EXP(node, RES_2_PARALLEL(info->r10, info->r11) * info->c3);
DISCRETE_STEP_CALL(dst_tvca_op_amp);
}

View File

@ -40,8 +40,8 @@ static DISCRETE_START( dso_task )
{
discrete_task_context *task = (discrete_task_context *) node->context;
int inputnum;
linked_list_entry *node_entry;
linked_list_entry *step_entry;
const linked_list_entry *node_entry;
const linked_list_entry *step_entry;
/* Determine, which nodes in the task are referenced in the main task
* and add them to the list of nodes to be buffered for further processing

View File

@ -1207,7 +1207,7 @@ static DISCRETE_RESET(dss_schmitt_osc)
* So use this for the RC charge constant. */
rSource = 1.0 / ((1.0 / info->rIn) + (1.0 / info->rFeedback));
context->rc = rSource * info->c;
context->exponent = RC_CHARGE_EXP(context->rc);
context->exponent = RC_CHARGE_EXP(node, context->rc);
/* Cap is at 0V on power up. Causing output to be high. */
context->v_cap = 0;
@ -1508,7 +1508,7 @@ static DISCRETE_RESET(dss_squarewave2)
#define DSS_INVERTER_OSC__C DISCRETE_INPUT(4)
#define DSS_INVERTER_OSC__R2 DISCRETE_INPUT(5)
INLINE double dss_inverter_tftab(node_description *node, double x)
INLINE double dss_inverter_tftab(const node_description *node, double x)
{
const discrete_inverter_osc_desc *info = (const discrete_inverter_osc_desc *)node->custom;
struct dss_inverter_osc_context *context = (struct dss_inverter_osc_context *)node->context;
@ -1520,7 +1520,7 @@ INLINE double dss_inverter_tftab(node_description *node, double x)
return info->vB;
}
INLINE double dss_inverter_tf(node_description *node, double x)
INLINE double dss_inverter_tf(const node_description *node, double x)
{
const discrete_inverter_osc_desc *info = (const discrete_inverter_osc_desc *)node->custom;
struct dss_inverter_osc_context *context = (struct dss_inverter_osc_context *)node->context;

View File

@ -115,7 +115,7 @@ static void CLIB_DECL ATTR_PRINTF(2,3) discrete_log(const discrete_info *disc_in
*
*************************************/
INLINE int node_module_index(node_description *node)
INLINE int node_module_index(const node_description *node)
{
linked_list_entry *entry;
int index = 0;
@ -132,7 +132,7 @@ INLINE int node_module_index(node_description *node)
return -1;
}
INLINE void linked_list_add(discrete_info *info, linked_list_entry ***list_tail_ptr, void *ptr)
INLINE void linked_list_add(const discrete_info *info, linked_list_entry ***list_tail_ptr, const void *ptr)
{
**list_tail_ptr = auto_alloc(info->device->machine, linked_list_entry);
(**list_tail_ptr)->ptr = ptr;
@ -140,10 +140,10 @@ INLINE void linked_list_add(discrete_info *info, linked_list_entry ***list_tail_
*list_tail_ptr = &((**list_tail_ptr)->next);
}
INLINE int linked_list_count(linked_list_entry *list)
INLINE int linked_list_count(const linked_list_entry *list)
{
int cnt = 0;
linked_list_entry *entry;
const linked_list_entry *entry;
for (entry = list; entry != NULL; entry = entry->next)
cnt++;
@ -287,15 +287,15 @@ static const discrete_module module_list[] =
{ DSS_NULL ,"DSS_NULL" , 0 ,0 ,NULL ,NULL ,NULL ,NULL }
};
INLINE void step_nodes_in_list(linked_list_entry **list)
INLINE void step_nodes_in_list(const linked_list_entry *list)
{
linked_list_entry *entry;
const linked_list_entry *entry;
if (DISCRETE_PROFILING)
{
osd_ticks_t last = osd_profiling_ticks();
for (entry = *list; entry != NULL; entry = entry->next)
for (entry = list; entry != NULL; entry = entry->next)
{
node_description *node = (node_description *) entry->ptr;
@ -307,7 +307,7 @@ INLINE void step_nodes_in_list(linked_list_entry **list)
}
else
{
for (entry = *list; entry != NULL; entry = entry->next)
for (entry = list; entry != NULL; entry = entry->next)
{
node_description *node = (node_description *) entry->ptr;
@ -335,7 +335,7 @@ static node_description *discrete_find_node(const discrete_info *info, int node)
*
*************************************/
static void discrete_build_list(discrete_info *info, discrete_sound_block *intf, linked_list_entry ***current)
static void discrete_build_list(discrete_info *info, const discrete_sound_block *intf, linked_list_entry ***current)
{
int node_count = 0;
@ -408,7 +408,7 @@ static void discrete_build_list(discrete_info *info, discrete_sound_block *intf,
*
*************************************/
static void discrete_sanity_check(discrete_info *info)
static void discrete_sanity_check(const discrete_info *info)
{
linked_list_entry *entry;
int node_count = 0;
@ -522,9 +522,9 @@ static DEVICE_START( discrete )
*
*************************************/
static UINT64 list_run_time(linked_list_entry *list)
static UINT64 list_run_time(const linked_list_entry *list)
{
linked_list_entry *entry;
const linked_list_entry *entry;
UINT64 total = 0;
for (entry = list; entry != NULL; entry = entry->next)
@ -536,7 +536,7 @@ static UINT64 list_run_time(linked_list_entry *list)
return total;
}
static void display_profiling(discrete_info *info)
static void display_profiling(const discrete_info *info)
{
int count;
UINT64 total;
@ -653,7 +653,7 @@ static void *task_callback(void *param, int threadid)
samples = ti->samples;
while (samples-- > 0)
{
step_nodes_in_list(&ti->context->list);
step_nodes_in_list(ti->context->list);
}
/* reset ptr */
for (i = 0; i < ti->context->numbuffered; i++)
@ -681,7 +681,7 @@ INLINE void discrete_stream_update_nodes(discrete_info *info)
}
/* loop over all nodes */
step_nodes_in_list(&info->step_list);
step_nodes_in_list(info->step_list);
}
static STREAM_UPDATE( buffer_stream_update )
@ -770,7 +770,7 @@ static void init_nodes(discrete_info *info, linked_list_entry *block_list, const
{
discrete_sound_block *block = (discrete_sound_block *) entry->ptr;
node_description *node = auto_alloc_clear(info->device->machine, node_description);
int inputnum, modulenum;
int modulenum;
/* find the requested module */
for (modulenum = 0; module_list[modulenum].type != DSS_NULL; modulenum++)
@ -782,7 +782,6 @@ static void init_nodes(discrete_info *info, linked_list_entry *block_list, const
/* static inits */
node->context = NULL;
node->info = info;
//node->node = block->node;
node->module = &module_list[modulenum];
node->output[0] = 0.0;
node->block = block;
@ -832,19 +831,7 @@ static void init_nodes(discrete_info *info, linked_list_entry *block_list, const
if (task_node_list_ptr == NULL)
fatalerror("init_nodes() - NO DISCRETE_START_TASK.");
task = auto_alloc_clear(info->device->machine, discrete_task_context);
#if 1
task->numbuffered = 0;
#else
task->numbuffered = node->active_inputs;
{
int i;
for (i = 0; i < task->numbuffered; i++)
{
task->node_buf[i] = auto_alloc_array(info->device->machine, double, 2048);
task->dest[i] = (double **) &node->input[i];
}
}
#endif
task->list = task_node_list;
linked_list_add(info, &task_list_ptr, task);
node->context = task;
@ -865,11 +852,6 @@ static void init_nodes(discrete_info *info, linked_list_entry *block_list, const
info->indexed_node[NODE_INDEX(block->node)] = node;
}
for (inputnum = 0; inputnum < DISCRETE_MAX_INPUTS; inputnum++)
{
node->input[inputnum] = &(block->initial[inputnum]);
}
/* if we are an stream input node, track that */
if (block->type == DSS_INPUT_STREAM)
{
@ -954,9 +936,18 @@ static void find_input_nodes(discrete_info *info)
/* also report it in the error log so it is not missed */
logerror("Warning - discrete_start - NODE_%02d trying to use a node on static input %d", NODE_BLOCKINDEX(node), inputnum);
}
else
{
node->input[inputnum] = &(block->initial[inputnum]);
}
}
}
for (inputnum = node->active_inputs; inputnum < DISCRETE_MAX_INPUTS; inputnum++)
{
//FIXME: Check that no nodes follow !
node->input[inputnum] = &(block->initial[inputnum]);
}
}
}
/**************************************************************************

View File

@ -3338,13 +3338,13 @@
*************************************/
/* calculate charge exponent using discrete sample time */
#define RC_CHARGE_EXP(rc) (1.0 - exp(node->info->neg_sample_time / (rc)))
#define RC_CHARGE_EXP(_node, rc) (1.0 - exp((_node)->info->neg_sample_time / (rc)))
/* calculate charge exponent using given sample time */
#define RC_CHARGE_EXP_DT(rc, dt) (1.0 - exp(-(dt) / (rc)))
#define RC_CHARGE_NEG_EXP_DT(rc, dt) (1.0 - exp((dt) / (rc)))
/* calculate discharge exponent using discrete sample time */
#define RC_DISCHARGE_EXP(rc) (exp(node->info->neg_sample_time / (rc)))
#define RC_DISCHARGE_EXP(_node, rc) (exp((_node)->info->neg_sample_time / (rc)))
/* calculate discharge exponent using given sample time */
#define RC_DISCHARGE_EXP_DT(rc, dt) (exp(-(dt) / (rc)))
#define RC_DISCHARGE_NEG_EXP_DT(rc, dt) (exp((dt) / (rc)))
@ -3668,14 +3668,14 @@ struct _node_description
typedef struct _linked_list_entry linked_list_entry;
struct _linked_list_entry
{
void *ptr;
const void *ptr;
linked_list_entry *next;
};
typedef struct _discrete_task_context discrete_task_context;
struct _discrete_task_context
{
linked_list_entry *list;
const linked_list_entry *list;
int numbuffered;
double *ptr[DISCRETE_MAX_TASK_OUTPUTS];

View File

@ -335,8 +335,8 @@ static DISCRETE_RESET( dkong_custom_mixer )
context->r_total[0] = RES_2_PARALLEL(context->r_in[0] + DKONG_CUSTOM_R4, NE555_CV_R);
context->r_total[1] = RES_2_PARALLEL((context->r_in[1] + DKONG_CUSTOM_R4), NE555_CV_R);
/* precalculate charging exponents */
context->exp[0] = RC_CHARGE_EXP(context->r_total[0] * DKONG_CUSTOM_C);
context->exp[1] = RC_CHARGE_EXP(context->r_total[1] * DKONG_CUSTOM_C);
context->exp[0] = RC_CHARGE_EXP(node, context->r_total[0] * DKONG_CUSTOM_C);
context->exp[1] = RC_CHARGE_EXP(node, context->r_total[1] * DKONG_CUSTOM_C);
node->output[0] = 0;
}