pikopiko 0.1.0

MML parser, compiler and chiptune player for games, with diagnostics designed for tools and AI.
Documentation
//! PikoPiko の効果音音源 `sfx`(レトロ系)。
//!
//! sfxr / bfxr の系統の効果音(コイン、レーザー、爆発、パワーアップ、ダメージ、ジャンプ、
//! 選択音)を、パラメータ 1 組から作る。2 つの層でできている。
//!
//! 1. **合成エンジン**([`SfxParams`]、[`Voice`]、[`render_mono`]、[`generate`]、[`mutate`]):
//!    `pikopiko-runtime` の `synth::sfx`(`sfx` 機能)。MML を知らない。整数だけで計算し、
//!    ヒープを使わないので `no_std` のマイコンでも動く。ここからも同じ名前で使える。
//! 2. **音源**:`#synth sfx` で選べる MML の音源。
//!    音符 1 つで効果音を頭から 1 回鳴らし(ワンショット)、音符の高さで音程をずらす
//!    (`o4 c` が `%freq` の高さ)。音色 `@n` がカテゴリのプリセットで、`%` で上書きする。
//!
//! ```
//! // MML で
//! let src = "#synth sfx\nA @0 o4 c4 @1 %freq=96 c4 @2 o3 c2";
//! let (song, diags) = pikopiko::synth::compile(src);
//! assert!(diags.is_empty(), "{diags:?}");
//! let pcm = pikopiko::synth::render(&song.unwrap(), 44_100, 0);
//! assert!(!pcm.is_empty());
//! // Rust の API で(MML なし、ヒープなし)
//! use pikopiko::synth::sfx::{generate, render_mono, Category};
//! let p = generate(Category::Laser, 42);
//! let mut buf = [0i16; 44_100];
//! let n = render_mono(&p, 44_100, &mut buf);
//! assert!(n > 0);
//! ```
//!
//! パラメータはテキスト(`@n %名前=値 …`)と相互に変換でき([`SfxParams::write_text`]、
//! [`SfxParams::parse`])、MML・エディタ・AI の間でそのまま受け渡せる。

/// このモジュールの文の表(`locales/` の機能の部分。音源の説明・エラーの文)。機能を入れたときだけ入る。
#[allow(dead_code)]
pub(crate) mod text_table {
    use crate::text::{Catalog, Seg};
    include!(concat!(env!("OUT_DIR"), "/text-sfx.rs"));
}

mod adapter;
pub mod presets;

pub use pikopiko_runtime::synth::sfx::*;

pub use adapter::{SfxSynth, SFX};