[sdiy] MIDI velocity

Neil Johnson neil.johnson71 at gmail.com
Wed Apr 13 21:20:22 CEST 2016

I wrote:

> About 7 years ago when I was writing the keyboard scanning code for a
> Siel Opera 6 I had a simple scheme for scanning and measuring play and
> release velocity (not many folks seem to know about release velocity
> although some synthesizers do recognise it).
> Using an Atmel ATMega8 scanning the entire keyboard every 1ms I run
> 4-state state machine for each key, where the states are UP,
> GOINGDOWN, DOWN, GOINGUP, and an 8-bit counter for each key.
> Debouncing is handled by the algorithm rather than a separate
> debouncing step.  With the right encoding of the states you can do
> most of the testing and state transitions using btiwise operations, 8
> keys at a time (on a 32-bit processor you could do 32 keys at a time).
> I'll try and dig out the code and sling it up on github sometime.
> It's all in C, no assembler required.

Found it, and hosted up on github:


The keyboard scanner talks to a 74LS154 on the keyboard assembly, and
generates key on and off events with associated velocities.  There's
also code for reading some analogue inputs and a footswitch, but
that's not important right now.


More information about the Synth-diy mailing list