Expand description
Duty-modulated PWM audio for embedded targets: effect banks, tiered DSP, mixing.
§Quick start
ⓘ
use embedded_audio::prelude::*;
let bank = SoundBank::parse(FLASH_BLOB)?;
let mut engine = AudioEngine::new(AudioConfig::default_duty());
engine.set_bank(bank);
engine.play(1, AdsrSpec::click())?;
// In a timer ISR at `config.sample_rate_hz`:
let duty = engine.tick();§Tiers
| Tier | Source | Use |
|---|---|---|
| A | Tone / wavetable / FM synth | UI beeps, alarms |
| B | PCM8 / IMA ADPCM in flash | Sampled SFX |
| C | Packed ΣΔ bitstream | Premium short sounds |
Build banks on the host with the eaf-bake tool (std feature).
§Procedural extras
Standalone building blocks, composed manually rather than driven through the bank format:
pluck::KarplusPluck (Karplus-Strong string) and fx (Overdrive, Wavefolder,
Tremolo) need no extra feature; [drums] (AnalogBassDrum, AnalogSnareDrum, HiHat)
and [dsp] need the dsp feature.
Re-exports§
pub use bank::BANK_BUILD_CAP;pub use bank::BANK_MAGIC;pub use bank::BANK_VERSION;pub use bank::BankBuilder;pub use bank::EffectEntry;pub use bank::SoundBank;pub use config::AudioConfig;pub use config::DEFAULT_PWM_CARRIER_HZ;pub use config::DEFAULT_PWM_PERIOD;pub use config::DEFAULT_SAMPLE_RATE_HZ;pub use config::crossfade_step_q8;pub use decode::AdpcmDecoder;pub use decode::AdpcmStream;pub use decode::Pcm8Stream;pub use engine::AudioEngine;pub use engine::VoiceStealingPolicy;pub use envelope::Adsr;pub use envelope::AdsrSpec;pub use error::AudioError;pub use fixed::db_to_q8;pub use fixed::q8_to_db;pub use fx::Overdrive;pub use fx::Tremolo;pub use fx::Wavefolder;pub use hal::DmaDoubleBuffer;pub use hal::DutyBuffer;pub use hal::PwmDutySink;pub use hal::fill_buffer_into;pub use hal::fill_dma_half_buffers;pub use hal::tick_into;pub use output::DutyMode;pub use output::PwmMapper;pub use output::SigmaDelta;pub use output::SigmaDelta2ndOrder;pub use output::pcm_to_dac_u8;pub use output::pcm_to_dac_u12;pub use output::pcm_to_dac_u16;pub use output::pcm_to_i16;pub use output::pcm_to_i32;pub use pluck::KarplusPluck;pub use source::VoiceSource;pub use stream::SigmaDeltaBitStream;pub use synth::FmVoice;pub use synth::PULSE_25_TABLE;pub use synth::SAW_TABLE;pub use synth::SINE_TABLE;pub use synth::SQUARE_TABLE;pub use synth::TRIANGLE_TABLE;pub use synth::ToneParams;pub use synth::ToneVoice;pub use synth::Waveform;pub use synth::WavetableVoice;pub use synth::generate_wavetable_fixed;pub use tier::EffectKind;pub use tier::flags;
Modules§
- bank
- config
- decode
- engine
- envelope
- error
- fixed
- fx
- Lightweight per-sample effects ported from DaisySP’s
Effectsmodule: waveshaping distortion, wavefolding, and tremolo. All three run oni8PCM with plain arithmetic (nolibm/std), so they’re part of the always-on core rather than thedspfeature. - hal
- output
- pluck
- Karplus-Strong plucked-string synthesis.
- prelude
- source
- stream
- synth
- tier
- voice