Koepf's EditionsComputer Projects – The MSQ Project

The MSQ Project

Siegfried Koepf, 2000

1. Introduction

The MSQ Project was originally created in 1998 by Siegfried Koepf and Bernd Haerpfer needing a MIDI compatible computer system for algorithmic composition and score synthesis. It was carried on to the current level MSQ 2.0 by Siegfried Koepf. The idea was to have a platform independent, easily readable and editable file format qualified for algorithmic manipulation and composition as well as for real time controlling MIDI instruments.
The MSQ file format, a plain ASCII text file format, represents sequences of MIDI commands in strictly chronological order even when multiple MIDI tracks are present. It does not only allow the translation of MIDI files to some readable text (and vice versa) but is a well defined and MIDI compatible file format itself.
Programmers, composers and musicians are invited to develop their own tools to process MSQ files or just to download the MSQ package and use the existing tools.

2. MSQ 2.0 specification

The MSQ 2.0 standard supports the MIDI file formats 0 and 1. It is compatible with what is known as 'The MIDI Standard' as described in many resources on the web. Not supported by now is anything related to SMPTE.

2.1. MSQ file format

MSQ files are plain ASCII text files. To simplify their identification, MSQ files usually have the extension .MSQ. The first line of a MSQ file must contain a MIDI TICKS setting as:

TICKS = 120

where the tokens may be separated by white spaces (not tabulators). The TICKS value sets the maximal number of subdivisions of a quarter note. About limits of the TICKS value see Ranges and conditions. Each further line consists of a complete MIDI message with an absolute time value in ticks, followed by a track number, a MSQ symbol (see MSQ symbols), channel number in case of a Channel Message and appropriate further data. For a detailed description of the line syntax, see General form of a MSQ line. The tokens must be separated by one or more white spaces (not tabulators). There is no limit for the overall size of an MSQ file but the maximum number of characters in a line is 256 (this value has been increased from 128 to 256 in 2007 – only MSQ tools with version 0.5.0 and higher will accept this new limit). For visual reasons, empty lines are allowed.

2.2. General form of a MSQ line

Basically, a MSQ line consists of three or more tokens separated by white spaces:

xxx xxx xxx xx xxx xxx etc...

where the first token represents a time value of the event in ticks,
followd by a track number,
followd by a MSQ symbol,
followd by a channel number (in Channel Messages only),
followd by optional data bytes.

Here are some examples of valid MSQ lines:

Channel Messages
0 1 NOF 0 64 100
0 1 NON 0 64 100
0 1 PCH 0 2

System Messages
0 1 SEX 67 16 53 13 0 0 17 0 64
0 1 ASE

Meta Events
0 0 _CR some text
0 0 _ST 500000
0 0 _TS 3 2 24 8

Here is an example of a complete MSQ 2.0 file: gloter2.msq. The file represents Glockenterror II, one of my piano pieces, written in 1997.

2.3. MSQ symbols

This table shows a list of all MSQ symbols with corresponding MIDI messages and expected data in each case.

MSQ Symbols
Channel Messages
MSQ symbolMIDI messageExpected data
NOFNote Offchannel number, 2 data bytes
NONNote Onchannel number, 2 data bytes
PAFPoly Aftertouchchannel number, 2 data bytes
CCHControllerchannel number, 2 data bytes
PCHProgram Changechannel number, 1 data byte
CAFChannel Aftertouchchannel number, 1 data byte
PWHPitch Wheelchannel number, 2 data bytes

System Messages
MSQ symbolMIDI messageExpected data
SEXSystem Exclusiveuncommitted data bytes
MTCMTC Quarter Frame Message1 data byte
SPPSong Position Pointer2 data bytes
SELSong Select1 data byte
TRETune Requestno data
MCLMIDI Clockno data
TICTickno data
STAMIDI Startno data
CONMIDI Continueno data
STOMIDI Stopno data
ASEActive Senseno data
SREResetno data

Meta Events
MSQ symbolMIDI messageExpected data
_SNSequence Number2 data bytes
_TEText EventASCII text
_CRCopyright NoticeASCII text
_TNSequence/Track NameASCII text
_INInstrument NameASCII text
_LYLyricASCII text
_MAMarkerASCII text
_CUCue PointASCII text
_CPMIDI Channel Prefix1 data byte
_MPMIDI Port1 data byte
_STSet Tempo1 data DWORD
_SMSMPTE Offset5 data bytes (not implemented)
_TSTime Signature4 data bytes
_KSKey Signature2 data bytes
_SQSequencer Specificuncommitted data bytes

2.4. Ranges and conditions

This table shows lower and upper limits of MSQ values.

Ranges of MSQ values
MSQ valuesminmax
TICKS in the first line of a MSQ file 1 32767
Number of characters in a line in a MSQ file 0 256
Time value in ticks, the first row in a MSQ file 04294967295
Difference of two successive time values 0 268435455
Track number, the second row in a MSQ file 0 65535
Channel number in Channel Messages 0 15
The Meta Event _SN (Sequence Number) must occur at the beginning of a track 0 127
Channel number, the value in Meta Event _CP (MIDI Channel Prefix) 0 15
Tempo, the value in Meta Event _ST (Set Tempo) 1 16777215
Numerator, first value in Meta Event _TS (Time Signature) 1 127
Exponent, second value in Meta Event _TS (Time Signature) 0 7
Clocks, third value in Meta Event _TS (Time Signature) 1 127
32nds, fourth value in Meta Event _TS (Time Signature) 1 127
Flats/sharps, first value in Meta Event _KS (Key Signature)-7 7
Scale, second value in Meta Event _KS (Key Signature) 0 1
Other data bytes 0 127

3. MSQ tools

Five MSQ tools are currently available. All programs are console applications, written by Siegfried Koepf.

msq2mid
Description MSQ to MIDI converter
Converts MSQ files to Standard MIDI files
Usage msq2mid msq-file midi-file
where msq-file is the source and midi-file is the target file name
Example msq2mid gloter2.msq gloter2.mid
Version 0.5.1
Operating System WINDOWS and LINUX
Last update December 20, 2010
mid2msq
Description MIDI to MSQ converter
Converts Standard MIDI files to MSQ files.
Usage mid2msq midi-file msq-file
where midi-file is the source and msq-file is the target file name
Example mid2msq gloter2.mid gloter2.msq
Version 0.5.1
Operating System WINDOWS and LINUX
Last update December 20, 2010
merge
Description MSQ file merge
Merges two MSQ files together
Usage merge msq-file-1 msq-file-2 msq-file-3
where msq-file-1 and msq-file-2 are the source and msq-file-3 is the target file name
Version 0.5.1
Operating System WINDOWS and LINUX
Last update December 20, 2010
play
Description MSQ file player (sequencer)
Plays MSQ files on any MIDI device
Usage play <msq-file> [-d<device-id>] [-s<n>] [-v] [-h]
where <msq-file> is the name of the MSQ file to be played
Options -d<device-id> where <device-id> is the ID of the MIDI device to use (to find available devices on a running system use mmid). Without -d play uses the default MIDI device
-s<n> where <n> is a ticks value from where the playback will be started
-v shows a tick counter while playing
-h shows a help screen
Example play gloter2.msq -d0 -s2112 -v
Hotkeys [ESC] to stop the program
[SPACE] toggles between pause and continue
Version 0.5.1
Operating System WINDOWS
Last update December 20, 2010
mmid
Description Multi Media device ID finder
Finds the IDs of currently available Multi Media devices on the running system to use with play
Usage mmid
Version 0.5.1
Operating System WINDOWS
Last update December 20, 2010

4. Feedback

Your feedback is welcome here.

5. Download and terms

The MSQ package may be used for non-commercial purposes and freely distributed in the format originally released. It is provided "as is", you get no guarantees because all standard disclaimers apply! All programs and documentation are copyrighted © 2000-2010 by Siegfried Koepf. They can be downloaded here:
Download MSQ tools for WINDOWS
Download MSQ tools for LINUX

Last update: 20.10.2021

WebCounter

(WebCounter)