MIDI is shorthand for “Musical Instrument Digital Interface,” and is a standard protocol for describing electronic music. In this chapter I will describe how to convert an abstract performance as defined in Chapter 21 into a MIDI file that can be played on any modern PC with a standard sound card.
module MDL where
import Music
import Perform
import Haskore (MidiFile (‥), MidiChannel, ProgNum, MEvent, MFType, Velocity, MEvent (‥), MidiEvent (‥), MetaEvent (‥), Division (‥), MTempo, outputMidiFile)
import List (partition)
import System (system)
As mentioned in Chapter 20, Haskore is a library for computer music that is more extensive than MDL, and I will borrow much of the basic MIDI data types defined there, as well as the low-level function outputMidiFile, to be described later.
An Introduction to MIDI
MIDI is a standard adopted by most, if not all, manufacturers of electronic instruments. At its core Is a protocol for communicating musical events (such as note on, note off, key press, pedal press) as well as socalled meta events (such as select synthesizer patch, change volume). Beyond the logical protocol, the MIDI standard also specifies electrical signal characteristics and cabling details. In addition, it specifies what is known as a Standard MIDI File, which any MIDI-compatible software package should be able to recognize.
Over the years musicians and manufacturers decided that they also wanted a standard way to refer to common or general instruments such as “acoustic grand piano,” “electric piano,” “Violin,” and “acoustic bass,” as well as more exotic ones such as “chorus aahs,” “voice oohs,” “bird tweet,” and “helicopter.” A simple standard known as General MIDI was developed to fill this role, It is nothing more than an agreed-upon list of instrument names along with a program patch number for each, a parameter in the MIDI standard that is used to select a MIDI instrument's sound. The constructor names in the IName data type (see Fig. 20.1. In Chapter 20) come directly from this standard.
Review the options below to login to check your access.
Log in with your Cambridge Aspire website account to check access.
If you believe you should have access to this content, please contact your institutional librarian or consult our FAQ page for further information about accessing our content.