-
Notifications
You must be signed in to change notification settings - Fork 9
Creating Custom Keymap
The following instructions could be useful if you would like to have a different mapping of keys to MIDI notes in this application. Please note well, that this involves modifying a file that is used by the application. You should be comfortable working with a text editor and XML in particular. You should keep a backup of the file you will edit in case you make a mess of things and need to get back to a usable state.
In the Finder, go to the Applications folder and control-click on the MIDIKeys application. Select the “Show Package Contents” action. Open the folders “Contents" and then “Resources”. There you will see the KeyMaps.plist file that defines the mappings defined. This is the file you need to change. First though, make a copy of it by control-clicking on it and selecting the “Duplicate” action. It is OK that the copy is in the same folder, but to be really safe, you should move some place outside of the application. Now if you make a mistake, you can always restore to the original content.
You will need a plain text editor for the next part, one that will not add any formatting or control sequences to the text in the file. The TextEdit application that comes with macOS is an OK option. Open the “KeyMaps.plist” file in your editor. It has a fairly simple format:
- Top-level contains pairs of and values, each one defining a named key map that you can see in the MIDIKeys Preferences pane in the “Keys” tab in the “Key map” popup button. In the app there are 4 separate maps.
- The next level is an array of entries. There is at least one entry, but like the “Full” map which has 2, there can be more than 1.
- The third level is the actual map definition:
- FirstMidiNote: defines the MIDI note that will be assigned to the first KeyCode in the map
- KeyCodes: an of integer values, each one is a key code of the key to use. Each key will emit the MIDI note that is 1 greater than the previous entry. So if FirstMidiNote is 39, then the first key code listed will emit 39, and the next key will emit 40.
Simple, no? :) Here is a toy sample that just maps one key ("A") to MIDI note 69 (A4):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Toy</key>
<dict>
<key>Ranges</key>
<array>
<dict>
<key>FirstMidiNote</key>
<integer>69</integer>
<key>KeyCodes</key>
<array>
<integer>0</integer> <!-- Key A -->
</array>
</dict>
</array>
</dict>
</dict>
</plist>
Mostly this is an exercise in making sure you do not make an error with the XML format that could cause the file to not be readable by the application. Also, there is the issue of knowing what key codes correspond to the keys you want. I recommend the Key Codes application. It is free and it does the job. Just press a key and make note of the Key Code value it shows (not the Unicode value).
A good start would be to copy the first / entry in the top-level (the one whose name is "Full") by selecting the line with "Full" and selecting everything until you get to the "" that is indented by the same amount (1 tab), and then paste what you just copied to duplicated it. Note that the order shown in the preferences pane is in the order of this file, so making the new entry appear before the "Full" one would make it first in the preferences pane. Also very important: be sure you copy full lines, starting with the Full line and including all the way down to the line with the that is before the line with Reversed Full.
Now, change the name of your pasted entry to whatever you want.
Note that there is no need to have multiple entries of “FirstMidiNote" like “Full” does, though breaking it up into separate entries might make it easier to comprehend. You only need multiple entries if you have a gap in the MIDI notes you want to emit. For instance, if you want to have 10 keys play MIDI notes 69-78 and another 10 keys play MIDI notes 80-89, then you would need to have two entries, one that starts at MIDI note 69 and has 10 key codes, and another entry that starts at MIDI note 80 that has 10 different key codes. There is no limit to the number of key codes a mapping can have, so putting everything in one should be fine.