Skip to content

feat: add RMS-based loudness normalization#262

Draft
Philosyang wants to merge 1 commit into
LingFeng-bbben:devfrom
Philosyang:feat/loudness-normalization
Draft

feat: add RMS-based loudness normalization#262
Philosyang wants to merge 1 commit into
LingFeng-bbben:devfrom
Philosyang:feat/loudness-normalization

Conversation

@Philosyang

Copy link
Copy Markdown

Replace peak-amplitude normalization with RMS-based loudness normalization using BASS ChannelGetLevelEx with the RMS flag. When enabled, all songs are normalized to a -14 dB RMS target so perceived volume is consistent across tracks.

  • Add LoudnessNormalization toggle to SoundOptions (default off)

  • Add MeasuredRmsDb cache field to ChartSetting for persistence

  • Implement RMS scan in BassAudioSample and BassSimpleAudioSample

  • Pass cached RMS through AudioManager to skip re-measurement

  • Wire cache read/write in SongDetail and OnlineSongDetail

Ref #259


Hi! 本 PR 实现了 #259 中讨论的 RMS-based loudness normalization,无新增依赖。但是在 merge 之前有几个设计问题想先确认:

1. 替换还是保留 peak normalization?
目前的实现保留了两种方式:原有的 peak normalization 仍为当前默认,RMS normalization 通过 settings.json > Audio 下的 "LoudnessNormalization": true 控制(默认关闭)。我们是让 RMS 替代旧的 peak normalization,还是两者并存,让玩家选择?(例如在游戏内的设置界面中添加对应选项)

2. 默认行为
如果两者并存,LoudnessNormalization 应该默认 true 还是 false

3. Settings UI 可见性
目前这个 toggle 只能通过 settings.json 手动修改,因为 SettingManagerAudio 只暴露了 Volume 子菜单。需要在游戏内 settings UI 中加入这个选项吗?如果需要,放在哪里合适?

4. 目标响度值
当前使用 -14 dB RMS 作为 normalization target(参考主流串流平台标准)。是否需要换一个值,或者做成用户可调?

测试结果(使用同一首歌,ffmpeg 降低 10 dB 制作对照组):

  • 原曲:measured RMS = -11.84 dB,gain = 0.78x(衰减)
  • -10 dB 副本:measured RMS = -21.83 dB,gain = 2.46x(增益)
image

开启 normalization 后两首歌的感知音量基本一致。RMS 测量结果会缓存到 ChartSetting(内存变量,不会写入文件),从选曲界面进入歌曲后会跳过重复扫描。

Replace peak-amplitude normalization with RMS-based loudness normalization using BASS ChannelGetLevelEx with the RMS flag. When enabled, all songs are normalized to a -14 dB RMS target so perceived volume is consistent across tracks.

- Add LoudnessNormalization toggle to SoundOptions (default off)

- Add MeasuredRmsDb cache field to ChartSetting for persistence

- Implement RMS scan in BassAudioSample and BassSimpleAudioSample

- Pass cached RMS through AudioManager to skip re-measurement

- Wire cache read/write in SongDetail and OnlineSongDetail

Ref LingFeng-bbben#259
@Philosyang Philosyang marked this pull request as draft March 26, 2026 08:59
@LingFeng-bbben

Copy link
Copy Markdown
Owner

我感觉默认开启,settings不显示,然后替换之前的那个算法会比较好?

@LingFeng-bbben

Copy link
Copy Markdown
Owner

可以加QQ667644338群来讨论下

@LingFeng-bbben

Copy link
Copy Markdown
Owner

另外希望RMS的部分不要在BassAudioSample以外的地方出现,且仅对谱面track生效(与之前行为一致)

@Philosyang

Copy link
Copy Markdown
Author

可以加QQ667644338群来讨论下

ok已申请

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