📜 ⬆️ ⬇️

Programming on the keyboard ... piano

How to distinguish a programmer from a musician? Ask them what C # is.

Since the early 1950s, when humanity finally managed to teach an electronic machine to sing , computers gradually became a useful and versatile instrument for sound production. Today, thanks to digital synthesizers, VST-plug-ins and digital sound workstations, you can forget about the endless magnetic tape reels and do sound recording at home, and the quality will be almost like in the studio (assuming that you are quite purposeful).

Much of this progress in the music industry contributed to the invention of the technical standard MIDI, which allowed for the exchange of data between electronic musical instruments using a digital protocol. The protocol itself is based on the concept of MIDI messages, with each message consisting of a status byte that indicates the type of message, and several data bytes that carry the information load.
')
For example, consider what happens when you press and release the middle key before (in Latin transcription - C) on the MIDI keyboard (suppose you use MIDI channel number 1):



Status byteData byte 1Data byte 2
144 = take note60 = note to 3rd octave127 = speed (0..127): sharp hit on the key
128 = remove note60 = note to 3rd octave10 = speed (0..127): soft release

Familiar, right?

Yes, it is very similar to the principle of the computer keyboard (with the only difference that it does not have as many functions as MIDI). In this way, you can easily interpret these messages and turn your MIDI data input device into a useful computer programming tool. Imagine that the MIDI launcher is configured like this:


(if you hit the push key hard, the git push -f command is executed)

If you have the courage, you can even try to completely replace the computer keyboard with a digital piano. All that is required for this is the presence on the computer of some software for translating MIDI messages into computer commands. This can be a user-mode driver, or you can create a plugin for your favorite IDE that will teach her to do new tricks.

That is what we did. Purely out of sports interest, I developed Midichlorian , a Visual Studio plug -in that allows you to write code and automate VS using MIDI instruments. And influenced by the music of pi, my colleague Lana composed music, which is also a melody in the key in C-sharp minor (in Latin transcription - C # m) and a real computer program in C #. See how it works.



As for the “stuffing”, the extension is associated with the editor window , processes the incoming MIDI stream , recognizes notes and chords in it and executes the corresponding Visual Studio commands according to the settings configured via the user interface:


This is an open source extension - anyone can contribute to its refinement on GitHub and create their own music.

PS Naturally, without a musical notation, this post would be incomplete:
Hello World - Visual Studio Suite in C Sharp Minor

Translation by ABBYY Language Services .

Source: https://habr.com/ru/post/238037/


All Articles