Skip to content

Conversation

@nchapman
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings November 25, 2025 22:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request upgrades MinArch's audio resampling system from nearest-neighbor to linear interpolation and adds libretro audio buffer status callback support for frameskip. The changes improve audio quality and enable cores like mGBA to make intelligent frameskip decisions based on audio buffer occupancy.

Key Changes

  • Linear interpolation resampling: Replaces the old Bresenham-like nearest-neighbor algorithm with smooth linear interpolation using 16.16 fixed-point math, eliminating audio artifacts
  • Dynamic rate control: Implements ±2% playback speed adjustment based on buffer fill level (30-70% deadband targeting 50%) to prevent underruns/overruns
  • Audio buffer status callback: Implements RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK (ID 62) to report buffer occupancy to cores for frameskip decisions

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
workspace/all/common/audio_resampler.h Updated API from single-frame to batch processing with linear interpolation; added rate adjustment parameter and legacy API compatibility layer
workspace/all/common/audio_resampler.c Implemented linear interpolation with fixed-point math; added buffer overflow detection and state management across batches
workspace/all/common/api_types.h New file extracting shared types (SND_Frame, PAD_Axis, LID_Context) to avoid circular dependencies
workspace/all/common/api.h Moved type definitions to api_types.h; added SND_getBufferOccupancy() declaration
workspace/all/common/api.c Integrated new resampler with dynamic rate control; improved underrun handling to repeat last frame instead of outputting backwards samples
workspace/all/minarch/minarch.c Added audio_buffer_status callback field; implemented callback registration and invocation in both threaded and non-threaded render paths
tests/unit/all/common/test_audio_resampler.c Rewrote tests for batch API and linear interpolation; added dynamic rate adjustment and buffer wrapping tests
docs/MINARCH-GAP-ANALYSIS.md New comprehensive documentation of libretro API implementation coverage and gaps
docs/LIBRETRO-API.md New reference documentation for the libretro API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nchapman nchapman merged commit bef789d into develop Nov 26, 2025
4 checks passed
@nchapman nchapman deleted the feature/audio-upgrades branch November 26, 2025 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants