Piano Music

In the run up to Electromagnetic Field Festival which I played earlier in the year, I was preparing for a performance using only instruments and effects I’d built myself, either from kits or of my own design. The problem was, most of my modules are effects, they transform sound, but they can’t really generate sound from nothing. I had an idea to make a module which would just play piano sounds controlled by CV and gate. Here’s a video of the performance, similar to the one I played at EMF.

 

 

The Piano Player module

I decided to base the module on Music Thing Modular’s Radio Music/Chord Organ module by Tom Whitwell. It already has inputs for CV and Gate, and is Teensy based, which I’m well versed in. Time was limited so I didn’t want to have to build the hardware as well as write the software. I ordered the module from Thonk as well as a Penrose Quantiser, although I didn’t have time to build this in the end, so ended up doing the quantising in software.

The Teensy 3.2 has fairly limited memory (64k ram, 256k flash), so I only had space for a single piano sample, which is stored in the flash memory. I then had to write the code which could play this sample back at any pitch, using cubic interpolation to smooth the resulting sound. I wanted the module to have polyphony, so the sounds could overlap, without cutting off the tail of the previous sample. The Teensy 3.2 doesn’t have a floating point unit. This means it has to emulate all floating point (fractional numbers) in software, which is very slow. Initially I struggled to achieve multiple voices at once due to poor performance. I solved the problem by writing a fixed point maths library. This replaces floating point maths calculations with integer based ones, which are faster. You do accrue some loss of accuracy doing this, but it was almost x10 faster, and I was unable to hear any artefacts. This extra boost in speed gave me enough remaining CPU power to add reverb, using the freeverb algorithm in the Teensy audio library. See the source on GitHub for more details.

In this video, the Piano module is being fed random voltages from the Turing Machine (also from Music Thing). I then quantise this signal internally in software to be in the key of C. Once I’ve built my hardware quantiser I can remove this step. Theoretically this module could play any sample, the sample just needs turning into a .h include file which can be included in the source of the project. I created this using wav2sketch. If you want more samples, or larger ones, you’d need more memory. A Teensy 3.5 could be used to achieve this (as I use in some of my other modules). It does look like you could physically fit this onto the Radio Music board, the only problems I can see might be power related issues, such as discussed here http://www.cutlasses.co.uk/tech/redux-the-redux/

 

 

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *