DEKI/ENGINE 文档
deki-audio 0.19.0
Deki 包参考
deki-audio

音频播放外设。通过 I²S 驱动 MAX98357 D 类功放。

仓库:github.com/dekiengine/deki-audio · 最新版本:0.19.0 · 需要引擎 0.19.0 或更高版本 · 依赖:deki-i2s

使用 DekiEditor --packages-add deki-audio <project> 或通过包管理器安装。引擎自身的组件和 C++ API 见 Deki 文档。

在编辑器中显示为 **Audio (Speaker / PCM playback)**。

组件

组件 类别 说明
MAX98357AudioComponent 传感器 通过 MAX98357A I2S 功放播放声音。

功能开关

可以从构建中去掉的部分。带有 define 的功能通过该 define 开关,其余的随其组件一起被剥离。

功能 define 默认值
MAX98357A (I²S class-D mono amp, 16-bit PCM) DEKI_FEATURE_AUDIO_MAX98357 开

组件参考

MAX98357AudioComponent

通过 MAX98357A I2S 功放播放声音。

检视器中的名称:MAX98357A 音频 · 类别:传感器 · 类型:DekiAudio::MAX98357AudioComponent

属性 类型 默认值 约束 说明
i2sPort int32 0 0 到 1 由芯片的哪个 I2S 控制器驱动功放。大多数开发板只用一个。
bclkPin int32 39 0 到 48 传输位时钟(BCLK)的 GPIO,每个音频位跳变一次。
lrclkPin int32 40 0 到 48 传输字选择线(LRCLK 或 WS)的 GPIO,用于区分左右声道的采样。有些开发板标为 LRC。
dinPin int32 5 0 到 48 向功放传输音频数据的 GPIO(DIN)。声音实际就是通过这条线传输的。
sampleRate int32 16000 8000 到 48000 每秒的采样数。16 kHz 对语音和音效已经足够,占用内存也少;44100 是 CD 采样率,带宽开销接近三倍。
channels int32 1 1 到 2 1 为单声道,2 为立体声。MAX98357 是单声道功放,因此除非为另一个声道再接一片,否则立体声素材会被混合为单声道。
initialVolume int32 80 0 到 100 启动时的音量,范围 0 到 100。在第一个声音播放前生效,因此项目可以以较小音量启动,而不是满音量输出。

更新日志

更新日志为英文。

0.19.0

Changed

  • minEngine 0.19.0: built against engine 0.19.0, whose component metadata records the package each class is in. A build of this package from before does not load and is rebuilt.

Added

  • Japanese, Simplified Chinese and Korean: editor/lang/ja.json, zh.json and ko.json translate the names, tooltips and enum values this package's components show in the Inspector.
  • The package's editor text goes through the editor's translation (Tr), so it shows in the editor's language. Needs the editor release that adds Localization.h; raise minEngine to it when releasing.

0.18.0

Changed

  • minEngine 0.18.0. Reflection ABI 21: the package must be rebuilt.
  • Names follow the code style (deki-engine/docs/codestyle): types, functions and enum values are PascalCase, constants kPascalCase, members m_PascalCase, locals and parameters camelCase. The code is formatted with clang-format 22.
  • The functions the editor finds by name are PascalCase: DekiAudioRegisterComponents, DekiAudioGetAutoComponentCount, DekiAudioEnsureRegistered and the rest. Built against engine ABI 21; a build of this package from before does not load and is rebuilt.

Fixed

  • MAX98357A: after Stop() the speaker stayed silent until a restart, because playing never turned the I2S channel back on. PlayPCM now does.
  • MAX98357A: PlayPCM copied the whole clip into internal RAM to apply the volume, so a long clip ran the board out of memory. It now scales a small chunk at a time.
  • MAX98357A: initializing twice leaked the first I2S channel, and a channel that failed to start was left open.

Removed

  • The former names from before 0.16.0 (bare class names, and deki-gpio's DekiEsp32::ESP32PinSetup). A scene that old is upgraded with 0.17 first.

更早的版本:CHANGELOG.md


由包的反射数据生成(引擎 0.19.0)。属性名就是场景文件中使用的键。重命名后会保留别名(兼容性)。