chaosprint / glicol

Graph-oriented live coding language and music/audio DSP library written in Rust
https://glicol.org
MIT License
2.27k stars 75 forks source link

Possibility of integrating Tidal PEG for pattern syntax? #16

Open jarmitage opened 3 years ago

jarmitage commented 3 years ago

What are the author's thoughts on introducing a pattern syntax such as tidal.pegjs? https://github.com/gibber-cc/tidal.pegjs

Would this require porting the above to Pest.rs?

chaosprint commented 3 years ago

This would be an interesting feature to add. I can see several usages in Glicol immediately: aa: seq '[0 [1 2]*4 <5 6 7> 8]' >> sp \bd or aa: sound 'bd [bd ~] ~ bd*4' But since Glicol has its own philosophy on syntax, of which one prominent feature is to have no pair symbols, it is better to only have a minimal modification to the glicol.pest file when adding new features. For instance, we can only add an one-line rule of Tidal:

tidalpattern = { "\'" ~ ANY* ~ "\'" } // pseudo pest code

Similar to how Gibber mixes in mini-Tidal, the best solution is to create an individual Rust crate for doing the same job as the example you mentioned in Rust:

use tidalcycles::pattern_to_event;
let event = pattern_to_event("bd ~".to_string());

Then in nodes like seq or sp, these patterns can be parsed in the node constructing process. This Tidal crate can be created with pest.rs or other tools, and can be reused in other projects.

jarmitage commented 2 years ago

Another possibility here would be to build an OSC bridge with Tidal or Strudel or Vortex.

All of the above also show more ideas for how to implement pattern parsers for inspiration to make a Rust-based parser.

On the Rust side, these look interesting:

Edit: closed by accident 😅