From a6571e2487ad7d546c2d1a5f9da3c0c0963b50df Mon Sep 17 00:00:00 2001 From: Derrick Renaud Date: Thu, 24 Sep 2009 23:55:33 +0000 Subject: [PATCH] DISCRETE_74LS624 - optimized for some more speed --- src/emu/sound/disc_dev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/emu/sound/disc_dev.c b/src/emu/sound/disc_dev.c index 8a1ed05f36a..9921356e834 100644 --- a/src/emu/sound/disc_dev.c +++ b/src/emu/sound/disc_dev.c @@ -125,6 +125,7 @@ struct dsd_ls624_context int out_type; double k1; /* precalculated cap part of formula */ double k2; /* precalculated ring part of formula */ + double dt_vmod_at_0; }; @@ -1600,7 +1601,11 @@ static DISCRETE_STEP(dsd_ls624) sample_t = node->info->sample_time; /* Change in time */ //dt = LS624_T(DSD_LS624__C, DSD_LS624__VRNG, DSD_LS624__VMOD) / 2.0; - dt = 1.0f / (2.0f * LS624_F(DSD_LS624__VMOD)); + if (DSD_LS624__VMOD > 0.001) + dt = 1.0f / (2.0f * LS624_F(DSD_LS624__VMOD)); + else + /* close enough to 0, so we can speed things up by no longer call pow() */ + dt = context->dt_vmod_at_0; t = context->remain; en += (double) context->state * t; while (t + dt <= sample_t) @@ -1649,6 +1654,8 @@ static DISCRETE_RESET(dsd_ls624) context->k1 = -0.912029404 * log10(DSD_LS624__C) -0.091695877 * (DSD_LS624__VRNG) - 3.207072925; context->k2 = -0.014110946 * (DSD_LS624__VRNG); + context->dt_vmod_at_0 = 1.0f / (2.0f * LS624_F(0)); + /* Step the output */ DISCRETE_STEP_CALL(dsd_ls624); }