Music Macro Language
Music Macro Language is a music description language used in sequencing music on computer and video game systems.
Background
Early automatic music generation functions were used in arcade games, which used many computer sounds. An example of an early popular Arcade game with music is The Circus from Exidy Corporation in 1977.The boom in Japanese video games was heralded in 1978 by the appearance in Japanese game centers of Space Invaders by TAITO Corporation.
The music was all proprietary. The 1978 release of the Programmable interval timer by Intel was significant. The Intel 8253 Mode 3 Square Wave generator was used for music, in the Kit computer MZ-40K by SHARP Corporation, made in Japan at May 1978. Another Micro computer :w:ja:ベーシックマスター|BASIC MASTER MB-6880 BASIC Master used a 5Bit D/A converter music automated reference signal. Also important was the development of a method to generate using BASIC software. The machine was assembled by Hitachi, Ltd. and made in Japan in September 1978.
The MZ-40K featured an open architecture and program sources, was therefore a kind of open source software.
Versions
Classical MML
The first commands for classical MML appeared in the internal architecture of the SP-1002 MONITOR IOCS and SP-5001 BASIC Operating Systems on the MZ-80K 8-bit computer. Made by SHARP Corporation at 1978 in Japan. It incorporated Intel 8253 hardware and memory mapped I/O. The sound-related BASIC Statements were MUSIC, TEMPO, and BEEP.Syntax
Classical MML as used in BASIC is described here. "MML Commands" are supplied to the MUSIC statement. Notes are specified in a three-octave range. A song is a sequence of mono single tones."+" indicates upper octave, "- " indicates the lower octave. The characters "CDEFGAB" correspond to a scale. A semitone is indicated by following the note with a '#' character. The note names are followed by a tone length, indicated by a number from 0-9. Similarly, R indicates a rest, and is also followed by a number from 0-9 indicating length.
Sound length Internal value × TEMPO values.Tone length Demisemiquaver is 0 - Whole note is 9.
Music played on Call to $0030 SP-1002 IOCS program routine.
Value | Length |
0 | 1/32 |
1 | 1/16 |
2 | dotted 1/16 |
3 | 1/8 |
4 | dotted 1/8 |
5 | 1/4 |
6 | dotted 1/4 |
7 | 1/2 |
8 | dotted 1/2 |
9 | 1 |
Statements TEMPO n is 1-9, the slowest 1.TEMPO 4 is similar T=120.
Example
Below is the popular Japanese song "tōryanse" written using MML in MZ-731 SHARP :ja:S-BASIC|S-BASIC 1Z-007B.10 TEMPO 4
20 A$="E5R1E3R0D3R0E3R0E1R0D1R0-G4R1"
30 B$="F3R0F1R0F1R0A3R0F1R0E1R0D1R0D1R0E5R0"
40 C$="C3R0C1R0C1R0E3R0C1R0-B1R0C1R0-B1R0-A1R0-A1-B5R0"
50 D$="E1R0E1R0E1R0E1R0E1R0E1R0D1R0E1R0E1R0E1R0D1R0-A1R0-A1R0B3R1"
60 E$="-A1R0-B1R0C1R0D1R0E1R0F1R0E1R0F3R1A3R1B1R0A1R0F3R0E3R0E1R0E4R0"
100 MUSIC A$+B$+B$
110 MUSIC C$+C$+B$
120 MUSIC C$+D$+E$
Modern MML
Modern MML originally appeared in Microsoft BASIC and was common in the early 1970s and 1980s on 8-bit and 16-bit era Japanese personal computers. The NEC PC-6001 included Microsoft BASIC and the Programmable Sound Generator in 1981. The MML was especially popular on NEC's personal computers, such as the NEC PC-8801. With the 2001 release of the mck software for compiling MML to play music on the Nintendo Entertainment System, awareness and use of MML increased. MML is presently popular among Japanese electronic musicians and musicians who create chiptunes as a way to write music for the Nintendo Entertainment System.Syntax
Modern MML originated as a sub-language of BASIC, then generally included in ROM on micro-computers. APLAY
statement uses an argument to define a string of tones that the sound-chip played. MML code has a simple text format whereby letters and numbers are used to describe the musical notes to be played. In addition, various implementations of MML add system extensions allowing parameters of audio synthesis to be altered with specialized commands or to simplify the entry of common musical figures such as arpeggios.Though many platforms feature custom extensions and letter case requirements and other minor syntactical features vary slightly in some implementations, the fundamental syntax rules, commands and features that define MML and are present in whole or in part in all implementations are as follows:
cdefgab
— The lettersa
tog
correspond to the musical pitches and cause the corresponding note to be played. Sharp notes are produced by appending a+
or#
, and flat notes by appending a-
. The length of a note is specified by appending a number representing its length as a fraction of a whole note — for example,c8
represents a C eighth note, andf+2
an F♯ half note.p
— A pause or rest. Sometimes alsor
, although the original IBM and Microsoft BASIC usedp
, as do all clones. The length of the rest is specified in the same manner as the length of a note — for example,r1
produces a whole rest.o
— Followed by a number,o
selects the octave the instrument will play in.>
,<
— Used to step up or down one octave.l
— Followed by a number, specifies the default length used by notes or rests which do not explicitly define one. For example,l8 g a b g l16 g a b g
produces a series of four eighth notes followed by a series of four sixteenth notes.v
— Followed by a number, sets the volume of the instrument. The range of values allowed is dependent upon the specific sound hardware being used. Some implementations also allow an ADSR envelope to be applied to the amplitude of each note.t
— Followed by a number, sets the tempo in beats per minute. On hardware with more than one sound channel, it is often possible to set each channel to a different tempo.
SMX
Standard Musical eXpression is a variant of Modern MML provided by Microsoft in QBASIC, BASICA, and GW-BASIC's statement. The version used by GW-BASIC is part of the modern BSDs, FreeBSD, NetBSD, OpenBSD, and MirOS; see speaker for the language.Languages, platforms and software
- Epic Games's ZZT and Super ZZT, as well as the open-source clone named MegaZeux, use a very compact variant of MML for the PLAY command, with only one channel for the PC Speaker
- Microsoft's QBASIC, BASICA, and GW-BASIC all feature a
PLAY
statement which takes a string argument in the SMX format. The name "Music Macro Language" may originate with GW-BASIC, which provided a facility "to play music by embedding a music macro language into the string data type." The SBasic compiler from the German magazine DOS Extra, produced by DMV Widuch, offers the same PLAY command, and a few-line BASIC programme could be compiled into a small tool to play any MML files given on the command line. - * Eric S. Raymond wrote a UNIX System V driver that offers /dev/speaker in a GW-BASIC-compatible format. It was subsequently ported to 386BSD and is present modern BSD operating systems.
- The NEC PC-8801's BASIC dialect, N88-BASIC, used MML in its
PLAY
statement, as did several other implementations of BASIC produced or sold by NEC. - * Chiptune composer Yuzo Koshiro created a heavily modified version. According to Koshiro, it "was more a BASIC-style language at first, but I modified it to be something more like Assembly. I called it ‘Music Love'. I used it for all the Bare Knuckle Games."
- Various MML utilities were written for the NEC PC-9801 family of computers, including PMD by game composer :ja:梶原正裕|Masahiro Kajihara, which was used by composer Ryu Umemoto for games like EVE Burst Error and Grounseed, as well as by game developer ZUN for most of his first five Touhou Project games.
- The mck, pmck, and ppmck utilities for creating Nintendo Entertainment System music, and a number of other tools for creating music for other hardware, such as the Bandai WonderSwan, the NEC PC Engine, and the Sega Mega Drive.
- The xpmck utility for creating music for various systems, including the Sega Master System, Sega Game Gear, Sega Mega Drive, Nintendo Game Boy, and Commodore 64.
- Some cellular phones utilize MML as a ringtone format. The RTTTL ringtone language exhibits many of the characteristics of MML.
- An escape sequence was defined to allow terminal programs play music encoded in MML. Because of this music in MML is sometimes called ANSI Music.
- On the MSX computer system, the built-in MSX BASIC also uses MML with PLAY-command. Comma separated strings represent separate voice channels. Music hardware expansions such as MSX-Music, MSX-Audio and MSX-MIDI expand PLAY-command so that also FM-chips and external MIDI devices can be controlled through MML.
- Sharp Pocket computer music routine PLAYX - .Nihongo -> :ja:ポケットコンピュータの製品一覧.
- is a free MML editor available for Windows and OS X while also offering Shared libraries for software/game developers.
- uses an extended format with a file header with metadata, a newline, and then one line for each staff, supporting multiple instruments, with bar lines. It’s designed to output to up to eight 3½″ floppy disc drives on Raspberry Pi GPIO ports. It also contains a library and utility, tested with MuseScore, allowing easy debugging of especially mass-parallel MML files, score sheet printing, etc. – Floppi-Music and MMLlib is Free Software written in pure Python.
- Petit Computer and SmileBASIC both offer
BGMPLAY
functions, which can either take a preset MML track or one provided as a string.