The entire code is written in Python. In the first place I chose it, because libraries were available for everything I needed. It proved to be a good choice, because it is such a nice language and you can code very efficiently with it. I don’t want to imagine, how much effort it would have taken me if I had used C.
I used the Aubio library for pitch detection. It is written in C, but has a Python wrapper. The documenation for the Python part of the library is rather light, but fortunately Chris Baume posted an example, which helped me a ton.
Other libraries I used Rpi-LPD8806 and the library for the Adafruit 16×2 LCD.
Threads
Each task runs in a separate thread (see sequence diagram below). The LED animations are controlled in pdlmThreads. pdlmAubio consistently updates the pitch and energy values for sound and pdlmThreads fetches the values when needed. This way the update interval can be set independently from the calculation time for pitch detection, which takes about 100ms.
The colors are mapped to the pixels with different dictionaries from pdlmLEDDict. Different color ranges can be set as two colors which are set as minimum note and maximum note color. These and all other settings are saved in an instance of pdlmSettings.
The code can be found here: https://github.com/Xwoe/pedalumi/