----------- initialize time tables ----------- */
| 580 | |
| 581 | /* ----------- initialize time tables ----------- */ |
| 582 | static void init_timetables( FM_OPL *OPL , int ARRATE , int DRRATE ) |
| 583 | { |
| 584 | int i; |
| 585 | double rate; |
| 586 | |
| 587 | /* make attack rate & decay rate tables */ |
| 588 | for (i = 0;i < 4;i++) OPL->AR_TABLE[i] = OPL->DR_TABLE[i] = 0; |
| 589 | for (i = 4;i < 60;i++){ |
| 590 | rate = OPL->freqbase; /* frequency rate */ |
| 591 | if( i < 60 ) rate *= 1.0+(i&3)*0.25; /* b0-1 : x1 , x1.25 , x1.5 , x1.75 */ |
| 592 | rate *= 1<<((i>>2)-1); /* b2-5 : shift bit */ |
| 593 | rate *= (double)(EG_ENT<<ENV_BITS); |
| 594 | OPL->AR_TABLE[i] = rate / ARRATE; |
| 595 | OPL->DR_TABLE[i] = rate / DRRATE; |
| 596 | } |
| 597 | for (i = 60;i < 75;i++) |
| 598 | { |
| 599 | OPL->AR_TABLE[i] = EG_AED-1; |
| 600 | OPL->DR_TABLE[i] = OPL->DR_TABLE[60]; |
| 601 | } |
| 602 | #if 0 |
| 603 | for (i = 0;i < 64 ;i++){ /* make for overflow area */ |
| 604 | LOG(LOG_WAR,("rate %2d , ar %f ms , dr %f ms \n",i, |
| 605 | ((double)(EG_ENT<<ENV_BITS) / OPL->AR_TABLE[i]) * (1000.0 / OPL->rate), |
| 606 | ((double)(EG_ENT<<ENV_BITS) / OPL->DR_TABLE[i]) * (1000.0 / OPL->rate) )); |
| 607 | } |
| 608 | #endif |
| 609 | } |
| 610 | |
| 611 | /* ---------- generic table initialize ---------- */ |
| 612 | static int OPLOpenTable( void ) |