Repository navigation
PSX3DS v0.2.8 — Smooth Real-3DS Audio Fix (Zero Silence Splices, Core 2 SPU Worker, NDSP Rate Matching & Phase-Locked CD Clock)
LatestPSX3DS v0.2.8 — Smooth Real-3DS Audio Fix (Zero Silence-Padding Splices, Core 2 Dedicated 804 MHz SPU Worker, NDSP Hardware Rate Matching, Phase-Locked CD-ROM Sector Clock & Division-Free Reverb/XA)
v0.2.8 resolves the real New 3DS audio stuttering/choppiness reported on v0.2.7 ("画面流畅, 声音卡顿" — video runs smoothly at 60 FPS and sound plays on real hardware, but audio chopped/stuttered), eliminating all premature silence-padding wavebuf splices, Core 1 SysCore quota freezes, CD-ROM INT1 acknowledge XA drift, dropped SPU_CMD_REG_ADVANCE audio batches, and ~727,000 software divisions/sec on ARM11v6K.
English Release Notes
1. Smooth Real-3DS NDSP Audio Pipeline (src/platform/3ds/audio_ndsp.c, src/platform/3ds/threads_3ds.c, src/platform/3ds/ui_bottom.c)
- Eliminated Premature
active_wbufs <= 1Silence-Padding Splices & Synchronous SPU Drain:- Root Cause: In
v0.2.7,CTR_NDSP_PRIME_FRAMESwas2 x 735(33.3 ms). Wheneverwb[0]retired during Core 0'spacer_wait()frame sleep (active_wbufsdropping from2to1whileavail < 735),audio_pump_locked()hit theactive_wbufs <= 1branch and padded the remaining ~700 frames (~16 ms) of a 735-frame wavebuf with an exponential fade-to-zero ramp (WBinflated to3,610in 3,200 frames of KOF '97 = ~8 silence holes/sec). In addition, atrylockmiss against the SPU worker left part of the emulated frame'sSpuCmdqueue unrendered incmd_ring. - Fix: Removed the
active_wbufs <= 1silence-padding branch so Core 0 submits full 735-frame wavebufs only while NDSP is playing; expanded the NDSP ring to8 x 735frames (133.3 ms) with a3 x 735(50.0 ms) prime (CTR_SPU_HIGH_WATER = 6 x 735 = 100.0 ms,250 msstall watchdog); and addedspu_drain_all_cmds_sync(sys)wheneverqueued < CTR_NDSP_PRIME_FRAMESso 100% of Core-0-emulated audio is rendered intoout_ringbefore checking availability.
- Root Cause: In
- New 3DS Dedicated Core 2 (
804 MHz, Unthrottled AppCore) SPU Worker Placement:- Root Cause: On real New 3DS hardware, Core 1 (
SysCore) is throttled by the Horizon OS Kernel11APT_SetAppCpuTimeLimit(30)quota (4.8 msCPU budget per16.67 mswindow, freezing Core 1 app threads for ~11.2 ms) and shared withdsp::DSP,gsp::Gpu, andfs::USER. Meanwhile, Core 2 is a dedicated804 MHzAppCore with 100% unthrottled CPU time and zero OS services. - Fix: On New 3DS (
hw->is_n3ds),g_spu_workernow runs on Core 2 at priority0x2F(main_prio - 1), whileg_cd_worker(bursty CHD readahead) moves to Core 1 at0x2F/0x30(never0x31, avoiding starvation below the0x30SysCore quota thread), with clean fallback chains for Old 3DS / restricted.3dsxlaunchers.2:HUDnow displaysSPU:C2/SPU:C1/SPU:SYNalongsideCD [CHD]: Core <N>.
- Root Cause: On real New 3DS hardware, Core 1 (
- TeakLite II NDSP Hardware Resampler Rate Matching with Hysteresis:
- Because the
60.00 HzNTSC pacer runs native PS1 (59.8261 Hz,737.13SPU frames/vblank) at44,228 Hz(50.00 HzPAL at44,312 Hz),ndspChnSetRatenow runs at44,228 HzNTSC (44,312 HzPAL) and steers smoothly with hysteresis (44,100/44,228/44,360 HzNTSC;44,180/44,312/44,440 HzPAL) around ~3 queued wavebufs without step-resampling pitch jumps or queue drift.
- Because the
2. Phase-Locked CD-ROM Sector Clock & XA Gap Decay (src/periph/cdrom.c, src/periph/spu.c)
- Zero Guest
INT1Acknowledge Drift on XA / FMV Streams:- Root Cause: At 2x speed, 8 CD sectors (
7video +1XA 37.8 kHz stereo sector) take8 x 225,792 = 1,806,336cycles (2,352.000SPU samples) and produce2,352XA samples.v0.2.7scheduled the next sector after the guest acknowledgedCD_INT1_DATARDY(+t_irq_ack≈15,000cycles/sector), stretching every 8 sectors to~2,490SPU samples and starvingxa_ringevery ~53 ms. - Fix: Added wrap-safe
u32next_sector_cycle+sector_clock_armedphase-locked sector scheduling (cd_schedule_next_sector), schedulingEV_CDROMimmediately onINT1delivery as well as on guest acknowledge so 8 sectors take8 x 225,792 = 1,806,336cycles regardless of guest IRQ latency. Briefxa_ringtransitions now smoothly decaylast_cd_l/r(* 252 / 256toward0) instead of stepping full-scale to0. Covered bytest_cdrom_sector_clock_no_ack_driftandtest_spu_xa_gap_decay.
- Root Cause: At 2x speed, 8 CD sectors (
3. Zero Dropped SPU_CMD_REG_ADVANCE Audio & ARM11v6K Division Elimination (src/periph/spu.c, src/periph/spu_reverb.c, src/periph/spu_xa.c)
- Render Queued
ADVANCEBatches on Drain & Before SPU DMA:spu_drain_all_cmdsnow renders all queuedSPU_CMD_REG_ADVANCEtime intoout_ring(with deferred IRQ9 delivery) instead of discarding up to a full frame (736samples) whenSPUCNTtogglesIRQ9(0x8040) or on savestate, and drainscmd_ringbeforespu_dma_write_wordsoverwrites SPU sample RAM. Covered bytest_spu_drain_renders_queued_advance.
- Eliminated ~727,000 Software Divisions/sec on ARM11v6K:
- Replaced
s64 %inspu_reverb.c(rev_calc_addr+rev_next_pos, called 29 times per 22.05 kHz tick =639,450calls/sec to__aeabi_ldivmod) with single add/subtract wrap-around plus a muted-reverb fast path (vLOUT == 0 && vROUT == 0 && (SPUCNT & 0x00C0) == 0), and replaced per-sample/ 44100inspu_xa.cwith exactUMULLreciprocal multiplication ((p * 1595663134ULL) >> 32for all0 <= p < 44100).
- Replaced
中文更新说明 (v0.2.8)
- 彻底消除 New 3DS 实机声音卡顿/断续(修复
v0.2.7“画面流畅,声音卡顿”):- 移除过早静音拼接并同步排空 SPU 命令队列:修复
v0.2.7在pacer_wait帧间休眠时当活跃缓冲降至 1 块(active_wbufs <= 1)即向 735 帧 wavebuf 强行填充约 700 帧渐隐静音(导致《拳皇 '97》每秒混入约 8 次 16 ms 静音断口、WB虚高膨胀)的问题;现扩展为8 x 735帧(133.3 ms)环形缓冲与3块(50.0 ms)预充水位,播放期间仅提交完整 735 帧音频块,并在低水位时通过spu_drain_all_cmds_sync同步渲染当帧全部 SPU 采样(WB与帧数严格保持~1.0x)。 - New 3DS 独占
Core 2(804 MHz无配额限制核心) 运行 SPU 音频线程:实机上Core 1(SysCore) 受 Horizon OSAPT_SetAppCpuTimeLimit(30)限制(每16.67 ms窗口仅4.8 ms配额、其余约11.2 ms被内核冻结)且与dsp/gsp/fs系统服务共享;现将 New 3DS 的 SPU 渲染线程移至拥有 100% 算力、零系统服务抢占 的独立应用核Core 2(优先级0x2F),并将突发式 CHD 预读线程移至Core 1(优先级0x2F/0x30,避免落入0x31被配额线程饿死)。下屏2:HUD现精确显示SPU:C2与CD [CHD]: Core 1。 - 3DS NDSP 硬件重采样器自适应锁相调速(带迟滞防抖):针对
60.00 HzNTSC 限速器下 PS1 实际采样率(44,228 Hz,PAL 为44,312 Hz),利用 3DS TeakLite II DSP 硬件线性重采样器围绕 3 块缓冲水位平滑微调(±0.3%带迟滞区间),无需跳变重采样即可长期稳态不空载、不溢出。
- 移除过早静音拼接并同步排空 SPU 命令队列:修复
- CD-ROM 锁相扇区时钟与 XA 音频无缝衔接(消除 FMV / XA 周期性断音):
- 修复
v0.2.7在游戏确认CD_INT1_DATARDY后才调度下一扇区导致的累计确认延迟漂移(每 8 扇区多消耗约 138 个采样,每 ~53 ms 抽空一次xa_ring);现改为INT1触发即按精确扇区周期锁相调度(8 个 2x 扇区严格耗时1,806,336周期 =2,352采样),并对扇区间极短间隙做平滑衰减避免爆音。
- 修复
- 零丢帧 SPU 队列排空与 ARM11v6K 零软除法优化:
spu_drain_all_cmds(含切换SPUCNTIRQ9 与 SPU DMA 写入前)现完整渲染队列中的ADVANCE时间片,不再丢弃未渲染音频;- 消除
spu_reverb.c与spu_xa.c在无硬件除法指令的 ARM11v6K 上每秒约 72.7 万次__aeabi_ldivmod/__aeabi_idiv软件除法开销,大幅降低 SPU 混响与 XA 解码 CPU 占用。