From c0179e7ed4a337c4eebb4d993f126c1f93713bbc Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Sun, 9 Aug 2009 16:10:44 +0000 Subject: [PATCH] fixed YM2612 output limiter modified resampler frame length calculation --- source/gx/config.c | 4 ++-- source/sound/Fir_Resampler.c | 18 ++++++++++++------ source/sound/ym2612.c | 15 +++++++-------- source/system.c | 15 ++++++++------- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/source/gx/config.c b/source/gx/config.c index 7be36eb..46e23a0 100644 --- a/source/gx/config.c +++ b/source/gx/config.c @@ -71,8 +71,8 @@ void config_default(void) config.hq_fm = 1; config.psgBoostNoise = 0; config.filter = 1; - config.low_freq = 200; - config.high_freq = 8000; + config.low_freq = 880; + config.high_freq = 5000; config.lg = 1.0; config.mg = 1.0; config.hg = 1.0; diff --git a/source/sound/Fir_Resampler.c b/source/sound/Fir_Resampler.c index ac648b2..6d80ef1 100644 --- a/source/sound/Fir_Resampler.c +++ b/source/sound/Fir_Resampler.c @@ -1,6 +1,6 @@ /* Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ /* Copyright (C) 2004-2006 Shay Green. */ -/* Modified by Eke-Eke for use in Genesis Plus (2009). */ +/* C Conversion by Eke-Eke for use in Genesis Plus (2009). */ #include "Fir_Resampler.h" @@ -23,7 +23,7 @@ static int step = STEREO; static int input_per_cycle; static double ratio = 1.0; -static void gen_sinc(double rolloff, int width, double offset, double spacing, double scale, int count, sample_t *out ) +static void gen_sinc(double rolloff, int width, double offset, double spacing, double scale, int count, short *out ) { double const maxh = 256; double const fstep = M_PI / maxh * spacing; @@ -38,11 +38,11 @@ static void gen_sinc(double rolloff, int width, double offset, double spacing, d double w = angle * to_w; if ( fabs( w ) < M_PI ) { - double rolloff_cos_a = ROLLOFF * cos( angle ); + double rolloff_cos_a = rolloff * cos( angle ); double num = 1 - rolloff_cos_a - pow_a_n * cos( maxh * angle ) + - pow_a_n * ROLLOFF * cos( (maxh - 1) * angle ); - double den = 1 - rolloff_cos_a - rolloff_cos_a + ROLLOFF * ROLLOFF; + pow_a_n * rolloff * cos( (maxh - 1) * angle ); + double den = 1 - rolloff_cos_a - rolloff_cos_a + rolloff * rolloff; double sinc = scale * num / den - scale; out [-1] = (short) (cos( w ) * sinc + sinc); @@ -78,6 +78,12 @@ int Fir_Resampler_initialize( int new_size ) buffer = (sample_t *) realloc( buffer, (new_size + WRITE_OFFSET) * sizeof (sample_t) ); if ( !buffer && new_size ) return 0; buffer_size = new_size + WRITE_OFFSET; + write_pos = 0; + res = 1; + imp_phase = 0; + skip_bits = 0; + step = STEREO; + ratio = 1.0; Fir_Resampler_clear(); return 1; } @@ -265,7 +271,7 @@ int Fir_Resampler_input_needed( unsigned long output_count ) unsigned long skip = skip_bits >> imp_phase; int remain = res - imp_phase; - while ( (output_count -= 2) > 0 ) + while ( (output_count) > 0 ) /* fixed (Eke_Eke) */ { input_count += step + (skip & 1) * STEREO; skip >>= 1; diff --git a/source/sound/ym2612.c b/source/sound/ym2612.c index 89ddb32..76c18bb 100644 --- a/source/sound/ym2612.c +++ b/source/sound/ym2612.c @@ -137,9 +137,6 @@ #define FREQ_MASK ((1<> 1; - rr = (rr + r) >> 1; - l = ll; - r = rr; + l = (ll + l) >> 1; + r = (rr + r) >> 1; + ll = l; + rr = r; } else if (filter & 2) { @@ -141,7 +142,7 @@ int audio_init (int rate) snd.sample_rate = rate; /* Calculate the sound buffer size (for one frame) */ - snd.buffer_size = (rate / vdp_rate) + 8; + snd.buffer_size = (rate / vdp_rate) + 32; #ifndef NGC /* Output buffers */