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

Welcome to the modal! 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]")
note"0 7":every(4, "|+ note 1"):d1()

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

this is under active construction

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

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")

modal supports:

  • Tidal style custom operators.
  • Mini-notation that need no quotes.
  • Quoting 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, most library functions support both strudel style method calling and tidal style function calling:

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

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

Partial application

In modal, method calling does not make sense, also, currying the method calls make no sense as well.

In both case, the tidal style functions are smartly curried like in haskell, meaning you can do partial application easily like in Tidal

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

Composing

-- OO-style method chaining
id = function(a)
   return a:fast(2):slow(2)
end

-- functional style piping
id = pipe(fast(2), slow(2))

TODO

id = fast 2 . slow 2

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]

TODOs

  1. pattern of functions(tranformations)
every 4 [(fast 2) rev] $ note 1

this is not possibe for current haskell implementation where every's second param is just a function, but might be possible just by fully patternify??? this might just be like a good syntax arround spread?

  1. lib pats && auto sample name swap
// M.fonf = reify("bd sd bd sd") -- libaray patterns
> bd = 808bd
> fonf = 808bd sd 808 bd
Clone this wiki locally