Re: [hatari-devel] Improved YM2149 cycle accuracy |
[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]
--- a/src/sound.c 2021-07-25 11:50:06.650166911 -0700 +++ b/src/sound.c 2021-07-25 12:18:56.516824122 -0700 @@ -399,17 +399,19 @@ /** * Get coefficients for different Fs (C10 is in ST only): - * Wc = 2*M_PI*4895.1; - * Fs = 44100; + * Wc = 2*M_PI*fc; + * Fs = 250000 Hz; * warp = Wc/tanf((Wc/2)/Fs); - * b = Wc/(warp+Wc); - * a = (Wc-warp)/(warp+Wc); + * b = Wc/(Wc+warp); + * a = (Wc-warp)/(Wc+warp); * + * Aside: 44100 Hz coefficients example * #define B_z (yms32)( 0.2667*(1<<15)) * #define A_z (yms32)(-0.4667*(1<<15)) * * y0 = (B_z*(x0 + x1) - A_z*y0) >> 15; * x1 = x0; + * /Aside * * The Lowpass Filter formed by C10 = 0.1 uF * and @@ -437,11 +439,11 @@ static yms32 y0 = 0, x1 = 0; if (x0 >= y0) - /* YM Pull up: fc = 7586.1 Hz (44.1 KHz), fc = 8257.0 Hz (48 KHz) */ - y0 = (3*(x0 + x1) + (y0<<1)) >> 3; + /* YM Pull up: fc is approx 7693.7 Hz (at 250 KHz rate) */ + y0 = ( 11*(x0 + x1) + 106*y0 ) >> 7; else - /* R8 Pull down: fc = 1992.0 Hz (44.1 KHz), fc = 2168.0 Hz (48 KHz) */ - y0 = ((x0 + x1) + (6*y0)) >> 3; + /* R8 Pull down: fc is approx 2096.6 Hz (at 250 KHz rate) */ + y0 = ( 13*(x0 + x1) + 486*y0 ) >> 9; x1 = x0; return y0; @@ -469,7 +471,7 @@ y0 = x0; else /* R8 Pull down */ - y0 = (3*(x0 + x1) + (y0<<1)) >> 3; + y0 = ( 11*(x0 + x1) + 106*y0 ) >> 7; x1 = x0; return y0;
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |