MIDI Operations

The command to set-up MIDI ports is simply [midi]. Use it without parameters to see what MIDI devices are available. Once you can see them, you can select the ones you want with [midi *in *out] command. For example, [midi 0 0] will select the first input device and the first output device.

On Apple OS X you don't actually have to do anything. The application creates virtual MIDI ports and uses them by default. They can be used by all your other software. You can also use [midi *in *out] to select additional ports for extra transmission.
On Windows you must select devices, otherwise no MIDI will be transmitted and/or received.
On Linux the [midi] command will show you 10 input and output devices, regardles of whether they are connected or not. You must look into your /dev directory and check if the devices are actually present. Then you can select the appropriated device.
If they are then you can select them.

On every platform you can access in-built help on MIDI commands. First, load the help module, i.e.: [load "help.prc"]. Once it is loaded you can access help by typing [help midi] or simply [help] for general help. You can get help on each separate command using [help midiCommand], for example, [help keyoff] will tell you more about keyoff command.

TRANSMITTING MIDI
RECEIVING MIDI
For receiving MIDI messages HERCs Prolog uses callback mechanism. There is a dedicated symbol for this purpose: income_midi. Whenever a new MIDI message arrives, a call to [income_midi ..... ] is executed. It is your responsibility to provide the definition of income_midi. You can find an example below.

MIDI MONITOR
This is probably the simplest program, which you can write for HERCs Prolog. It shows incoming MIDI transmission. Just a single line of code. You can download the sample code midi_monitor.prc or midi_monitor.prb. The first one is in a form of a module, another is just a batch script.