As a machine learning engineer, I love a good parameterization that represents something interesting, like a creative coding sketch, as a core set of interesting numbers.
You can sample from distributions and automatically generate values through hyperparameter search methods! You can interpolate! You can explore the latent space!
So it might not be surprising that murrelet, the framework I built to do creative coding visuals, centers around a data structure filled with numbers and booleans. It being built in Rust means that I can take it one step further by using algebraic data types, which provides enums to choose between things and structs to combine things together.
Experiments
Transitions
One challenge with live performances is updates to parameters can cause jarring updates. By interpolating, we animate the transition. I published a Rust package called Lerpable that lets you derive a trait on your data type that interpolates between two different values of a deeply-nested data type. It works by traversing the data type of your “before” and “after” states, and any number that has changed goes from start to end as t changes from 0 to 1.
Specifically, when comparing two of the same types it compares each field individually, and when comparing bools or different enums, it’ll do a “step” where it changes over at 0.5. It has an additional functionality around vectors, where it’ll interpolate the number of items and let you fade-in or fade out new items. The Lerpable package also gives you ways to bypass or give custom methods to lerp.