A Rust environment for sound synthesis and algorithmic composition.

Overview

Sorceress

built with nix Crates.io docs.rs docs Gitter

A Rust environment for sound synthesis and algorithmic composition, powered by SuperCollider.

Sorceress

Overview

Sorceress is a Rust crate that provides a creative coding environment for:

  • Sound synthesis - build audio synthesizers by connecting unit generators together into signal graphs. SuperCollider provides hundreds of unit generators to choose from including things like wave generators, noise generators, filters, envelopes, compressors, resonators, physical simulations, Fourier transforms, and much more.

  • Algorithmic composition - write code to create music, anywhere from using code as a musical notation system to full-fledged generative composition where large scale structures of a music piece are determined by computational algorithms.

Why SuperCollider?

SuperCollider is a powerful and mature platform for audio synthesis with decades of development effort behind it. SuperCollider's Client and Server architecture lets us to leverage all of the features offered by SuperCollider's audio synthesis server, from Rust:

  • A real-time audio synthesis engine
  • A massive library of unit generators
  • Audio I/O with your operation system and sound card

Why Rust?

There are projects in many other programming languages for interacting with SuperCollider including Overtone, Tidal, and Sonic Pi. I really like programming in Rust and I could not find any such project using Rust so I started building Sorceress.

Example

This example plays a sine wave at 220 Hz for 1 second:

use anyhow::Result;
use sorceress::{
    server::{self, Server},
    synthdef::{encoder::encode_synth_defs, SynthDef},
    ugen,
};
use std::{thread::sleep, time::Duration};

fn main() -> Result<()> {
    let server = Server::new("127.0.0.1:57110")?;

    let sine_wave = SynthDef::connect(
        "sine_wave",
        ugen::Out::ar().channels(ugen::Pan2::ar().input(ugen::SinOsc::ar().freq(220))),
    );
    let encoded_synthdef = encode_synth_defs(vec![sine_wave])?;
    server.send_sync(server::SynthDefRecv::new(&encoded_synthdef))?;

    server.send(server::SynthNew::new("sine_wave", 1, vec![]))?;
    sleep(Duration::from_secs(1));

    server.reset()?;

    Ok(())
}

Setup

With cargo-edit installed run:

$ cargo add sorceress

You must install SuperCollider separately from the sorceress crate.

Note: Sorceress does not run SuperCollider for you at this time, so you must boot a server yourself. The recommended way to do this by starting the server in scide, SuperCollider's built in IDE.

Documentation

The primary source of documentation for Sorceress is the crate documentation on docs.rs.

Contributing

See CONTRIBUTING for details on creating issues or making pull requests.

License

Sorceress is free software available under Version 3 the GNU General Public License. See COPYING for details.

You might also like...
Auritia is a DAW coded in Rust and Vue in hopes of having cross platform compatability, while also providing enough features for anyone to use professionally
Auritia is a DAW coded in Rust and Vue in hopes of having cross platform compatability, while also providing enough features for anyone to use professionally

Steps Install WebView if you're not on Windows 11 Install Node deps npm i To run the dev server do npm run tauri dev Compiling Linux You will need to

Loopers is graphical live looper, written in Rust, designed for ease of use and rock-solid stability
Loopers is graphical live looper, written in Rust, designed for ease of use and rock-solid stability

Loopers Loopers is a graphical live looper, written in Rust, designed for ease of use and rock-solid stability. It can be used as a practice tool, com

Simple examples to demonstrate full-stack Rust audio plugin dev with baseplug and iced_audio
Simple examples to demonstrate full-stack Rust audio plugin dev with baseplug and iced_audio

iced baseplug examples Simple examples to demonstrate full-stack Rust audio plugin dev with baseplug and iced_audio WIP (The GUI knobs do nothing curr

A wav encoding and decoding library in Rust

Hound A wav encoding and decoding library in Rust. Hound can read and write the WAVE audio format, an ubiquitous format for raw, uncompressed audio. T

Rust task runner and build tool.

cargo-make Rust task runner and build tool. Overview Installation Binary Release Usage Simple Example Tasks, Dependencies and Aliases Commands, Script

PortAudio bindings and wrappers for Rust.

rust-portaudio PortAudio bindings and wrappers for Rust. PortAudio is a free, cross-platform, open-source, audio I/O library. rust-portaudio is still

ears is a simple library to play Sounds and Musics in Rust

ears ears is a simple library to play Sounds and Musics in Rust. ears is build on the top of OpenAL and libsndfile. Provides an access to the OpenAL s

A low-overhead and adaptable audio playback library for Rust

Awedio   A low-overhead and adaptable audio playback library for Rust. Examples Play a single sound file: let (mut manager, backend) = awedio::start()

Rust-crate with functions and helpers for working with music / audio, inspired by computer music languages.

music-math This crate contains common functions and helpers for working with music / audio in Rust. Most of these are inspired by similar functions fo

Comments
  • Add examples

    Add examples

    Hi again.

    I'm building some small projects while I learn how to use this crate. Would you be interested in adding those as examples in this repository?

    I already moved the example in the README inside an examples folder, so I can run it with:

    cargo run --release --examples sinewave
    

    The only thing changed is that I used .expect rather than propagating the error with anyhow just to avoid adding the dependency in the repository.

    I already have another example to play a .wav file from the file system.

    If you are ok with it I can open a PR for each example while I write them.

    opened by Psykopear 2
  • Example in the README not working

    Example in the README not working

    Hi ooesili!

    I saw this project on This week in Rust, and since I wanted to build something similar to be able to control SuperCollider from whithin Rust, I'm really happy to see some of the work is already done.

    I tried creating a new project and running the code in the README.md file and noticed that it probably isn't up to date with the repository.

    I had to make some minor fixes to make it work, but in the end I could hear the sinewave generated by the running SC server.

    If you'd like I can open a Pull Request to fix the example in the README, this is how I had to modify it to make it work:

    use anyhow::Result;
    use sorceress::{
        server::{self, Server},
        synthdef::{encoder::encode_synth_defs, SynthDef},
        ugen,
    };
    use std::{thread::sleep, time::Duration};
    
    fn main() -> Result<()> {
        let server = Server::connect("127.0.0.1:57110")?;
    
        let sine_wave = SynthDef::new("sine_wave", |_| {
            ugen::Out::ar().channels(ugen::Pan2::ar().input(ugen::SinOsc::ar().freq(220)))
        });
        let encoded_synthdef = encode_synth_defs(vec![sine_wave]);
        server.send_sync(server::SynthDefRecv::new(&encoded_synthdef))?;
    
        server.send(server::SynthNew::new("sine_wave", 1))?;
        sleep(Duration::from_secs(1));
    
        server.reset()?;
    
        Ok(())
    }
    
    opened by Psykopear 2
  • Live reloading development workflow

    Live reloading development workflow

    Some ideas regarding the live reloading development workflow.

    • I have had success with https://crates.io/crates/dynamic_reload for live reloading of Rust DLLs (auto rebuilding the DLL with cargo watch -x build) for the purpose of live coding in Rust. (This can also be made ABI-stable with https://crates.io/crates/abi_stable but when compiling host and DLL with the same nightly, I had no issues.)
    • Here is a Rust evaluator: https://crates.io/crates/evcxr (used by https://crates.io/crates/evcxr_repl)
    • Here is another Rust evaluator that can be embedded into any host: https://crates.io/crates/irust_repl It was factored out of IRust to make it easily re-useable from other hosts, after I raised this issue: https://github.com/sigmaSd/IRust/issues/77 These evaluators can be combined with file reloading after saving a file, by using https://crates.io/crates/hotwatch, https://crates.io/crates/notify or https://crates.io/crates/warmy

    Other relevant links: https://github.com/Michael-F-Bryan/plugins_in_rust https://adventures.michaelfbryan.com/posts/plugins-in-rust/

    Btw, someone also implemented a UGen in Rust: http://www.andrewchristophersmith.com/2015/01/01/implementing-a-supercollider-external-in-rust/ https://github.com/andrewcsmith/vox_box_supercollider

    opened by Boscop 1
Owner
Wesley Merkel
Wesley Merkel
DSP real time audio synthesis, effect algorithms and utilities for Rust

synfx-dsp synfx-dsp DSP real time audio synthesis, effect algorithms and utilities for Rust Most of the algorithms and implementations in this library

Weird Constructor 8 Nov 23, 2022
A CLI and library to convert data to sound, and vice versa (dependency-free)

Data to sound A simple crate to convert data to sound, and sound to data. The sound file format is wave (.wav). You can use it as a library or as a co

Awiteb 8 Feb 28, 2023
Procedural engine sound generator controlled via GUI or CLI

enginesound GUI Application used to generate purely synthetic engine sounds with advanced options written in Rust loosely based on this paper Reading

null 198 Dec 30, 2022
A constructive audio programming environment with timeline-based view

otopoiesis a constructive audio programming environment with timeline-based view. Todo project file export/import Wav file loading file io streaming(w

Tomoya Matsuura 3 Dec 15, 2022
Symphonia is a pure Rust audio decoding and media demuxing library supporting AAC, FLAC, MP3, MP4, OGG, Vorbis, and WAV.

Pure Rust multimedia format demuxing, tag reading, and audio decoding library

Philip Deljanov 1k Jan 2, 2023
A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without altering any audio information.

OptiVorbis A library and application for lossless, format-preserving, two-pass optimization and repair of Vorbis data, reducing its size without alter

OptiVorbis 27 Jan 3, 2023
Idiomatic Rust bindings for OpenAL 1.1 and extensions (including EFX).

alto alto provides idiomatic Rust bindings for OpenAL 1.1 and extensions (including EFX). WARNING Because Alto interacts with global C state via dynam

null 80 Aug 7, 2022
High-level PortMidi bindings and wrappers for Rust

portmidi-rs High-level PortMidi bindings for Rust. PortMidi website: http://portmedia.sourceforge.net/portmidi/ Installation Add this to your Cargo.to

Philippe Delrieu 69 Dec 1, 2022
PortAudio bindings and wrappers for Rust.

rust-portaudio PortAudio bindings and wrappers for Rust. PortAudio is a free, cross-platform, open-source, audio I/O library. rust-portaudio is still

null 331 Dec 23, 2022
Implements the free and open audio codec Opus in Rust.

opus-native Overview Implements the free and open audio codec Opus in Rust. Status This crate is under heavy development. Most functionality is not wo

Nils Hasenbanck 9 Nov 28, 2022