this is about using multiple ports with keykit…
Within my current setup I run up to four keykit instances. One instance is the main application: A large loop interprets and processes MIDI input and output in realtime. The other instances work as “preprocessors” to handle the output of various external MIDI devices (for example to reframe [in time] a Doepfer R2M-ribbons’s high-speed output). Every instance opens its own MIDI input- and output ports (including USB ports). Normally all of these keykit instances are linked by virtual MIDI Yoke ports. The main application can even loop self-generated MIDI back to itself for interpretation. Nevertheless, a physical routing via an M-Audio MIDISPORT 4x4-interface is also available. All of this usually works fine.
As you can imagine, a setup like this makes intense use of a phrase’s .port-attribute to route keykit-phrases correctly. To set a phrase’s destination-port we can type for example phr = ’a’; phr.port = n , where n is an integer from 1 to 64 (for output). The realtime()-function will transmit such a phrase to the specified MIDI-outport. When you print a phrase phr to the console by typing print(phr), you can detect that phrase’s (non-default) destination-port index preceded by an uppercase letter P.
Keykit provides several ways to retrieve information about the relation between MIDI port-name and the corresponding .port-attribute’s value (port-index) on your system. You can either
- type listports() into the console-window or
- create an enhanced version of the Port Enabler-tool (known from the Tools1-> menu).
The following procedure describes how to create and run an improved Port Enabler-tool that displays your system’s MIDI-port-indices in the first column:
1. Open the lib-directory in your keykit installation folder
2. Create a copy of the file wportpick.k and rename the copy to wportpick.ORG, confirm the change if necessary.
3. If you run a windows7-system (like I do), open wportpick.k with WordPad and save the textfile immediately *as is*. This arranges a readable layout of the text-lines. Close WordPad.
4. Now open wportpick.k with the windows texteditor (or whatever you prefer to edit a keykit source file).
5. Apply the following four modifications 5.1. - 5.4. :
Within the class wportpick { -section...
5.1 find the loop
for ( i in $.inports ) { ...
and replace the line
##$.intext[n] = new ktext("IN","left") by
$.intext[n] = new ktext("IN P"+string(i),"left") # show port index
5.2 next find the loop
for ( i in $.outports ) { ...
and replace the line
##$.outtext[n] = new ktext("OUT","left by
$.outtext[n] = new ktext("OUT P"+string(i),"left") # show port index
5.3 next find the method resize(sz) { ...
and replace the line
##xneeded = tw * ($.maxlength + 8) by
xneeded = tw * ($.maxlength + 10) # 2nd column slightly widened
5.4 …and further down, still within the method resize(sz)
replace the line
##x0a = $.xmin() + tw*5; by
x0a = $.xmin() + tw*8; # 1st column widened
Save and close the edited file (wportpick.k) and make sure to run the updated version by closing and restarting keykit. Click to open the Tools1-menu and select the (new) Port Enabler-tool. Should your attempt to upgrade the Port Enabler-tool fail for any reason, delete the edited file and rename wportpick.ORG to wportpick.k again.
That’s it, hope this is useful - your comments are very much appreciated!
All the best
Holger
-----------------------