--- np2/sound/opngenc.c 2011/01/15 14:15:21 1.13 +++ np2/sound/opngenc.c 2011/02/04 14:43:55 1.14 @@ -54,8 +54,10 @@ void opngen_initialize(UINT rate) { UINT ratebit; int i; + char sft; int j; double pom; + long detune; double freq; UINT32 calcrate; @@ -73,7 +75,6 @@ void opngen_initialize(UINT rate) { for (i=0; i= 21) - freq = FREQBASE4096 * dttable[i*32 + j] * - (1 << (FREQ_BITS-21)); -#else - freq = FREQBASE4096 * dttable[i*32 + j] / - (1 << (21-FREQ_BITS)); -#endif - detunetable[i][j] = (long)freq; - detunetable[i+4][j] = (long)-freq; + detune = dttable[i*32 + j]; + sft = ratebit + (FREQ_BITS - 21); + if (sft >= 0) { + detune <<= sft; + } + else { + detune >>= (0 - sft); + } + + detunetable[i][j] = detune; + detunetable[i+4][j] = -detune; } } for (i=0; i<4; i++) {