Difference between revisions of "MIDI"

From MorphOS Library

(An article by Antoine Dubourg, proof-reading by Neil Pearson)
 
Line 5: Line 5:
 
== Low level components ==
 
== Low level components ==
 
All the MIDI intricacies are handled by two system components:
 
All the MIDI intricacies are handled by two system components:
* camd.library, which handles message parsing and delivery to applications
+
* '''camd.library''', which handles message parsing and delivery to applications
* camdusbmidi.class, which bridges MIDI messages from USB compliant MIDI devices to camd.library
+
* '''camdusbmidi.class''', which bridges MIDI messages from USB compliant MIDI devices to camd.library
  
camd.library is located in SYS:MorphOS/Libs while camdusbmidi.class is located in SYS:MorphOS/Classes/USB.
+
''camd.library'' is located in ''SYS:MorphOS/Libs/'' while ''camdusbmidi.class'' is located in ''SYS:MorphOS/Classes/USB/''.
  
 
=== CAMD concepts ===
 
=== CAMD concepts ===
 
CAMD library was designed in the 90s using the concept of delivery by copying of MIDI messages.
 
CAMD library was designed in the 90s using the concept of delivery by copying of MIDI messages.
  
When an application wants to use MIDI, it creates a 'MidiNode', which is a type of area for storing messages.
+
When an application wants to use MIDI, it creates a ''MidiNode'', which is a type of area for storing messages.
  
Once MidiNode is created by the application, this node is then linked to its destination name, the MIDI cluster.
+
Once ''MidiNode'' is created by the application, this node is then linked to its destination name, the MIDI cluster.
  
MidiLink can be only a single type: sending or receiving. So, an application will send MIDI messages while some will receive MIDI messages. Some might do both.
+
''MidiLink'' can be only a single type: sending or receiving. So, an application will send MIDI messages while some will receive MIDI messages. Some might do both.
  
 
All the mechanics of CAMD is based around MIDI clusters: they provide a user friendly way to promote MIDI flux. Usually, clusters are presented to  
 
All the mechanics of CAMD is based around MIDI clusters: they provide a user friendly way to promote MIDI flux. Usually, clusters are presented to  
Line 29: Line 29:
 
Usually, an instrument will create a two way communication link, one for sending MIDI messages and another one for receiving MIDI messages.
 
Usually, an instrument will create a two way communication link, one for sending MIDI messages and another one for receiving MIDI messages.
  
The cluster name ending with '.out' is used to send MIDI messages TO the instrument.
+
The cluster name ending with '.out' is used to send MIDI messages '''to''' the instrument.
  
The cluster name ending with .'in' is used to receive MIDI messages FROM the instrument.
+
The cluster name ending with .'in' is used to receive MIDI messages '''from''' the instrument.
  
 
Those '.in' and '.out' are usually prefixed with a name. For example, you have a MIDI instrument of whatever make, which will usually be shown similar to 'Brand-DeviceName.in' and 'Brand-DeviceName.out'.
 
Those '.in' and '.out' are usually prefixed with a name. For example, you have a MIDI instrument of whatever make, which will usually be shown similar to 'Brand-DeviceName.in' and 'Brand-DeviceName.out'.
Line 41: Line 41:
 
MorphOS features two handy applications that can help with testing and boot-strapping MIDI gear:
 
MorphOS features two handy applications that can help with testing and boot-strapping MIDI gear:
  
- Virtual MIDI Keyboard, is a simple visual keyboard for sending or receiving MIDI messages,
+
* [[Utilities/MIDIPiano | MIDI Piano]], is a simple virtual MIDI keyboard for sending or receiving MIDI messages
 +
* [[Utilities/MIDI_Logger | MIDI Logger]], a tool for looking at MIDI messages
  
- MIDI Logger, a tool for looking at MIDI messages.
+
Both tools are located in SYS:Utilities/MIDI/.
 
 
Both tools are located in SYS:Tools/MIDI.
 
  
 
== Using Virtual MIDI Keyboard ==
 
== Using Virtual MIDI Keyboard ==
Run it by double-clicking its icon. You'll get a window with a large piano keyboard. VMK (Virtual MIDI Keyboard) is able to receive or send MIDI messages.
+
Run it by double-clicking the [[Utilities/MIDIPiano | MIDI Piano]] icon. You'll get a window with a large piano keyboard. VMK (Virtual MIDI Keyboard) is able to receive or send MIDI messages.
 
 
1. Select the mode of operation with the first cycle, 'Receive' for ... receiving MIDI messages, 'Send' for ... you guessed it, sending MIDI messages.
 
 
 
2. Select the cluster to connect to. If you're sending, be sure to select a cluster with a name ending in '.out'. Inversly, select an '.in' cluster for receiving.
 
 
 
3. Select to which MIDI channels you want to send/receive MIDI messages. VMK will happily send/receive from multiple MIDI channels at once.
 
 
 
4a. If you are in receive mode, the piano keyboard won't react to mouse events but will colour the keys as/when receiving note events from the cluster.
 
  
4b. If in send mode, the piano keyboard will react to mouse event(s): clicking on the piano keys will emit MIDI messages to the selected cluster.
+
# Select the mode of operation with the first cycle, 'Receive' for ... receiving MIDI messages, 'Send' for ... you guessed it, sending MIDI messages.
 +
# Select the cluster to connect to. If you're sending, be sure to select a cluster with a name ending in '.out'. Inversly, select an '.in' cluster for receiving.
 +
# Select to which MIDI channels you want to send/receive MIDI messages. VMK will happily send/receive from multiple MIDI channels at once.
 +
# a) If you are in receive mode, the piano keyboard won't react to mouse events but will colour the keys as/when receiving note events from the cluster.<br>b) If in send mode, the piano keyboard will react to mouse event(s): clicking on the piano keys will emit MIDI messages to the selected cluster.
  
 
'''Tip''': The MIDI instrument keeps emitting an annoying sound?  
 
'''Tip''': The MIDI instrument keeps emitting an annoying sound?  
Line 64: Line 58:
  
 
== Using MIDI Logger ==
 
== Using MIDI Logger ==
MIDI Logger is an analysis tool for watching incoming MIDI messages. It is most helpful for debugging an application, or to simply check MIDI messages.
+
[[Utilities/MIDI_Logger | MIDI Logger]] is an analysis tool for watching incoming MIDI messages. It is most helpful for debugging an application, or to simply check MIDI messages.
  
 
This application is only able to receive MIDI messages.
 
This application is only able to receive MIDI messages.
  
1. Select the cluster you'd like to receive from
+
# Select the cluster you'd like to receive from
 
+
# Select channels you'd like to view
2. Select channels you'd like to view
+
# Select the kind of MIDI message you'd like to view
 
 
3. Select the kind of MIDI message you'd like to view
 
  
 
Any message meeting your filter criteria will be displayed in the list.
 
Any message meeting your filter criteria will be displayed in the list.
  
 
== Playing a MIDI file ==
 
== Playing a MIDI file ==
MorphOS features a MIDI playback tool wisely named PlayMIDI. This is a Shell only tool that features the minimum for playback '.smf' MIDI files.
+
MorphOS features a MIDI playback tool wisely named [[Shell_Commands/PlayMidi | PlayMIDI]]. This is a Shell only tool that features the minimum for playback '.smf' MIDI files.
  
 
It takes a FILE argument that should point to a valid '.smf' MIDI file and a CLUSTERNAME argument that should point to an '.out' cluster name.
 
It takes a FILE argument that should point to a valid '.smf' MIDI file and a CLUSTERNAME argument that should point to an '.out' cluster name.
Line 83: Line 75:
 
For example:
 
For example:
  
PlayMIDI FILE=song.smf CLUSTERNAME=myinstrument.out
+
PlayMIDI FILE=song.smf CLUSTERNAME=myinstrument.out
  
 
The song will be sent to the 'myinstrument.out' cluster.
 
The song will be sent to the 'myinstrument.out' cluster.
 
See PlayMIDI (MZ library link to PlayMIDI page)
 
  
 
== Soft Synthesis ==
 
== Soft Synthesis ==
 
MorphOS does not feature any soft synthesis application for MIDI. You'll have to rely on an external application for that. One tool is available for
 
MorphOS does not feature any soft synthesis application for MIDI. You'll have to rely on an external application for that. One tool is available for
doing soft synthesis: FrozenLiquid (available at https://tcheko.binaryriot.org or MorphOS Storage).
+
doing soft synthesis: FrozenLiquid (available at the [https://tcheko.binaryriot.org developer's page] or [https://www.morphos-storage.net/?find=frozenliquid MorphOS Storage]).
  
 
FrozenLiquid needs a sound font for producing sound. Sound fonts are easy to find with any search engine.
 
FrozenLiquid needs a sound font for producing sound. Sound fonts are easy to find with any search engine.
Line 99: Line 89:
 
Starting FrozenLiquid is just a single step:
 
Starting FrozenLiquid is just a single step:
  
FrozenLiquid FILE=soundfontname.sf2
+
FrozenLiquid FILE=soundfontname.sf2
  
 
By default, FrozenLiquid will create a MIDI cluster based on the filename of the sound font.
 
By default, FrozenLiquid will create a MIDI cluster based on the filename of the sound font.
  
 
With PlayMIDI and FrozenLiquid, you can experience MIDI without owning any actual (hardware based) MIDI instrument.
 
With PlayMIDI and FrozenLiquid, you can experience MIDI without owning any actual (hardware based) MIDI instrument.

Revision as of 18:46, 1 June 2023

MorphOS is able to make use of the MIDI protocol with various system components.

To make best use of MIDI, it is advised to have some MIDI instruments be it physical devices or soft synthesis.

Low level components

All the MIDI intricacies are handled by two system components:

  • camd.library, which handles message parsing and delivery to applications
  • camdusbmidi.class, which bridges MIDI messages from USB compliant MIDI devices to camd.library

camd.library is located in SYS:MorphOS/Libs/ while camdusbmidi.class is located in SYS:MorphOS/Classes/USB/.

CAMD concepts

CAMD library was designed in the 90s using the concept of delivery by copying of MIDI messages.

When an application wants to use MIDI, it creates a MidiNode, which is a type of area for storing messages.

Once MidiNode is created by the application, this node is then linked to its destination name, the MIDI cluster.

MidiLink can be only a single type: sending or receiving. So, an application will send MIDI messages while some will receive MIDI messages. Some might do both.

All the mechanics of CAMD is based around MIDI clusters: they provide a user friendly way to promote MIDI flux. Usually, clusters are presented to a user to configure access to MIDI instruments.

Instrument(s) and application(s) can be started in any order. The cluster name is a collection point created by the first one joining the cluster.

Understanding the MIDI cluster naming scheme

When a MIDI instrument is connected to CAMD, it 'registers' itself to a MIDI cluster using a specific naming scheme.

Usually, an instrument will create a two way communication link, one for sending MIDI messages and another one for receiving MIDI messages.

The cluster name ending with '.out' is used to send MIDI messages to the instrument.

The cluster name ending with .'in' is used to receive MIDI messages from the instrument.

Those '.in' and '.out' are usually prefixed with a name. For example, you have a MIDI instrument of whatever make, which will usually be shown similar to 'Brand-DeviceName.in' and 'Brand-DeviceName.out'.

Installing & testing MIDI gear

Initial, first time, setup of MIDI gear can be quite intimidating. It has to be correctly wired if connected using legacy DIN connectors (inverting in and out isn't dangerous at all, it will just not work) and figuring out how to use an application often requires some getting used to.

MorphOS features two handy applications that can help with testing and boot-strapping MIDI gear:

  • MIDI Piano, is a simple virtual MIDI keyboard for sending or receiving MIDI messages
  • MIDI Logger, a tool for looking at MIDI messages

Both tools are located in SYS:Utilities/MIDI/.

Using Virtual MIDI Keyboard

Run it by double-clicking the MIDI Piano icon. You'll get a window with a large piano keyboard. VMK (Virtual MIDI Keyboard) is able to receive or send MIDI messages.

  1. Select the mode of operation with the first cycle, 'Receive' for ... receiving MIDI messages, 'Send' for ... you guessed it, sending MIDI messages.
  2. Select the cluster to connect to. If you're sending, be sure to select a cluster with a name ending in '.out'. Inversly, select an '.in' cluster for receiving.
  3. Select to which MIDI channels you want to send/receive MIDI messages. VMK will happily send/receive from multiple MIDI channels at once.
  4. a) If you are in receive mode, the piano keyboard won't react to mouse events but will colour the keys as/when receiving note events from the cluster.
    b) If in send mode, the piano keyboard will react to mouse event(s): clicking on the piano keys will emit MIDI messages to the selected cluster.

Tip: The MIDI instrument keeps emitting an annoying sound? If so, then send an 'All Notes Off' message with 'Send a MIDI message' using that menu option.

Using MIDI Logger

MIDI Logger is an analysis tool for watching incoming MIDI messages. It is most helpful for debugging an application, or to simply check MIDI messages.

This application is only able to receive MIDI messages.

  1. Select the cluster you'd like to receive from
  2. Select channels you'd like to view
  3. Select the kind of MIDI message you'd like to view

Any message meeting your filter criteria will be displayed in the list.

Playing a MIDI file

MorphOS features a MIDI playback tool wisely named PlayMIDI. This is a Shell only tool that features the minimum for playback '.smf' MIDI files.

It takes a FILE argument that should point to a valid '.smf' MIDI file and a CLUSTERNAME argument that should point to an '.out' cluster name.

For example:

PlayMIDI FILE=song.smf CLUSTERNAME=myinstrument.out

The song will be sent to the 'myinstrument.out' cluster.

Soft Synthesis

MorphOS does not feature any soft synthesis application for MIDI. You'll have to rely on an external application for that. One tool is available for doing soft synthesis: FrozenLiquid (available at the developer's page or MorphOS Storage).

FrozenLiquid needs a sound font for producing sound. Sound fonts are easy to find with any search engine.

Soft synthesis is producing sound with the help of the CPU. It can consume a large amount of CPU capability depending on the number of MIDI events required to process, and the complexity of the sound font.

Starting FrozenLiquid is just a single step:

FrozenLiquid FILE=soundfontname.sf2

By default, FrozenLiquid will create a MIDI cluster based on the filename of the sound font.

With PlayMIDI and FrozenLiquid, you can experience MIDI without owning any actual (hardware based) MIDI instrument.