MIDI Support
Csound Shell for BeOS
Menus
Environment Variables
Sound Synthesis
Heterodyne Filter Analysis
Linear Predictive Analysis
Short-Time Fourier Analysis
Fourier Analysis
Job Execution
BeOS Server
MIDI Support
BeOS MIDI Architecture
MIDI Input to Csound
MIDI Output from Csound
Manipulating MIDI Endpoints
Valid HTML 4.0!
BeOS MIDI Architecture
BeOS supports MIDI devices and applications via a simple, flexible and powerful software architecture. Every piece of hardware or software which sends or receives MIDI data is represented by a set of endpoints. All endpoints have descriptive names and unique integer IDs. Endpoints internal to an application may be invisible to the outside, but applications can make endpoints public to provide an interface to the outside. MIDI device drivers also provide public endpoints.

Each endpoint is either a producer or a consumer, depending on the direction in which MIDI data passes through the endpoint. Producers and consumers can be freely interconnected; a producer can send data to an arbitrary number of consumers, and a consumer can receive data from multiple producers. Connections between producers and consumers can be made or broken at any time.

The following diagram shows some examples of interconnections between MIDI devices and applications:

MIDI Architecture

(Note that the diagram does not accurately represent the way in which MIDI devices are connected. In reality, MIDI devices are connected physically to MIDI interfaces, and the hardware endpoints shown in the diagram actually reside in the device drivers.)

^ MIDI Input to Csound
Csound can process MIDI data coming from a standard MIDI file (although it doesn't support all possible file formats). MIDI events coming from a file are processed like ordinary score events; the mechanisms mentioned above play no part in this process. To let Csound read MIDI data from a file, specify the file name in the MIDI Input text entry field and switch the Realtime MIDI input check box to off:
MIDI Input Controls
If you switch on the Realtime MIDI input check box, the name you specify in the MIDI Input field no longer identifies a file; in this case, two things happen when you start execution:
  1. Csound provides a MIDI consumer whose name is the string Csound: followed by the name specified in the MIDI Input field.
  2. If the system already contains a MIDI producer whose name matches the given one (without prefix), this producer is connected to the new MIDI consumer. Csound starts receiving and processing MIDI events coming from this producer.
As a convenience, all known MIDI producers are put in a pop-up menu which is accessible by clicking the small button in the MIDI Input text entry field.

Input from a known MIDI producer
The simplest way to use Csound as a MIDI synthesizer is to take input from a MIDI producer which is publically visible, e.g., a hardware MIDI input. To do this, select the producer from the pop-up menu in the MIDI Input text entry field. Make sure the Realtime MIDI input check box is switched on.

Input from other MIDI sources
You may want to use Csound as a consumer of MIDI data produced by an application which doesn't provide a public endpoint. As long as the application allows you to redirect its MIDI output to a known consumer, this is still possible:
  1. Type a name (preferrably unique, but it really doesn't matter) into the MIDI Input text entry field, switch on the Realtime MIDI input check box, and start Csound.
  2. In the application from which you want Csound to receive MIDI events, send the output data to the now publically visible MIDI consumer whose name is Csound: plus the name you used in step 1.
^ MIDI Output from Csound
MIDI Output Controls
The name you specify in the MIDI Output field identifies a new MIDI producer, and possibly a connection made from it. When you start execution,
  1. Csound creates a MIDI producer whose name is the string Csound: followed by the name specified in the MIDI Output field.
  2. If the system already contains a MIDI consumer whose name matches the given one (sans prefix), the new MIDI producer is connected to this consumer.
As a convenience, all known MIDI consumers are put in a pop-up menu which is accessible by clicking the small button in the MIDI Output text entry field. The special name Csound:BMidiSynth identifies a consumer residing in the Csound Server, which allows you to send data to the software MIDI synthesizer provided by the BeOS.

Ouput to a known MIDI consumer
To send MIDI data from Csound to a publically visible MIDI consumer, e.g., a hardware MIDI output, select the consumer from the pop-up menu in the MIDI Output text entry field. (There should always be at least one entry that you can use, since Csound:BMidiSynth is available as long as the Csound Server is running.)

Output to other MIDI receivers
You may want to use Csound as a producer of MIDI data for another application which doesn't provide a public endpoint. As long as the application allows you to take MIDI input from a known producer, this is still possible:
  1. Type a name (preferrably unique, but it really doesn't matter) into the MIDI Output text entry field and start Csound.
  2. In the application which you want to receive MIDI events from Csound, select as an input the now publically visible MIDI producer whose name is Csound: plus the name you used in step 1.
^ Manipulating MIDI Endpoints
Besides the methods outlined above, the BeOS MIDI architecture allows you a variety of other ways to connect Csound to other MIDI applications. Csound publishes its MIDI input and output endpoints using readily identifiable names (the string Csound: followed by whatever name you want to use). Various third-party applications are available that let you connect these public endpoints to other MIDI producers and consumers. One very simple (but useful) program is PatchBay, a small sample application by Be, Inc., which lets you make or break connections between any consumer or producer in the system.
PatchBay window

MIDI producers appear at the left side of the window, with small gauges that give an indication of the number of events produced by each. MIDI consumers are shown along the top edge; the matrix of check boxes indicates which producers are connected with which consumers (note that multiple connections are perfectly OK). The check boxes can also be used to change the connections. (Names of endpoints are not shown in the window, but they appear as "tip" windows when the mouse moves over one of the icons.)

For your convenience, PatchBay is bundled in the Csound distribution for BeOS. Please note that the licensing conditions for the rest of the distribution do not apply to this program; it is covered by the Sample Code License from Be, Inc.


Copyright © 2000 Jens Kilian. This file may be distributed under the conditions of the GNU General Public License.