Cangen
Cangen was actually my first coding project, all the way back in 2023. I had been exploring canonic sequences by hand with a pen and paper, and compiling all the results was becoming repetitive and begged for automation. Eventually I bit the bullet and learned a bit of C, and then JavaScript, and cangen was the result!
A melodic sequence is formed when melodic material is repeated, transposed to a new scale degree. A canon is a kind of strict imitation, where one voice enters after another with the same melodic material—possibly transposed or otherwised transformed in some way—while the original voice continues in counterpoint with it. A canonic sequence is a melodic sequence that is also imitated canonically. These patterns form an important kind of resource, ubiquitous in tonal music, and I was studying a specific subclass involving two-note melodic models, as they are the simplest sequences possible and can be easily exhaustively generated, studied and manipulated.
This app is essentially a constraint satisfaction algorithm powered by a few nested for loops. First, it generates the set of all “valid” two-note melodic models based on some constraints related to ease of singing, with models that fail to meet any constraints being skipped. Then, for each melodic model, every possible vertical placement of an imitating second “copy” is tried, and those that fail to meet certain constraints are again skipped.
Finally, a collection of functions that query properties of patterns algebraically are used to filter the patterns via user-specified parameters.
Roadmap
Although I was forced to abandon this project by other commitments in 2023, I intended to add features that allow patterns to be procedurally “elaborated”, as I had developed various processes to do so on paper. These processes will hopefully end up being integrated into a more comprehensive application at some point in the future. As an example:

This pattern contains a descending third in its melodic model, which can be “split” into a stepwise passing motion:

These passing tones can be “supported” with new consonances, effectively creating a new pattern of the same kind as the one we started with, but belonging to the set of patterns with 4-note melodic models:

Let’s cycle this pattern forwards a beat so it starts on what was previously the fourth quarter note. This actually forms a ubiquitous pattern in classical music called the “canonic Prinner”:

This pattern contains descending steps which can be delayed via suspensions:

There is a two-step process by which suspended patterns can be reduced to their essential components, and then repopulated with new intervals (there are many possibilities for these intervals, only one possibility is presented here):


Lastly, an example of how this pattern could be adapted into actual musical texture:

I have also written higher dimensional equivalents to this 2x2 generator that exhaustively mine canoninc sequences with larger numbers of voices, and longer melodic models. The same elaboration techniques can be applied to these patterns, which make the generative possibilities surprisingly powerful:
I intend to unify these techniques behind a single user interface at some point.
← Back to projects