This is a project I've been building in my spare time over the past few months. It's a library that provides methods for working with musical harmony ‒ intervals, notes, chords. For example, it can parse almost any chord symbol (Fmaj7, CminMaj9, etc) and turn it into notes, or it can identify a chord from a given set of notes.
I started this project with the idea of using formal grammar to parse chord symbols. I wanted to use it instead of a hand-written parser, which is the common approach among similar libraries. Lua caught my attention because of Lpeg, a Parsing Expression Grammar library that is both fast and easy to use. An additional motivation for using Lua was the lack of comparable libraries for it, even though the language is commonly used in audio programming.
However, despite being a Lua library, the project itself is written in Fennel — a "lispy" language that transpiles to Lua. Fennel has features that make writing code for the Lua platform much more pleasant: a concise syntax, macros, and destructuring — a feature Lua sorely lacks!
In the process, I definitely learned a lot about music theory, although my new knowledge is quite one-sided. By working on this library, I know a thing or two about types and structure of chords, but I learned almost nothing about their composition and transformation. Perhaps these will be the directions I explore next in the project.
You can define interval structure as a sequence of large L, small s, and optionally medium M steps.
For example, the Major diatonic scale, a 7 note scale from 12 EDO, in Ls notation is:
A 6 note scale (Gorgo-6) in 16 EDO is: You can then explore frequency ratios beyond those available in 12 EDO, see this Lua file: https://github.com/robmckinnon/pitfalls/blob/main/lib/ratios...E.g. the Gorgo-6 scale has the intervals S2 (septimal major second), d4 (Barbados third), N4 (undevicesimal wide fourth), s6 (septimal sixth), s7 (septimal minor seventh).
And chords based on those ratios, see Lua file: https://github.com/robmckinnon/pitfalls/blob/main/lib/chords...
The above links are Lua code files for a monome norns library for exploring microtonal tuning: https://llllllll.co/t/pitfalls/37795
reply