Open Music Labs has released a tutorial and detailed build documentation on how to read 48-key electronic MIDI keyboard with the XMEM interface on an Atmega640. If you’re building something that uses a musical keyboard and need to shave a few clock cycles off of your scan time, this is a good way to do it.