# 系统通知提示音

PX4 定义了一些用于为系统状态和问题提供音频通知的 标准音符/提示音(比如系统启动,解锁成功,电池警告等)

Tunes are specified using strings (in ANSI Music notation (opens new window)) and played by code using the tunes (opens new window) library. The tunes library also contains the list of default system tunes - see lib/tunes/tune_definition.desc (opens new window).

PX4 还有一个模块可以用于播放(测试)默认或用户自定义音乐。

本主题提供了如何创建您自己的声音并添加/替换系统通知音调/乐曲的通用指导。

# 创建乐曲

提示音字符串使用 ANSI 音乐提示 (opens new window) 定义。

提示

More information about the format can be found in QBasic PLAY statement (opens new window) (Wikibooks) and has been reproduced in tune_definition.desc (opens new window). 这允许您编辑乐曲并在您的电脑上播放, 然后导出为 PX4 可以播放的格式。

创建新调节的最简单方式是使用音乐编辑器。 这允许您编辑音乐并在您的电脑上播放, 然后导出为 PX4 可以播放的格式。

ANSI 音乐在 ANSI BBS 系统中很受欢迎,因此最好的编辑工具是 DOS 实用程序。 On Windows, one option is to use Melody Master within Dosbox.

使用软件的步骤是:

  1. 下载 DosBox (opens new window) 并安装应用程序

  2. 下载 Melody Master 并解压缩到新目录

  3. Open the Dosbox console

  4. 将 Melody 主目录挂载到 DosBox,如下:

    mount c C:\<path_to_directory\Melody21
    
  5. Start Melody Master with the following commands

    c:
    start
    
  6. You will then have the option to click through a few screens, then press 1 to display Melody Master: Melody Master 2.1

    屏幕的下半部分提供了关于键盘快捷键的实用工具(箭头用于移动, 和选择笔记长度的数字等)。

  7. 当您准备好时保存音乐:

    • Press F2 to give the tune a name and save it in the /Music sub folder of your Melody Master installation.
    • F7, 向右滚动旋钮,在输出列表选择格式,获取 ANSI。 The file will be exported to the root of the Melody Master directory (with the same name and a file-type specific extension).
  8. 打开文件。 输出可能看起来像这样:

    来自文件的 ANSI 输出

  9. 可以在 PX4 中播放的字符串是 MNTP64: 150L1O3DL16CL32<B>C<AEL16A

# 测试乐曲

当您准备好在 PX4 上尝试新的乐曲时,请使用 tune_control 库。 例如,要测试我们在上面“创建的”乐曲,您应在控制台或 shell(例如 MAVLink Shell)上输入以下命令 :

tune_control play -m "150L1O3DL16CL32<B>C<AEL16A"

注解

开箱即用产品中,tune_control 只存在于实际硬件上(而不是模拟器)。

# 正在替换已存在的乐曲

Tunes are defined within tune_definition.desc (opens new window).

如果你只需要替换现有的乐曲,可以在自己的 fork 中替换文件, 并更新 PX4_DEFINE_TUNE 中定义的乐曲字符串。

# 添加新乐曲

待开发