#owl #dsp #synthesizer #embedded

nightly no-std owl_patch

Rust SDK for Rebel Technology Owl2/3 devices

8 unstable releases (3 breaking)

new 0.4.0 Feb 20, 2025
0.3.1 Feb 16, 2025
0.2.1 Feb 4, 2025
0.2.0 Jan 24, 2025
0.1.2 Nov 19, 2024

#172 in Audio

Download history 373/week @ 2024-11-19 13/week @ 2024-11-26 118/week @ 2024-12-03 93/week @ 2024-12-10 23/week @ 2024-12-17 22/week @ 2024-12-24 20/week @ 2024-12-31 26/week @ 2025-01-07 4/week @ 2025-01-14 103/week @ 2025-01-21 11/week @ 2025-01-28 124/week @ 2025-02-04 181/week @ 2025-02-11

419 downloads per month

MIT/Apache

6.5MB
96K SLoC

C 87K SLoC // 0.3% comments C++ 5.5K SLoC // 0.1% comments Rust 2.5K SLoC // 0.0% comments Python 525 SLoC // 0.3% comments JavaScript 236 SLoC // 0.1% comments GNU Style Assembly 224 SLoC // 0.2% comments Shell 43 SLoC // 0.1% comments

Owl Patch

GitHub Actions Workflow Status Docs crates.io License

Write Patches in Rust for many Rebel Technology devices based on the Owl2/3 modules.

#![no_main]
#![no_std]
extern crate alloc;
use alloc::boxed::Box;
use owl_patch::{
    patch,
    program_vector::{heap_bytes_used, ProgramVector},
    sample_buffer::{Buffer, Channels, ConvertFrom, ConvertTo},
};

#[patch("Example Patch")]
fn main(mut pv: ProgramVector) -> ! {
    let audio_settings = pv.audio().settings;
    let mut buffer: Buffer<Channels, Box<[f32]>> =
        Buffer::new(audio_settings.channels, audio_settings.blocksize);
        
    pv.meta().set_heap_bytes_used(heap_bytes_used());
    pv.audio().run(|input, output| {
        buffer.convert_from(input);
        // Do something clever with the samples in the buffer
        buffer.convert_to(output);
    });
}

Getting Started

  1. Make sure you have the thumbv7em-none-eabihf Rust target installed:
rustup target add thumbv7em-none-eabihf
  1. Install gcc-arm-none-eabi and FirmwareSender. See the instructions on https://github.com/RebelTechnology/OwlProgram for details.

  2. Create a new binary package using Cargo, and add this repo as a dependency:

[dependencies]
owl_patch = "0.4.0"

It is also a good idea to add this to your Cargo.toml:

[profile.release]
codegen-units = 1
debug = 2
debug-assertions = false
incremental = false
lto = "fat"
opt-level = 3
overflow-checks = false

[profile.release.package."*"]
opt-level = 3
  1. Create a .cargo/config.toml file:
[build]
target = "thumbv7em-none-eabihf"

# For Owl 2
[target.thumbv7em-none-eabihf]
rustflags = [
    "-C", "link-arg=--nmagic",
    "-C", "target-cpu=cortex-m4",
    "-C", "link-arg=-Towl2.ld",
]

# For Owl 3
#[target.thumbv7em-none-eabihf]
#rustflags = [
#    "-C", "link-arg=--nmagic",
#    "-C", "target-cpu=cortex-m7",
#    "-C", "link-arg=-Towl3.ld",
#]
  1. Copy one of the examples into src/main.rs

  2. Build your patch

cargo build --release
  1. Use arm-none-eabi-objcopy to get the final binary:
arm-none-eabi-objcopy -O binary target/thumbv7em-none-eabihf/release/main target/thumbv7em-none-eabihf/release/main.bin
  1. Use FirmwareSender to upload the patch to your device.

For further help, check the docs.

Supported devices

The examples in this repo have been tested on a Befaco Lich using Owl2 and Owl3 modules. They should work on others too, but I am unable to verify this. To give you the best chance of success, make sure your device is running the latest Firmware.

Crate Features

  • talc (default): Uses the talc crate as the global allocator. If you want to use a different allocator, turn this feature off with default-features = false
  • fastmaths (default): Enables the fast approximate maths functions in the fastmaths module.
  • vpo_fastmaths (default): Use fastmaths functions in the volts_per_octave module to convert between Volts and Frequencies quicker (but less accurately). Requires fastmaths.

Project state

Experimental, but already pretty usable.

Working features:

  • Output correctly linked binary including patch header
  • Safe API wrapper for the ProgramVector, allowing communication with the host OS
  • Register Patch with host OS
  • Global Allocator using talc
  • Process Audio in i32 and f32 formats
  • Simple Audio Buffer implementation, supporting different formats and layouts
  • Register, get, and set Patch Parameters, with callback for button events
  • Send & Receive Midi messages
  • Debug / error messages
  • Get i/o callibration data for volts-per-octave conversions
  • Get system log / pow tables to perform fast maths functions
  • Load resource files
  • FFT init service calls
  • Write to screen buffer (on devices with a screen)

Todo List:

  • Empty!!

Maybe pile:

  • Additional device support
  • Invert some params for hardware_version == OWL_MODULAR_HARDWARE
  • Support for lower checksum versions
  • Create a Cargo project template
  • Support for Colour screens

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this repository by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note

The authors of this repository are not affiliated with Rebel Technology. The Owl Platform and associated published code is their copyright.

Dependencies

~2.3–5.5MB
~109K SLoC