static void ymf278b_envelope_next(YMF278BSlot *slot, float clock_ratio) { if(slot->env_step == 0) { // Attack slot->env_vol = (256U << 23) - 1; slot->env_vol_lim = 256U<<23; #ifdef VERBOSE logerror("YMF278B: Skipping attack (rate = %d)\n", slot->AR); #endif slot->env_step++; } if(slot->env_step == 1) { // Decay 1 slot->env_vol = 0; slot->env_step++; if(slot->DL) { int rate = ymf278b_compute_rate(slot, slot->D1R); #ifdef VERBOSE logerror("YMF278B: Decay step 1, dl=%d, val = %d rate = %d, delay = %g\n", slot->DL, slot->D1R, rate, ymf278_compute_decay_rate(rate)*1000.0*clock_ratio/Machine->sample_rate); #endif if(rate<4) slot->env_vol_step = 0; else slot->env_vol_step = ((slot->DL*8)<<23) / (ymf278_compute_decay_rate(rate) * clock_ratio); slot->env_vol_lim = (slot->DL*8)<<23; return; } } if(slot->env_step == 2) { // Decay 2 int rate = ymf278b_compute_rate(slot, slot->D2R); #ifdef VERBOSE logerror("YMF278B: Decay step 2, val = %d, rate = %d, delay = %g, current vol = %d\n", slot->D2R, rate, ymf278_compute_decay_rate(rate)*1000.0*clock_ratio/Machine->sample_rate, slot->env_vol >> 23); #endif if(rate<4) slot->env_vol_step = 0; else slot->env_vol_step = ((256U-slot->DL*8)<<23) / (ymf278_compute_decay_rate(rate) * clock_ratio); slot->env_vol_lim = 256U<<23; slot->env_step++; return; }
static void ymf278b_envelope_next(YMF278BSlot *slot) { if(slot->env_step == 0) { // Attack slot->env_vol = (256U << 23) - 1; slot->env_vol_lim = 256U<<23; LOG(("YMF278B: Skipping attack (rate = %d)\n", slot->AR)); slot->env_step++; } if(slot->env_step == 1) { // Decay 1 slot->env_vol = 0; slot->env_step++; if(slot->DL) { int rate = ymf278b_compute_rate(slot, slot->D1R); LOG(("YMF278B: Decay step 1, dl=%d, val = %d rate = %d, delay = %g\n", slot->DL, slot->D1R, rate, ymf278_compute_decay_rate(rate)*1000.0)); if(rate<4) slot->env_vol_step = 0; else slot->env_vol_step = ((slot->DL*8)<<23) / ymf278_compute_decay_rate(rate); slot->env_vol_lim = (slot->DL*8)<<23; return; } } if(slot->env_step == 2) { // Decay 2 int rate = ymf278b_compute_rate(slot, slot->D2R); LOG(("YMF278B: Decay step 2, val = %d, rate = %d, delay = %g, current vol = %d\n", slot->D2R, rate, ymf278_compute_decay_rate(rate)*1000.0, slot->env_vol >> 23)); if(rate<4) slot->env_vol_step = 0; else slot->env_vol_step = ((256U-slot->DL*8)<<23) / ymf278_compute_decay_rate(rate); slot->env_vol_lim = 256U<<23; slot->env_step++; return; }