Code Monkey home page Code Monkey logo

sorceress's Introduction

Sorceress

built with nix Build Status 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 sorceress::{
    server::{self, Result, 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(())
}

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.

sorceress's People

Contributors

ooesili avatar psykopear avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sorceress's Issues

Will the project continue to be developed?!

Such a fantastic project, and thank you for your efforts.

Was especially looking forward to playing with ugen::Klang, which doesn't seem to have been included.

Do you think the project continue to be developed?!

Live reloading development workflow

Some ideas regarding the live reloading development workflow.

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

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(())
}

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.