Mapping the underlying structures of TidalCycles and Mandalas.
Using Haskell’s advanced type system to map the structures in Tidal Cycles to the underlying shapes of Mandala art and produce beautiful visualisations.
Mandalas are geometric designs, created with circles and repeated simple shapes. Weaved squares, concentric circles, intricate triangles and squiggly lines form the piece. They are common in south east asian art, showing up in temples and sand paintings alike. Today they are widely used, to the extent that you find them on shirts and household items.
Tidal Cycles is a live coding environment for music production, created by Alex McLean. All the Tidal visualisations I saw were linear. Notes playing forward with time. But mandala art remains in situ. The shapes morph in the same place, accompanying the rhythms and cycles of the music. The periodic nature of music should reflect in its visuals as well. Thus came the project idea: Map the underlying structures of Tidal to mandala patterns.
From all that I found out about mandalas, they are general patterns. They are not really particular to India or any other country. Native American art has some mandalas, so does Tibetan sand art.
Not unlike euclidean rhythms , the underlying structures make the art universal. However, their mathematical symmetry, though obvious, remains undefinable. No simple code like euclidean rhythms that is concise. Instead, Mandala art in computers is formed usually through an exploratory process, going back as far as we have generated graphics.
Some mandalas are fractal. It’s an aspect of their underlying mathematics. Arthur C Clarke noted an odd coincidence when he wrote about mandalas -
“[..] but indeed the Mandelbrot set does seem to contain an enormous number of mandalas.”
Languages like Processing or libraries such as p5.js can produce mandala graphics.
No doubt, the heavy workload should be handled by languages more suited to the task. Even Haskell animation libraries are built as thin wrappers on top of the C animation library OpenGL.
Haskell is particularly well suited to representing these abstract patterns. Mapping its type system with simple shapes could lead to varying results. How could it be used to map Mandalas onto the existing structures of Tidal Cycles?
Turtle Graphics are a simple graphics system. Typical commands include move forwards, move left, right and so on. Some of you might be familiar with it from Python's Turtle graphics library. For the old school ones Microsoft's Visual Logo might ring a bell.
We integrated a basic Turtle Notation within Tidal's parser. Understanding the basics of monadic parsers proved useful. The system needed to be portable to other libraries, so we created an intermediate notation. Thus began the patterns.
“f”: pattern, moves forward with time
“f r”: Moves forward in the first half of the cycle, and then moves by 90 degrees in the second.
Mini Notation Magic
Tidal’s Mini-notation is used for writing patterns of various sorts (notes, samples, parameters).
Internally, the mini-notation is parsed as a shortcut for a function. You could otherwise write it using longer function compositions.
“f <l r>”: Alternatively moves left and right in each cycle’s second half.
“f [f f l]”: Starts forming Mandala like patterns.
But there was a problem.
The system is not real time. WorldTurlte's API does not give low level access to the time at which the pattern is produced. This leads to graphics that are only theoretically in sync with music. Gloss, on top of which WorldTurtle is built, does provide access to time.
There was also the problem of changing patterns in real time. But, by storing patterns in mutable, shared variables, we could handle this with threads. This is a work in progress.
Meanwhile, Some more patterns:
"f l l [f r r f l l f r r] f l l": Mininotation magic at hand, again.
"f <l r> f <r l r>"
append (slowSqueeze "1 3 1" ("[l f, f r]")
slow “1 1 2 3 5 8” “f l l”:Everything is patternable.
At it’s base,
“f l l”on its own produces a simple triangle.
This will slow down each cycle by the first pattern. Slow the first and second parts of the cycle by 1, third part by 2 and so on.
You can find more patterns here.
ANIMATION AND TIME
This talk by Conal Elliot on Functional Reactive Animation specifies what graphics systems do. They abstract the pixels away. Keep continuous space to work at a higher level. This allows for better composition too. You can scale and morph images without too much difficulty. The task is to use the same methods for time.
Regardless, some things I have learnt in this time: The rich variety of mandala art in many continents; L-systems that produce tree-like structures using grammars; and music theory: tones, scales, chord progressions and their mathematical underpinnings.
There is the intuition we have that fields of knowledge are interlinked. That these patterns are present in many areas. But you can’t work on intuition alone. So how do you confirm it?
However, the current system does show the structure of Tidal. The ChaosMap pattern, after going haywire in all directions, comes back to its original point. Seemingly random, until the very end when the pattern is visible. It showcases the underlying mathematical beauty at work. This was the central goal to accomplish.