|
Sound Byte Libs 1ee2ca6
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
Template-based C++ firmware for ARM Cortex-M processors
We build with a painter's workshop as our guiding abstraction. In this concept, the hardware is the canvas, Sound Byte Libs is the toolkit (paint, brushes, palette knives, etc), and the application is the artwork.
Sound Byte Libs uses a layer-based architecture where each layer builds on those below it:
Location: src/sbl/hal/
Direct hardware access templates that resolve to platform-specific implementations:
Location: src/sbl/primitives/
Essential data structures and algorithms with no hardware dependencies:
primitives/buffers/ - Ring buffers, FIFOsprimitives/containers/ - Fixed arrays, listsprimitives/math/ - Integer math, fixed-point utilitiesprimitives/io/ - Lightweight printf implementationLocation: src/sbl/patterns/
Template-based patterns that combine primitives with HAL:
patterns/timing/ - Non-blocking delays, interval timerspatterns/synchronization/ - Critical sections, atomic operationspatterns/events/ - Event broadcasting, observersLocation: src/sbl/components/
Mid-level functional components for common hardware interfaces:
components/display/ - LEDs, basic displayscomponents/cv/ - Trigger generators, gate handlerscomponents/input/ - Buttons, encodersApplications combine components and patterns to build complete functionality. The library provides building blocks; applications compose them according to their specific needs.
Common (src/sbl/common/): Shared constants, sensible defaults, cross-layer utilities
Utils (src/sbl/utils/): Development and debugging tools like logging
Validation (src/sbl/validation/): Compile-time validation and error messaging
When you build, templates resolve to concrete platform types. A GPIO template becomes STM32 HAL calls, RP2040 SDK calls, or SAMD peripheral access - whatever your specific ARM Cortex-M platform provides.
Minimal runtime dispatch, optimized for ARM Cortex-M with direct hardware access wrapped in clean APIs.
The core library contains zero platform-specific code. No #ifdef blocks, no hardcoded platform names, no conditional compilation.
MCU driver implementations are maintained separately in the sbl-hardware repository. The build system discovers them via sloth resolution from sbl.json.
This approach provides architectural integrity. Every MCU is equal - there are no defaults or preferred platforms baked into the core library.
Applications define hardware through sbl.json, which points to a mainboard manifest. The sloth tool resolves the manifest chain and generates <sbl/hw/hardware.hpp> with compile-time constants.
See namespaces.md for the namespace structure.
Static allocation only.
MCU drivers are maintained in sbl-hardware and implement the HAL interfaces. Exclusively supports 32-bit ARM Cortex-M processors.
Hardware is described using JSON manifests that define connections and generate type-safe handles at build time. The manifest system supports:
Mainboards expose pins and buses; modules claim them. The resolver walks the attaches_to chain to map logical pin names to physical MCU registers with conflict detection.
See the Hardware Schema Documentation for schema definitions and diagrams.
Sound Byte Libs enforces platform implementations through compile-time SFINAE validation. Every platform must satisfy interface contracts with clear error messages guiding implementation.
Typical audio application setup:
Environment variables point to library locations:
SBL_PATH - Path to sound-byte-libsSBL_HW_PATH - Path to sbl-hardware