Skip to content

feat(lyric): 丰富 AMLL 设置项,删除 QM 意外的逐字音译#726

Merged
imsyy merged 3 commits into
SPlayer-Dev:devfrom
MoYingJi:pr/s
Jan 10, 2026
Merged

feat(lyric): 丰富 AMLL 设置项,删除 QM 意外的逐字音译#726
imsyy merged 3 commits into
SPlayer-Dev:devfrom
MoYingJi:pr/s

Conversation

@MoYingJi
Copy link
Copy Markdown
Collaborator

@MoYingJi MoYingJi commented Jan 9, 2026

  1. 通过删除 cloneDeep 后的歌词的翻译和音译来实现了 AMLL 的:不显示翻译、不显示音译、不显示逐字音译
  2. 修改了 QM 歌词解析的部分逻辑,合并逐字音译为逐行而不是按 index 放入错误的逐字音译(QM 歌词的逐字音译无论从 index 还是 startTime/endTime 都是对不上的,只能合并为逐行)
  3. 支持设置 AMLL 背景的 renderScale
  4. 修改了 AMLL 背景的 lowFreqVolume 的逻辑,之前的逻辑会导致暂停后 lowFreqVolume 突变为 1,现在暂停则会保持

@MoYingJi MoYingJi changed the title feat(lyric): 丰富 AMLL 设置项,删除 QM 意外的逐字 feat(lyric): 丰富 AMLL 设置项,删除 QM 意外的逐字音译 Jan 9, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @MoYingJi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在增强歌词显示的用户自定义能力,特别是针对 Apple Music Like Lyrics (AMLL) 模式。通过引入新的设置选项,用户现在可以更灵活地控制歌词翻译、整体罗马音以及逐字罗马音的可见性。同时,内部歌词处理逻辑也得到了优化,使得罗马音的解析和应用更加模块化和独立。

Highlights

  • AMLL 歌词显示控制: 增加了对 Apple Music Like Lyrics (AMLL) 歌词显示更精细的控制,允许用户独立开关翻译、罗马音和逐字罗马音的显示。
  • 设置界面更新: 在歌词设置界面新增了“显示逐字音译”的开关,并移除了“显示翻译”和“显示歌词音译”开关的禁用状态。
  • 歌词处理逻辑优化: 重构了 LyricManager 中 QRC 歌词的解析逻辑,将罗马音的处理从主歌词解析中分离出来,使其能像翻译一样独立进行对齐和显示控制。
  • 新增配置项: 在全局设置中引入了 showWordsRoma 配置项,用于控制逐字罗马音的显示。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

此 PR 通过增加显示/隐藏逐字音译的设置,丰富了 AMLL 歌词的显示选项。同时,它重构了 QM 歌词的解析逻辑,移除了不正确的逐字音译,并对整行音译采用更可靠的基于时间的对齐方式。代码更改实现得很好。我对 LyricManager.ts 有几点建议,以提高可读性和性能。

Comment thread src/core/player/LyricManager.ts
isDuet: false,
};
});
result = this.alignLyrics(result, romaLines, "romanLyric");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

alignLyrics 函数由于存在嵌套循环,其时间复杂度为 O(N*M),其中 N 和 M 分别是主歌词和罗马音歌词的行数。对于歌词行数较多的歌曲,这可能会导致性能瓶颈。

建议优化 alignLyrics 函数,采用更高效的算法,例如在歌词按时间排序的前提下使用双指针法。这将能把时间复杂度降低到 O(N+M),从而显著提高长歌词的处理性能。

一个使用双指针法的高效实现示例(假设两个歌词数组都按 startTime 排序):

private alignLyrics(
  lyrics: LyricLine[],
  otherLyrics: LyricLine[],
  key: "translatedLyric" | "romanLyric",
): LyricLine[] {
  if (!lyrics.length || !otherLyrics.length) {
    return lyrics;
  }

  let otherIdx = 0;
  for (const line of lyrics) {
    // 移动 otherIdx 寻找可能的匹配项
    while (
      otherIdx < otherLyrics.length - 1 &&
      otherLyrics[otherIdx].startTime < line.startTime - 300
    ) {
      otherIdx++;
    }

    // 检查 otherLyrics 中当前及附近的歌词行以寻找匹配
    for (let i = otherIdx; i < otherLyrics.length; i++) {
      const otherLine = otherLyrics[i];
      const timeDiff = Math.abs(line.startTime - otherLine.startTime);

      if (timeDiff < 300) {
        line[key] = otherLine.words.map((word) => word.word).join("");
        // 原始实现会继续查找,并让最后一个匹配项生效。
        // 如果只需要第一个匹配项,可以在此处 `break`。
      }

      // 如果 otherLine 的时间已经远超当前行的时间,则停止搜索
      if (otherLine.startTime > line.startTime + 300) {
        break;
      }
    }
  }

  return lyrics;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

哈?这也不是我写的啊

星谷米游姬-未响应

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这个方法是祖传的来着(

@MoYingJi MoYingJi marked this pull request as draft January 9, 2026 09:43
@MoYingJi MoYingJi marked this pull request as ready for review January 9, 2026 10:07
@imsyy imsyy merged commit 13066eb into SPlayer-Dev:dev Jan 10, 2026
@MoYingJi MoYingJi deleted the pr/s branch January 10, 2026 15:33
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