In my last post (‘Alternative Keyboards 2‘) I described choosing a suitable QWERTY keyboard as a 2-dimensional ‘isomorphic’ musical keyboard. In this post I talk about the software I used to interpret the key presses and output MIDI information to the synthesizer (virtual synthesizer, in my case).
The first thing to appreciate is that every key press on a computer keyboard sends a number (its ‘ASCII’ code) to the computer via USB. Every key has a different number, and the number sent out by the key is different when the Shift key is pressed at the same time. Knowing this, and knowing which key sends which number means you can tell the computer to do a certain thing with each number it receives – for example to output a MIDI note number.
When you use a MIDI music keyboard the relationship between the number it sends and what you want done with it is very simple: press the note C in the middle of the keyboard, and it will send out the number ‘60’. MIDI synths recognise 60 as the number for C, and C will be sounded; press C#, the number 61 will be sent, and C# will be sounded; and so on. Unfortunately, this isn’t the case with the computer keyboard – the numbers sent out by the keys bear no relationship whatsoever to where on the keyboard they are: The ASCII code for Q, expressed as an ordinary decimal number, is 113; W, right next to it, is 119; E is 101, and so on and so forth.
So, in terms of software, if you’re using a QWERTY keyboard, as I was, you’re looking for a program that a) recognises ASCII codes input from a keyboard, and b) has a means of you telling it to do something unique with each different number it receives. In this application the unique action would simply be to output a specific MIDI note number for every specific key number received.
Having read about Ken Rushton (‘MusicScienceGuy’)’s instrument, the Jammer, at www.altkeyboards.com (and his blog at www.musicscienceguy.com), I decided to use the program MIDI Integrator he had devised to operate it. MIDI Integrator is described, and can be downloaded here: www.altkeyboards.com/integrator. It’s free, and works on Macs and Windows PCs. It’s an application based on MAX/MSP, and I had downloaded and installed the free version of this, ‘Max Runtime’ from
MIDI Integrator was designed to be used with the Jammer – and is potentially very useful because of that, as the Jammer has 2 separate MIDI keyboards; but inputs for MIDI keyboards weren’t useful for this application, as the QWERTY keyboard doesn’t output MIDI information. However, there is another feature of the program that would do the trick.
Setting this up was quite an involved process, but consisted of just a small number of important steps. Most importantly, when done once, most of these things didn’t have to be done again!
When you open MIDI Integrator, the interface you see looks like this:
All the boxes with a ‘p’ at the beginning are boxes which can be clicked to enter information. There are lots of boxes here, but I only needed to look at two of them.
What I had to do is ‘map’ the keys of the QWERTY keyboard – i.e. match them to MIDI notes – in the top half of the screen, and route the output to a virtual MIDI instrument in the bottom half – which involved telling the program where to send the MIDI signals to operate a synthesiser or sound module.
So, I began by clicking the box marked ‘p mapPCKeys’.
When I did this, it brought up the window for the QWERTY keyboard, which looks like this:
What this tells you is that the mapping instructions used by MIDI Integrator are in a text file called ‘MidInt PcKeys v1.txt’. What I had to do is replace the text file ‘MidInt PcKeys v1.txt’ with one of my own, with my choice of notes.
To do this, I clicked on the third button ‘coll MidInt PcKeys v1.txt ‘, under the text ‘Click below to edit mapping table’. This opened the text file, which looked (in part) like this:
You can see from this example that each line has 5 elements, like this:
56 #8, L N 76. This is interpreted as follows:
56 is the number (usually ASCII) sent out by the key;
#8 is which key that is (in this case, the number 8 on the second row down of the keyboard);
L is the virtual MIDI instrument in MIDI Integrator to which the information is sent (L, R, Lx and Rx are the choices MIDI Integrator gives us; it doesn’t matter which one you use if there’s only in use at any one time);
N means ‘note’ information is what’s being sent;
76 is the MIDI note number.
So all I had to do was identify the keys on the keyboard I wanted to play notes on, find out the ASCII number of each one, and write a line of code for it like the one above.
The problem is matching the right key number on the left-hand end with the right MIDI note number on the right-hand end, and the MIDI Integrator website made this easy, by providing a chart (an Excel spreadsheet), laid out in the same way as the QWERTY keyboard for me to write this information in. It already had the key numbers in it, all I had to do was write the MIDI note numbers in next to each key.
Not all of the keys on the keyboard have code numbers that can be used, but it’s only a small number round the edge that won’t work. I experimented to check exactly which ones could be used, and labelled them or didn’t label them in the spreadsheet, as appropriate.
This chart shows which codes MAX/MSP allocates to which key, mostly based on their ASCII codes:
I made this diagram to show the 5-row note layout for the ‘Wicki-Hayden’ keyboard:
and this one to for the ‘Janko’ keyboard:
I figured that I might as well create several different text files for MIDI Integrator while I was at it, and try out some different layouts.
So I had the keyboard layout spreadsheet and the pattern of notes for my layout (I started with the Wicki-Hayden). The final piece of information I needed was what MIDI note numbers corresponded to the notes in my layout diagram.
This chart shows the MIDI numbers which correspond with all the notes from C0 (the lowest) to G9 (the highest). C4 is ‘middle C’.
For mathematical reasons, 128 notes are available in MIDI and for mathematical reasons they are numbered 0 – 127, not 1 – 128.
Once armed with this information, I filled in the spreadsheet, went back to the text file ‘MidInt PcKeys v1.txt’, filled in my own numbers and saved it as ‘MidInt PcKeys AM Wicki.txt’ in the same folder as ‘MidInt PcKeys v1.txt’.
The file began like this:
(Large numbers like -999 are used for comments, and are not interpreted as instructions).
It doesn’t matter what order you put the notes in, so I started in the top left of my spreadsheet, so you can see the line of codes representing the F keys, followed by the line of codes representing the number keys. The file just continues until the end of the bottom line (the one beginning ` Z X C V . . .).
There are other things you can specify in the file – for example, you can map some keys to MIDI control messages, and MIDI Integrator has some of its own commands. I ended the list with the following:
-2 space, R C SUS;
-15 Home, R C OCT 2;
-13 Pg Up, R C OCT 1;
-14 Pg Dn, R C OCT 0;
-16 End, R C OCT -1;
-12 >, R C OCT -2;
5 Ins, R C KEY -1;
-6 Del, R C KEY 0;
-11 <, R C KEY 1;
Instead of ‘N’ for note as the 4th character, ‘C’ is for control. MIDI Integrator’s command ‘OCT’ changes the octave of the keyed note up or down by the amount shown, and the command ‘KEY’ changes the keyed note up or down by one semitone.
Now my note instructions are permanently preserved in the text file and never have to be input again. Whenever I open MIDI Integrator, I can click on the box ‘p mapPCKeys’,
and in the box that opens up, click on ‘read’ next to the text ‘Click to change mapping table’,
This brings up a typical ‘Open file’ dialogue box in which I can select ‘MidInt PcKeys AM Wicki.txt’, which immediately maps all the keys of the QWERTY keyboard to the Wicki-Hayden layout (or the Janko layout if I choose ‘MidInt PcKeys AM Janko.txt’, or any other layout for which I’ve created a text file).
There are a few other things to do to get MIDI Integrator working – for example, the keyboard volume can be set via the slider on the right-hand side – but these are all explained in the detailed MIDI Integrator Manual, available along with the program, the spreadsheet and other things at www.altkeyboards.com/file-cabinet.
The main thing is to select the instrument routing. This is done by clicking the box ‘p Instrument_L’, ‘p Instrument_R’ – or whichever one you’ve chosen on the lines of the text file – at the bottom of the main screen:
The boxes on the left-hand side, especially ‘noteout l’ (or ‘noteout r’, etc., for the other instruments) are important.
A QWERTY keyboard isn’t quite as good as the AXiS or the Jammer, of course, but it’s a pretty cheap way of getting to know isomorphic keyboards and alternative keyboard layouts.