From 6f40885f73e7042c7c2f5ab34ba7a5ddd900d8d7 Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 10 Oct 2017 20:29:46 -0500 Subject: [PATCH] this seems to improve audio a lot but I still hear some small crackles --- libretro/libretro.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libretro/libretro.c b/libretro/libretro.c index 3f64cb6..4533389 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -95,8 +95,8 @@ static void GB_update_keys_status(GB_gameboy_t *gb) static void audio_callback(void *gb) { - GB_apu_copy_buffer(gb, (GB_sample_t *) soundbuf, 735); - audio_batch_cb(soundbuf, 735); + GB_apu_copy_buffer(gb, (GB_sample_t *) soundbuf, (float)AUDIO_FREQUENCY / 59.72); + audio_batch_cb(soundbuf, (float)AUDIO_FREQUENCY / 59.72); } @@ -235,13 +235,22 @@ static void check_variables(void) void retro_run(void) { + static int frames; + size_t samples; + bool updated = false; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) check_variables(); + samples = GB_apu_get_current_buffer_length(&gb); + if (!(frames < (samples / 35112))) + { + GB_run_frame(&gb); + frames ++; + } + else + frames = 0; - GB_run_frame(&gb); video_cb(frame_buf, VIDEO_WIDTH, VIDEO_HEIGHT, 0); - } bool retro_load_game(const struct retro_game_info *info) @@ -325,6 +334,7 @@ bool retro_load_game(const struct retro_game_info *info) #endif GB_set_sample_rate(&gb, AUDIO_FREQUENCY); + /* GB_set_highpass_filter_mode(&gb, GB_HIGHPASS_REMOVE_DC_OFFSET); */ return true; }