audio-midi-shell

Crates.ioaudio-midi-shell
lib.rsaudio-midi-shell
version0.1.0
created_at2025-12-05 10:46:25.504355+00
updated_at2025-12-05 10:46:25.504355+00
descriptionPrototyping shell for audio development.
homepage
repositoryhttps://github.com/sourcebox/audio-midi-shell-rs
max_upload_size
id1968001
size35,012
Oliver Rockstedt (sourcebox)

documentation

README

audio-midi-shell

Cross-platform wrapper around tinyaudio and midir for prototyping audio algorithms as standalone applications.

It opens the default audio output device with a given sample rate and buffer size. MIDI messages are received from all detected MIDI inputs ports. The process chunk size can be set independently from the buffer size.

Usage

use audio_midi_shell::{AudioMidiShell, AudioGenerator};

const SAMPLE_RATE: u32 = 44100;
const BUFFER_SIZE: usize = 1024;
const PROCESS_CHUNK_SIZE: usize = 16;

fn main() -> ! {
    AudioMidiShell::run_forever(SAMPLE_RATE, BUFFER_SIZE, PROCESS_CHUNK_SIZE, TestGenerator);
}

struct TestGenerator;

impl AudioGenerator for TestGenerator {
    fn init(&mut self, chunk_size: usize) {
        // Optional function, called once on startup for initialization tasks.
    }

    fn process(&mut self, frames: &mut [[f32; 2]]) {
        // Called periodically with a buffer of `PROCESS_CHUNK_SIZE` samples.
        // Fill `frames` with sample data accordingly.
    }

    fn process_midi(&mut self, message: &[u8], timestamp: u64) {
        // Optional function, called on each incoming MIDI message.
    }
}

Example

The examples directory contains a simple monophonic synthesizer playing a sine wave for each received note.

    cargo run --example sine_synth

License

Published under the MIT license. Any contribution to this project must be provided under the same license conditions.

Author: Oliver Rockstedt info@sourcebox.de

Commit count: 0

cargo fmt