オーディオ再生用の周辺機器。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) と表示されます。
コンポーネント
機能フラグ
ビルドから外せる部分です。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 コントローラーでアンプを駆動するかです。ほとんどのボードは 1 つしか使いません。 |
| bclkPin | int32 | 39 | 0 から 48 | ビットクロック (BCLK) を送る GPIO です。オーディオの 1 ビットごとに 1 回刻みます。 |
| lrclkPin | int32 | 40 | 0 から 48 | ワードセレクト線 (LRCLK または WS) を送る GPIO で、左右のサンプルを区別します。LRC と表記しているボードもあります。 |
| dinPin | int32 | 5 | 0 から 48 | アンプへオーディオデータを送る GPIO (DIN) です。実際に音が流れるのはこの線です。 |
| sampleRate | int32 | 16000 | 8000 から 48000 | 1 秒あたりのサンプル数です。16 kHz は音声や効果音には十分で、メモリも少なく済みます。44100 は CD と同じレートで、帯域はおよそ 3 倍かかります。 |
| channels | int32 | 1 | 1 から 2 | 1 はモノラル、2 はステレオです。MAX98357 はモノラルのアンプなので、もう一方のチャンネル用に 2 つ目をつながない限り、ステレオの音はモノラルにまとめられます。 |
| 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)。プロパティ名はシーンファイルで使われるキーです。名前を変えても別名が残ります (互換性)。