Programming on a Keyboard… a Piano Keyboard

Yuriy Guts
R&D engineer and solutions architect at ELEKS

How can you tell a programmer from a musician? Ask them what C# is.

Since the early 1950s, when the humans finally managed to make an electronic machine sing, the computers have been gradually becoming a helpful and versatile tool in audio production. Nowadays, thanks to digital synthesizers, VSTi instruments and digital audio workstations, you can forget about endless rolls of magnetic tape and produce an almost-studio-quality recording at home if you’re persistent enough.

This progress in the music industry was significantly boosted by the invention of MIDI, a technical standard that allowed the electronic musical instruments to communicate with each other using a digital protocol. The protocol itself is based on the concept of MIDI messages, where each message consists of a status byte (indicating the type of the message), and some data bytes that contain the payload.

For example, here is what happens when you press and release the middle C key on a MIDI piano keyboard (assuming you use MIDI channel #1):


Status ByteData Byte 1Data Byte 2
144 = Note On60 = Note C, octave 3127 = Velocity (0..127): you hit the key hard
128 = Note Off60 = Note C, octave 310 = Velocity (0..127): you released the key smoothly

Looks familiar, right?
Yes, computer keyboards work in a very similar way (only they don’t have as many features as MIDI piano keyboard does). So, we can easily interpret these messages and turn a MIDI input device into a handy tool for computer programming. Imagine a MIDI trigger pad doing something like this:


(hitting the Push key really hard makes it do a git push -f)

If you feel brave enough, you can even try to completely replace the computer keyboard with a digital piano. All you need is to have some piece of software on the computer to translate MIDI messages into computer commands. It could be a user-mode driver, or you can create a plug-in for your favoride IDE to teach it new tricks.

Which we did. Just for fun, I developed Midichlorian, a Visual Studio extension that allows you to write code and automate VS using MIDI instruments. And, inspired by The Song of Pi, my colleague Lana composed a song which is both a melody in the key of C# minor and a valid C# computer program. Watch her in action!

Under the hood, the extension attaches to the editor window, processes the incoming MIDI stream, recognizes notes and chords within it, and executes the corresponding Visual Studio commands according to the profile configured on the UI:


The extension is open source, you can contribute to it on GitHub and create your own tunes.

P.S. Of course, this post would be incomplete without the sheet music:

Hello World: a Suite for Visual Studio in C# Minor



  • “We also walk dogs” (c)

  • i’ve been trying to get a Korg nano pad working as a window manager, i.e, pad 1 puts my text editor in right monitor with project management window in the left, pad 2 puts splits right monitor between test results and spec, etc. So much nicer and more satisfying to press one button than execute 1-5 silly keyboard shortcuts

  • Oooo! Can you reverse this so I can upload files of code to hear how they sound? What an awful opus that would be.

  • Hi Yuriy,
    Do you think we could translate this article to Russian and publish on our corporate blog ( — of course, with the name of the author clearly indicated and a link to the original text?
    We are a language software development company and our developers will certainly appreciate this great article.
    Thank you for your time.

    Best regards,
    Denis Frolov
    PR Manager
    ABBYY Language Services

    • Hi Denis,
      Yes, you’re welcome to do so, as long as all derivative works maintain a link to our original article.