EtudeGen

May 2017

Scale/arpeggio books are a necessity for serious music students, so I wrote a Python app for generating my own étude books.

Quick Stats

   
LIBRARIES & FRAMEWORKS USED LilyPond for sheet music generation. Mingus for working with musical logic. Sphinx for generating documentation.

Game plan

It’s important for musicians to know how to move around keys and chords in their respective instruments. I’m crazy enough to attempt playing multiple instruments, so I wanted a way to study scales/chords for several instruments without having to buy several scale books.

For some time, I’ve been playing around with LilyPond, so I knew how to generate sheet music through code. I also knew that scales and arpeggios usually work the same way across different instruments. I just needed a way to connect those dots, and I’d be set.

Pulling it off

Python and mingus are the keys to this project. Mingus is a music theory library for Python, which allowed me to program with musical logic. So I can define the various scales, keys, and chords that I wanted to work on. From there, I dynamically created a LilyPond source file for each étude book, which contains a series of exercises. I could then use LilyPond to compile each file, resulting in a series of PDFs.

I also allowed the app to read from a config YAML file, so I don’t have to tweak values in the code itself. This is very useful if I wanted to create a book for another instrument, or tweak the range of an existing instrument. For example, here’s the config block for a violin book:

1
2
3
4
5
6
7
8
9
name: violin
clef: treble
lowerLimit: G-3
upperLimit: C-6
arpeggioPattern: "1 2 3 2 3 2 1 3"
majorKeys: "C G D A E B F# F Bb Eb Ab Db Gb"
minorKeys: "A E B F# C# G# D# D G C F Bb Eb"
forceAccidentals: true
showSolfege: false

The config block above shows information for each instrument, the keys to include in the book, and various options for presentation.

You can see the rest of my code at GitHub.

Results

Check ‘em out!