Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题背景
原 SimpleNES 的 APU 音频存在两个核心问题:
APU_TRI_LINEAR寄存器处理时误用1 >> 7(恒为 0),导致线性计数器和长度计数器无法正常工作;修改内容
基于现有代码,仅改动
src/APU/APU.cpp和配套头文件src/APU/APU.h,未修改其他模块,确保低耦合:sf::SoundStream并实现onGetData/onSeek接口,将混合后的 float 样本转换为 16 位整数格式;step函数的分频逻辑,确保 APU 时钟为 CPU 时钟的 1/12;APU_TRI_LINEAR寄存器的1 >> 7修正为(value >> 7) & 1,正确读取输入值的第 7 位控制计数器;mix函数输出的 float 样本(0150 范围)进行缩放,映射到 SFML 所需的32767)sf::Int16(-32768其他说明