Sintrastes/xen-toolbox

Implement run-time version of note naming scheme.

Opened this issue · 0 comments

I implemented xen-toolbox's current system of assigning note names to pitches when I was fairly new to Haskell (as well as software development in general).

For this reason, this system has a lot of flaws. And honestly, I think one of the reasons I decided on the current implementation was probably something along the lines of: "Wow, Template Haskell seems cool. I want to use that"./

Probably the biggest flaw of the current implementation is the fact that notes for different temperaments are all hand-written enums. This leads to a lot of duplication in the implementation of different note naming schemes (a problem I think I intended to solve with more Template Haskell!), and also seems overly rigid (Why should the user have to do a bunch of code gen just to experiment with new some temperament?). There must be a better way.

Me talking to my former self

What seems to me to be a particularly elegant solution is essentially to have a product type of various finite fields and $\mathbb{Z}$ to represent pitches in a regular temperament, where we can represent $\mathbb{Z}_n$ with a type FiniteField :: Nat -> * (represented internally as a plain Int for efficiency reasons).