Skip to content
neo451 edited this page Jun 7, 2024 · 24 revisions

Welcome to the modal w This page documents some design process, syntax difference with tidal/strudel and (maybe) new features.

Overall structure

modal aimed to be both a lua library that looks alot like strudel:

d1(every("<3 4>", "|x| x |+ 7", note"[0 3 7]")

and thanks to the amazing and powerful lpeg library, modal also support the maxi notation, discussed here: https://github.com/tidalcycles/strudel/discussions/96

note this is under active construction

d1 $ every <3 4> (|x| x |+ 7) note [0 4 7]

Syntax

Literals and Mini-notation

In lua, most strings that passed into where should be a Pattern are always patternified:

d1(s"bd")
d2(note"0 .. 7":s"piano")  -- TODO

modal supports:

  • Tidal style custom operators for value combining(arithmetics not yet).
  • Mini-notation (in construction) that need no quotes.
  • Quoting (not the lisp way lol) for strings to embed named pattern into mini-notation
d1 $ s bd
d2 $ note [0 .. 7] |> s piano
a = cp
d3 $ s [bd 'a 'a] // -> [bd cp cp]

Functions

In lua, both strudel style methods and tidal style transformation functions are supported:

euclid(3, 8, 1, s"bd")

s"bd":euclid(3, 8, 1)

In modal, method calling does not make sense, though.

In both case, the tidal style functions are smartly curried like in haskell

off(0.25, euclid(3,8,1), s"bd")
off 0.25 (euclid 3 8 1) s bd

Embedding patterns

declare reusable patterns and sample names is especially easy in this environment

a = 1  -- only with global vars
reify"^a 2 3" --> [1 2 3]
ff = "bd!4"
reify"^ff, ~ sd ~ sd" --> [bd [bd sd] bd [bd sd]]
bd = 808bd
reify"^bd sd"
a = 1
[^a 2 3]
ff = [bd!4]
[^ff, ~ sd ~ sd]
bd = 808bd
[^bd sd]
Clone this wiki locally