Skip to content

系统通知提示音

PX4定义了一些 standard tones/tunes 用于为重要系统状态和问题(例如系统启动、解除武装成功、电池警告等)提供音频通知

使用字符串指定曲调 (in ANSI Music notation) and played by code using the tunes library. 曲调库还包含默认系统曲调的列表-请参阅 lib/tunes/tune_definition.desc.

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

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

创建乐曲

调音字符串是通过以下方式定义的 ANSI Music notation.

TIP

有关格式的更多信息,请参阅 QBasic PLAY statement (Wikibooks) and has been reproduced in tune_definition.desc.

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

ANSI 音乐在 ANSI BBS 系统中很受欢迎,因此最好的编辑工具是 DOS 实用程序。 在Windows上,一种选择是在_Dosbox_中使用_Melody Master_。

使用软件的步骤是:

  1. Download DosBox and install the app

  2. Download Melody Master and unzip into a new directory

  3. Open the Dosbox console

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

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

    sh
    c:
    start
  6. 然后,您可以选择点击几个屏幕,然后按 1 to display Melody Master: Melody Master 2.1

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

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

    • Press F2 为乐曲命名并将其保存在旋律大师安装的_/Music_子文件夹中。
    • Press F7, 向下滚动右侧的输出格式列表以进入ANSI。 该文件将导出到Melody Master目录的_root_(具有相同的名称和特定于文件类型的扩展名)。
  8. 打开文件。 输出可能看起来像这样:

    ANSI Output from file

  9. The string that can be played in PX4 is the bit between MNT and P64: 150L1O3DL16CL32<B>C<AEL16A

测试乐曲

当您准备在PX4上尝试新曲调时,请使用 tune_control library. 例如,要测试我们在上面“创建”的曲调,您可以在控制台或shell上输入以下命令 (e.g. the MAVLink Shell):

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

INFO

开箱即用 tune_control 仅存在于真实硬件上(不是模拟器)。

正在替换已存在的乐曲

曲调定义如下 tune_definition.desc.

如果你只需要替换现有的曲调,那么你可以替换自己分支中的文件,并更新中定义的曲调字符串 PX4_DEFINE_TUNE.

添加新乐曲

待开发