Giter VIP home page Giter VIP logo

glicol-cli's Introduction


website website npm Discord GitHub

Glicol (an acronym for "graph-oriented live coding language") is a computer music language with both its language and audio engine written in Rust programming language, a modern alternative to C/C++. Given this low-level nature, Glicol can run on many different platforms such as browsers, VST plugins and Bela board. Glicol's synth-like syntax and powerful audio engine also make it possible to combine high-level synth or sequencer control with low-level sample-accurate audio synthesis, all in real-time.

Get started

๐Ÿš€ The Web App

The easiest way to try Glicol:

https://glicol.org

There you can find guides, demos, docs, and apps for collaboration.

Features
  • Near-native, garbage-collection-free and memory-safe real-time audio in web browsers

  • Quick reference in consoles with alt-d

  • The web app automatically loads samples; you can also drag and drop local samples in the browser editor

  • Robust error handling: error reported in console, but previous music will continue!

  • Mix JavaScript code to create visuals with Hydra synth made by @ojack

  • What you see is what you get, i.e. declarative programmering for both code writing and executing: no need to select anything, just change the code and update, Glicol engine will use LCS algorithm to handle adding, updating and removing

  • Decentralised collaboration using yjs and a unique be-ready mechanism

๐ŸŽ For Audio Dev

Description
NPM Docs Safe, performant, light-weight and ergonomic audio lib for web apps
Rust Audio Lib Write VST like this Dattorro reverb plugin
Run on Bela Run Glicol DSL on Bela board for quick audio prototyping.

๐Ÿฟ YouTube Channel

Find Glicol demo vidoes in this playlist.

Philosophy of Glicol

The motivation of Glicol is:

  • to help people with zero knowledge of coding and music production to get started with live coding

  • to offer experienced music coders a tool for quick prototyping and hacking

In NIME community, it is known as:

low entry fee and high ceilings

This is Glicol's philosophy to approach these goals:

  • design the language from a new instrument design perspective

  • embrace the spirit of the internet for a better experience

Reflected in the implementation:

  • Glicol adopts a graph-oriented paradigm

  • Glicol can be used in browsers with zero-installation

Graph-oriented

The basic idea of Glicol is to connect different nodes like synth modules.

All you need to know is the audio input/output behaviour of each node.

Two ways for connecting: >> and ~reference:

// amplitude modulation and lazy evaluation example
// chain with ~ is a ref chain and will not be sent to the DAC

o: sin 440 >> mul ~amp
~amp: sin 1.0 >> mul 0.3 >> add 0.5

It also applies to sequencer and sampler:

// sequencer pattern
// first divide one bar with space
// then further divide each part based on midi number and rest(_)

o: speed 2.0 >> seq 60 _~a _ 48__67
>> sp \blip

// quantity alters probability
~a: choose 60 60 0 0 72 72

As mentioned above, you can try these examples on:

https://glicol.org

If you want, you can even hear how a seq node work:

o: speed 2.0 >> seq 60 _72 _ 48__67 >> mul 0.5

This is actually analogous to how hardware module pass signals.

It is very easy to remember and to get started.

When Glicol is used in education, we can let students see and hear each node, even including 'envelope'.

Just leave the introduction of data types, Object or Function later when we mix JavaScript with Glicol.

Zero-installation

For the audio engine, instead of mapping it to existing audio lib like SuperCollider, I decide to do it the hard way:

  • write the parser in Rust

  • write the audio engine in Rust that works seamlessly with the AST processing

  • port it to browsers using WebAssembly, AudioWorklet and SharedArrayBuffer

The main reason is to explore performant audio in browsers for easy access and live coding collaboration.

The reward is that we now have an Rust audio lib called glicol_synth:

It can run on Web, Desktop, DAW, Bela board, etc.

And one more thing.

To write everything from low-level also opens the door for meta node.

Now I can explain to students, the hello world tone can also be written in this way:

o: meta `
    output.pad(128, 0.0);
    for i in 0..128 {
        output[i] = sin(2*PI()*phase) ;
        phase += 440.0 / sr;
    };
    while phase > 1.0 { phase -= 1.0 };
    output
`

Roadmap

  • 0.1.0 hello world from dasp_graph and pest.rs, pass code from js to wasm, and lazy evaluation
  • 0.2.0 pass samples from js to wasm, support error handling, bpm control in console
  • 0.3.0 build complex node plate reverb using basic node from glicol, using macro in Rust
  • 0.4.0 use LCS algorithm and preprocessor for smooth and efficient whole graph updating
  • 0.5.0 build const_generics to dasp_graph and use it in glicol, use SharedArrayBuffer, support local sample loading
  • 0.6.0 refactor the code to modules:
    • glicol-main = glicol-synth + glicol-parser + glicol-ext
    • glicol-ext = glicol-synth + glicol-parser + glicol-macro
    • glicol-js = glicol-main + glicol-wasm
  • 0.7.0 support mixing js with glicol in glicol-js using Regex; add visualisation
  • 0.8.0 embed Rhai in glicol ๐ŸŽ‰
  • 0.9.0 redesigned architecture; see the release note
  • 0.10.0 run as a VST plugin
  • 0.11.0 run on Bela
  • 0.12.0 distribute as a npm package
  • better music expressions, more variation for seq nodes
  • exploring new forms of musical interactions

Note that Glicol is still highly experimental, so it can be risky for live performances. The API may also change before version 1.0.0.

Please let me know in issues or discussions:

  • your thoughts on the experience of glicol
  • new feature suggestion
  • bug report, especially the code that causes a panic in browser console
  • missing and confusion in guides and reference on the website

glicol-cli's People

Contributors

chaosprint avatar itsjunetime avatar joshka avatar tenstrings avatar tharvik avatar tprost 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

glicol-cli's Issues

[Bug] optional dependency `jack` is not included in any feature

Hi!

I just tried to install glicol-cli, with the command in the README:

cargo install --git https://github.com/glicol/glicol-cli.git

and was greeted with this error:

    Updating git repository `https://github.com/glicol/glicol-cli.git`
error: failed to parse manifest at `/home/XXXXX/.cargo/git/checkouts/glicol-cli-b10f0cfdae7f5c00/d3f80b8/Cargo.toml`

Caused by:
  optional dependency `jack` is not included in any feature
  Make sure that `dep:jack` is included in one of features in the [features] table.

I noticed there was a commit 13 hours ago adding jack as an optional dependency. Maybe it was related?

Startup error

Hey!

I'm getting the following error on glicol-cli launch:

capture

Then my terminal gets corrupted.

It points to this line (131):

glicol-cli/src/main.rs

Lines 127 to 133 in c5f6493

match config.sample_format() {
// ... other sample formats ...
cpal::SampleFormat::F32 => run_audio::<f32>(&device, &config.into(),
ptr_rb_left_clone, ptr_rb_right_clone, index_clone, path),
_ => unimplemented!(),
}
});

Not sure why it happens but is it related to my audio device? Any help is appreciated.

P.S. I'm using test.glicol from this repository.

"samples" example from glicol.org/tour causes ERROR: "cannot use this non-exist samples"

Love the library!

I'm running glicol-cli on Ubuntu 22.04 with neovim as my text-editor.
The samples don't appear to load properly and I can't figure out how I would run addSampleFolder() or similar since I'm not running glicol in the browser. I downloaded the zip folder with all the samples but not sure how to load them in locally, in other words.

// test.glicol
out: imp 1.0 >> sp \808bd

Here is the full error:

ERROR glicol_cli: get next block of engine: cannot use this non-exist samples \808bd

I tried a few different samples from the list but no dice.

Any help would be much appreciated!

comments

hi!

it doesn't parse comments, right? when there're '//' symbols in a file, everything goes silent

Can't exit from the cli tool

The issue applies to both bash and zsh and is tested on OSX. The only way to exit right now is to kill the terminal process altogether.

ps: thanks for working on this

Issue with external audio device

Not sure exactly what is the cause of this, but when I run the cli tool the audio is glitched (high pitched) and also comes out of all the outputs of my device.

CleanShot.2023-10-31.at.15.13.13.mp4

Panic at head when running in dev mode

Fresh clone, just a bare cargo run at head panics:

% cargo run -- 1.glicol
warning: unused import: `Sample`
  --> src/main.rs:10:17
   |
10 |     FromSample, Sample, SizedSample,
   |                 ^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: `glicol-cli` (bin "glicol-cli") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/glicol-cli 1.glicol`
thread 'main' panicked at 'Argument 'file' is a positional argument and can't have short or long name versions', /Users/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.8/src/builder/debug_asserts.rs:731:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Looks like this is in dev mode only -- cargo run --release works fine.

Full backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/panicking.rs:64:14
   2: clap::builder::debug_asserts::assert_arg
             at /Users/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.8/src/builder/debug_asserts.rs:731:9
   3: clap::builder::debug_asserts::assert_app
             at /Users/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.8/src/builder/debug_asserts.rs:61:9
   4: clap::builder::command::Command::_build_self
             at /Users/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.8/src/builder/command.rs:3920:13
   5: clap::builder::command::Command::_do_parse
             at /Users/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.8/src/builder/command.rs:3790:9
   6: clap::builder::command::Command::try_get_matches_from_mut
             at /Users/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.8/src/builder/command.rs:708:9
   7: clap::builder::command::Command::get_matches_from
             at /Users/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.8/src/builder/command.rs:578:9
   8: clap::builder::command::Command::get_matches
             at /Users/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.8/src/builder/command.rs:490:9
   9: clap::derive::Parser::parse
             at /Users/rich/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-4.1.8/src/derive.rs:82:27
  10: glicol_cli::main
             at ./src/main.rs:53:16
  11: core::ops::function::FnOnce::call_once
             at /rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs:507:5

Ableton Link time synchronization

Ableton Link is an open protocol for time synchronization, so that multiple disparate programs, devices, or instruments can sync up over the network to a common session that synchronizes musical time, so each connection knows the bpm and the exact moment to start the next measure, so everyone starts or stops at the correct time.

I have been interested in the glicol VST for syncing time in my DAW, but I think it would be more powerful for glicol-cli to have ableton link support, then you could sync with pretty much anything, not just a DAW.

Heres how I imagine it would work:

glicol-cli --link --sync-start 4 --file test.glicol

That would start the glicol engine loading the file, it would connect to ableton link, and then it would wait until the current beat is a modulus of 4, before starting. glicol wouldn't necessarily need to track time internally, and you would still use whatever speed parameters in your code, etc. But glicol would only respect the link time for the transport, to start and stop the DSP graph engine.

You could even trap the SIGINT (Ctrl-C) signal of glicl-cli, to tell it to stop playback at the next --sync-start bar and then quit, so that way you could start and stop glicol-cli in time with your other music.

I think this would be great for live music, but I am mostly interested in this for recording stems of several tracks in my DAW (my DAW controls the transport through Ableton Link), and by manually muting things in glicol code. So I can record the process N times for N tracks (unmuting each track), and have each recording start and stop in the same time frame (unless glicol can already map to multiple sound devices?)

References:

Distorted audio on Linux (buffer size problem)

I get distorted audio playback on Linux, because my audio device seems to want to ask cpal for buffers of sizes that aren't a multiple of BLOCK_SIZE (128). Since the current logic to fill the buffers relies on the size of the buffer being a multiple of BLOCK_SIZE, you end up with some blocks being not used completely (or maybe it's not filling the whole buffer with samples).

Anyways, I made a fix for that, but be warned, I am a beginner Rust developer.

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.