midi
MIDI stands for Musical Instrument Digital Interface. It is actually a system of devices, communications and digital information that enables a musical interpretation according to a certain digital protocol.
Midi concepts:
Midi messages:
Coding of notes and intensity (volume), instrument controls, instrument assignment to channels,….
Sound messages are groups of digits that represent the beginning of the note (note-on) and its volume (intensity) or the end of the note sound (note-off). They usually have an associated channel.
Sound messages:
Note-on, Note-off, Aftertouch, Pitch bend change, Program change, Control change.
Meta messages:
They are information messages: text, lyrics, scale, compass,… ..
Channel:
represents an instrument. A message (type: program change) assigns a channel to an instrument. Each message has a built-in channel code (0 to 15).
Track:
set of midi messages, recorded on a given medium, can be grouped into 16 channels.
Sequence:
set of tracks, represents a midi file.
Midi devices:
Keyboard:
keyboard, source of midi messages.
Sequencer:
writes and reads midi files, creates a sequence of midi messages from a midi file.
Synthesizer:
Sound synthesizer. They convert midi messages into sound. They can be multitimbral (support of different instruments) and / or polyphonic (several notes at the same time).
Midi devices are electronic devices used by record studios to record music tracks, edit notes, burn records,…. They are also used by music bands. They are the support of karaoke devices.
Midi devices have an input port (in) and an output port (out).
PC can make Sequencer and Synthesizer and through the usb port connect with external midi devices.
Fortunately, java has a class package:
javax.sound.midi
which encapsulate the above concepts and allow us to read / write sequences, read / write tracks, decode messages, play back a sequence, etc.
Java classes that support the midi system:
MidiSystem:
Provides a list of installed devices.
MidiDevice:
Synthesizer, Sequencer. Java can encapsulate both devices in the same class.
Sequencer methods:
start / stop playback, start / stop recording.
Transmission / Reception:
Transmit, Receiver. They represent ‘plugs’ to the devices.
MidiChannel
Instrument
MidiMessage
MidiEvent
Track
Sequence
MidiMessages:
They are: ShortMessage (Sound and control messages), SysexMessage (builder’s own messages), MetaMessage (information and set-tempo).
Transmitter / Receiver connection:
A transmitter can be associated with one device (e.g. Sequencer) and a receiver with another device (e.g. Synthesizer), and finally the transmitter can be connected to the receiver. Midi messages are transmitted from the Transmitter to the Receiver.
MidiEvent:
It is an object formed by MidiMessage plus time. Time is a variable that indicates when the message should be executed from the beginning of the sequence. Time is quantified in ticks and in two different ways: PPQ or SMPT.
PPQ: parts per quarter. Quarter = 1 black. F.e. if PPQ = 480 (this is called resolution), it means that the duration time of a black is 480 ticks. The setTempo message assigns a number of microseconds to a black one. If setTempo = 500,000, it means that a black (480 ticks) lasts 0.5 seconds, ie 1 tick = 500000/480 microseconds.
SMPT: frames per second.
And now a digression…
The digital representation of an analog system has a number of advantages such as storing without loss of quality (a 3 will always be a 3, possible it can not be read, but it will never be a 3.002, an analog variable can suffer degradation) and the possibility of editing, at least, within current technological knowledge. But it is still interesting the interest we have in modeling systems digitally, when we ourselves are analog systems, it must be that our brain is square or is the result of the battle between digital computers (American technology) and analog computers (Soviet Union technology), in the middle of the twentieth century, and which opted for digital for commercial reasons.