Sound Byte Libs 1ee2ca6
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Sound Byte Libs

C++ firmware library for embedded audio on ARM Cortex-M

What is Sound Byte Libs?

Sound Byte Libs is a library for building musical instruments and audio applications on 32-bit ARM microcontrollers.

Write once, run on multiple targets. SBL provides useful building blocks without imposing structure on your application. Through compile-time template polymorphism, you get hardware portability with zero-overhead abstractions.

Key features:

  • Cross-platform: Same code runs on RP2040, RP2350, STM32H7
  • Bare-metal: No vendor HALs - SVD-generated register definitions
  • Tiny binaries: ~1KB for hello-blinker on STM32H750
  • Audio-focused: Designed for real-time constraints

Quick Start

Prerequisites: ARM GCC toolchain (arm-none-eabi-gcc)

# Clone the ecosystem
git clone https://github.com/mjrskiles/sound-byte-libs.git
git clone https://github.com/mjrskiles/sound-byte-libs-examples.git
git clone https://github.com/mjrskiles/sbl-hardware.git
# Set environment
export SBL_PATH=/path/to/sound-byte-libs
export SBL_HW_PATH=/path/to/sbl-hardware
# Build for Raspberry Pi Pico 2
cd sound-byte-libs-examples/hello-blinker
cmake --preset pico2
cmake --build build/pico2
# Flash: copy build/pico2/hello_blinker.uf2 to Pico in BOOTSEL mode

Note: For RP2xxx targets, you'll also need the Pico SDK and PICO_SDK_PATH set. The build system handles SDK integration automatically via hooks.

Code Example

#include <sbl/hw/hw.hpp> // Single include: drivers + generated config
int main() {
sbl::driver::init();
// LED handle resolved at build time from hardware manifest
constexpr auto led = sbl::hw::gpio::status_led;
sbl::driver::Gpio::set_mode(led, sbl::gpio::PinMode::Output);
while (true) {
sbl::driver::Gpio::toggle(led);
sbl::driver::Timer::delay_ms(500);
}
}
Uber-umbrella header for all target-specific code.

Build System

SBL provides optional CMake hooks that simplify SDK integration. Our examples use them, but you can wire up builds however you prefer.

include($ENV{SBL_PATH}/tools/cmake/SblHooks.cmake)
sbl_pre_project() # Resolves hardware, sets up SDK
project(my_app C CXX ASM)
sbl_post_project() # Initializes SDK, creates sbl::driver
add_executable(my_app src/main.cpp)
target_link_libraries(my_app PRIVATE sbl::driver)
sbl_finalize(my_app) # Generates .uf2, .bin, .hex as needed

When using hooks, they read your target manifest and:

  • RP2xxx targets: Load Pico SDK, call pico_sdk_init(), generate UF2
  • STM32 targets: Configure bare-metal ARM toolchain, generate BIN/HEX
  • Custom targets: Override hooks or skip them entirely

Platform Support

Platform MCU Core Status
Raspberry Pi Pico RP2040 Cortex-M0+ Supported
Raspberry Pi Pico 2 RP2350 Cortex-M33 Supported
Daisy Seed STM32H750 Cortex-M7 Supported
Native Simulator x86/ARM host - Planned

Peripheral Support

Peripheral RP2040 RP2350 STM32H7
GPIO yes yes yes
Timer yes yes yes
UART yes yes yes
ADC - - yes
DMA - - -
I2S - - -

Tools

SBL provides three Python tools that work together:

Tool Purpose When Run
cecrops SVD → C++ register headers Rare (new MCU/peripheral)
sloth Hardware resolution → config headers Every build (via CMake)
sbl Project configuration and utilities Project setup, queries

sloth - Hardware Resolution

sloth (Sound Byte Labs Open Tool for Hardware) resolves hardware manifests and generates type-safe C++ headers.

# Resolve and show hardware graph
python -m sloth graph targets/pico2.json
# Generate config headers
python -m sloth generate targets/pico2.json -o build/generated
# Query MCU info (used by CMake hooks)
python -m sloth resolve targets/pico2.json --print-mcu-name

cecrops - Register Generation

cecrops generates C++ register definitions from CMSIS-SVD files with manifest-driven configuration and integrated patching for SVD errata.

# Generate register headers from SVD
python -m cecrops generate sbl-hardware/mcu/arm/stm32h750
# Show SVD file info
python -m cecrops info path/to/file.svd

Each MCU using cecrops has a cecrops.json manifest defining SVD source, output peripherals, and patches. See FDP-009 for design details.

sbl - Project CLI

sbl provides project configuration and utility commands.

# Initialize a new SBL project
python -m sbl_cli init my-project --target pico2
# Show project info
python -m sbl_cli info

Repository Structure

sound-byte-labs/ # Workspace
├── sound-byte-libs/ # Core library (this repo)
│ ├── src/sbl/ # Library source
│ ├── tools/ # sloth, cmake hooks
│ └── docs/ # Documentation
├── sbl-hardware/ # Hardware definitions & drivers
│ ├── mcu/ # MCU definitions + drivers
│ └── mainboards/ # Board manifests
└── sound-byte-libs-examples/ # Working examples
├── hello-blinker/ # LED blinking
├── hello-uart/ # Debug output
└── hello-adc/ # ADC reading

Documentation

Document Description
Architecture System design and layer model
Hardware System sloth, manifests, code generation
Namespaces Namespace structure and includes
Roadmap Development milestones

Design Philosophy

  • Bare metal first - No vendor HALs, SVD-generated registers
  • Every byte matters - We celebrate small binaries
  • Audio timing - Designed for real-time constraints
  • Cross-vendor - Avoid platform lock-in
  • Templates for performance - Clean APIs, zero runtime overhead

License

Copyright (c) 2025 Michael Skiles. See LICENSE file.