Previous 199869 Revisions Next

r23986 Friday 28th June, 2013 at 05:44:58 UTC by hap
improve adsr timing a bit, attack rate was too slow
[src/emu/sound]ymf271.c

trunk/src/emu/sound/ymf271.c
r23985r23986
5757
5858#define ENV_VOLUME_SHIFT    16
5959
60#define INF     100000000.0
60#define INF     -1.0
6161
62static const double ARTime[] =
62static const double ARTime[64] =
6363{
6464   INF,        INF,        INF,        INF,        6188.12,    4980.68,    4144.76,    3541.04,
6565   3094.06,    2490.34,    2072.38,    1770.52,    1547.03,    1245.17,    1036.19,    885.26,
r23985r23986
7171   0.88,       0.70,       0.57,       0.48,       0.43,       0.43,       0.43,       0.07
7272};
7373
74static const double DCTime[] =
74static const double DCTime[64] =
7575{
7676   INF,        INF,        INF,        INF,        93599.64,   74837.91,   62392.02,   53475.56,
7777   46799.82,   37418.96,   31196.01,   26737.78,   23399.91,   18709.48,   15598.00,   13368.89,
r23985r23986
354354void ymf271_device::init_envelope(YMF271Slot *slot)
355355{
356356   int keycode, rate;
357   int attack_length, decay1_length, decay2_length, release_length;
358357   int decay_level = 255 - (slot->decay1lvl << 4);
359358
360359   double time;
r23985r23986
371370
372371   // init attack state
373372   rate = GET_KEYSCALED_RATE(slot->ar * 2, keycode, slot->keyscale);
374   time = ARTime[rate];
373   time = (ARTime[rate] * 44100.0) / 1000.0;        // attack end time in samples
374   slot->env_attack_step = time < 0 ? 0 : (int)(((double)(255-0) / time) * 65536.0);
375375
376   attack_length = (UINT32)((time * 44100.0) / 1000.0);        // attack end time in samples
377   slot->env_attack_step = (int)(((double)(160-0) / (double)(attack_length)) * 65536.0);
378
379376   // init decay1 state
380377   rate = GET_KEYSCALED_RATE(slot->decay1rate * 2, keycode, slot->keyscale);
381   time = DCTime[rate];
378   time = (DCTime[rate] * 44100.0) / 1000.0;
379   slot->env_decay1_step = time < 0 ? 0 : (int)(((double)(255-decay_level) / time) * 65536.0);
382380
383   decay1_length = (UINT32)((time * 44100.0) / 1000.0);
384   slot->env_decay1_step = (int)(((double)(255-decay_level) / (double)(decay1_length)) * 65536.0);
385
386381   // init decay2 state
387382   rate = GET_KEYSCALED_RATE(slot->decay2rate * 2, keycode, slot->keyscale);
388   time = DCTime[rate];
383   time = (DCTime[rate] * 44100.0) / 1000.0;
384   slot->env_decay2_step = time < 0 ? 0 : (int)(((double)(255-0) / time) * 65536.0);
389385
390   decay2_length = (UINT32)((time * 44100.0) / 1000.0);
391   slot->env_decay2_step = (int)(((double)(255-0) / (double)(decay2_length)) * 65536.0);
392
393386   // init release state
394387   rate = GET_KEYSCALED_RATE(slot->relrate * 4, keycode, slot->keyscale);
395   time = ARTime[rate];
388   time = (ARTime[rate] * 44100.0) / 1000.0;
389   slot->env_release_step = time < 0 ? 0 : (int)(((double)(255-0) / time) * 65536.0);
396390
397   release_length = (UINT32)((time * 44100.0) / 1000.0);
398   slot->env_release_step = (int)(((double)(255-0) / (double)(release_length)) * 65536.0);
399
400391   slot->volume = (255-160) << ENV_VOLUME_SHIFT;       // -60db
401392   slot->env_state = ENV_ATTACK;
402393}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team