Hello everyone. I made a crate for making music with Rust. It's called tunes.
https://crates.io/crates/tunes
I accidentally made tunes while trying to create an audio engine for the game I'm building. Tunes initially started as just an audio synthesis project to make basic sounds. After having fun making a few funny sounds, I quickly realized that I wanted to create procedural, algorithmic sounds. I've always loved music and leaned into classical music theory a bit. I wanted something that could help me make the sounds I wanted, when I wanted, like an instrument. It turned into ~35k lines of code/docs/tests/examples.
There are a lot of things in here:
An ergonomic builder...
Hello everyone. I made a crate for making music with Rust. It's called tunes.
https://crates.io/crates/tunes
I accidentally made tunes while trying to create an audio engine for the game I'm building. Tunes initially started as just an audio synthesis project to make basic sounds. After having fun making a few funny sounds, I quickly realized that I wanted to create procedural, algorithmic sounds. I've always loved music and leaned into classical music theory a bit. I wanted something that could help me make the sounds I wanted, when I wanted, like an instrument. It turned into ~35k lines of code/docs/tests/examples.
There are a lot of things in here:
An ergonomic builder pattern api
Tons of music theory helpers (algorithmic sequences, scales, chords, progressions, key and time signatures, classical ornaments, microtonal support)
Over 20 fully automated effects and filters (delay, reverb, phaser, flanger, etc),
jit rendered sound synthesis to keep compiles less... compiley, but still custom instruments/voices, multiple waveforms, wavetable synthesis, fm synthesis and more
wav sample import, wav and midi export
Here's an example of just playing a chord and a scale:
fn main() -> Result<(), anyhow::Error> {
let mut comp = Composition::new(Tempo::new(140.0));
comp.instrument("lead", &Instrument::electric_piano())
.chords(&[C4_MAJOR], 1.0)
.scale_updown(C4_MAJOR_SCALE, 0.2);
let engine = AudioEngine::new()?;
engine.play_mixer(&comp.into_mixer())?;
Ok(())
}
And you can just keep on chaining from there. Overall, it feels nice to compose with. But I'll be straightforward: this is not a live music repl coding style. There are still compiles. Granted, they're nearly instant, but it's not live. I'm probably not smart enough to figure out how to support that with rust and it wasn't my goal. This is more meant to be on the composition side of things, rather than the live music side. Which is too bad because that scene is awesome and I really hope some of them take interest in making some music with rust using this crate! To everyone out there who makes some sound with it... best of luck and I hope to hear your pieces soon!