Music Macro Language

Short description: Programming language for generating computerized music

Not to be confused with the XML-based Music Markup Language, though Music Macro Language is sometimes erroneously called by this name.

This article's use of external links may not follow Wikipedia's policies or guidelines. Please improve this article by removing excessive or inappropriate external links, and converting useful links where appropriate into footnote references. (November 2024) (Learn how and when to remove this template message)

|

Music Macro Language (MML) is a music description language used in sequencing music on computer and video game systems.

## Contents

* 1 Origins of the term
* 2 Background
* 3 Versions
* 3.1 Classical MML
* 3.1.1 Syntax
* 3.1.2 Example
* 3.2 Modern MML
* 3.2.1 Syntax
* 3.2.2 Example
* 3.3 SMX
* 4 Historical BASIC MML comparison
* 4.1 SHARP MZ BASIC (SP-5030)
* 4.2 NEC PC-6001 (N60-BASIC)
* 5 Languages, platforms and software
* 6 See also
* 7 References

## Origins of the term

The term Music Macro Language (MML) was already in use by the early 1980s in descriptions of music-string syntax for personal computer BASIC dialects. One early documented example appears in BYTE magazine in May 1982, in an article on Japanese personal computers describing the OKI if-800, which states that “another sublanguage called MML (Music Macro Language) is used.”[1]

Microsoft documentation for GW-BASIC later described the syntax used by the PLAY statement as “a music macro language” embedded in a string expression.[2] This suggests that the term was associated with the textual command syntax used for computer music in Microsoft BASIC-derived environments by the early 1980s.[3]

Music-string notation itself predates GW-BASIC, as evidenced by contemporaneous BASIC documentation such as the OKI BASIC manual, which describes the PLAY statement for musical sequences but does not use the term “Music Macro Language”.[4]

The term MML is explicitly attested in published sources by 1982.[1]

## Background

Early automatic music generation functions were used in arcade video games, which used many computer sounds. Early examples of arcade video game music chiptunes include Gun Fight (1975) and Circus (1977).

The boom in Japanese video games was heralded in 1978 by the appearance in Japanese game centers (Amusement arcades) of Space Invaders by Taito.[5]

The music was all proprietary (closed source). 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 (Microcomputer Doctor (マイコン博士/まいこんはかせ, Maikon Hakase)) by SHARP Corporation, made in Japan at May 1978. Another Micro computer BASIC MASTER MB-6880(ja) BASIC Master (ベーシックマスター, 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.[6] The machine was assembled by Hitachi and made in Japan in September 1978. The MZ-40K used 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[7] and SP-5001 BASIC Operating Systems on the MZ-80K 8-bit[8] computer. Made by SHARP Corporation at 1978 in Japan.[9] It incorporated Intel 8253 hardware and memory mapped I/O. The sound-related BASIC Statements were MUSIC, TEMPO, and BEEP. [10]

#### Syntax

An open-sourced scan of page 110 of Sharp Corporation's 1987 MZ-80 BASIC Manual, describing the origins of the MML 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.

"+" (or in some old code, "￣") indicates upper octave, "- " (or in some old code, "_") indicates the lower octave. The characters "CDEFGAB" correspond to a scale ("Doremi Faso Lassi"). 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 (SP-1002 Internal value is 1)- Whole note is 9 (SP-1002 Internal value is 32). Music played on Call to $0030 SP-1002 IOCS program routine.[11]

The sound length  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 S-BASIC 1Z-007B (SP-5001 Upper compatible).[12]

10 TEMPO 4
20 A$="E5R1E3R0D3R0E3R0E1R0D1R0-B4R1"
30 B$="F3R0F1R0F1R0A3R0F1R0E1R0F1R0E1R0D1R0D1R0E4R1"
40 C$="C3R0C1R0C1R0E3R0C1R0-B1R0C1R0-B1R0-A1R0-A1R0-B4R1"
50 D$="E1R0E1R0E1R0E1R0E1R0E1R0D1R0E1R0E1R0E1R0D1R0-A1R0-A1R0-B4R1"
60 E$="-A1R0-B1R0C1R0D1R0E1R0F1R0E1R0F3R1A3R1B1R0A1R0F3R0E3R0E1R0D1R0E4R1"
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.[13] With the 2001 release of the mck (Music Creation Kit) software for compiling MML to play music on the Nintendo Entertainment System,[14] awareness and use of MML increased.[15] MML is presently popular among Japanese electronic musicians[13] and musicians who create chiptunes[16] 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. A `PLAY` 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.[13] 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:[13][17]

* `cdefgab` — The letters `a` to `g` 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, and `f+2` an F♯ half note.
* `p` — A pause or rest. Sometimes also `r`, although the original IBM and Microsoft BASIC used `p`,[18] as do all clones (e.g. the Linux and BSD speaker devices).[19] 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.

In addition to these, most implementations add their own keywords and symbols for system-specific enhancements or extensions.

#### Example

Below is a Modern MML transcription of Dance of the Cuckoos (with white-space for clarity, though some MML interpreters will require this to be stripped before playing).

t104

c16f16
a>c8<a c16f16
a>c8<a c8
b-8>c8<b-8 g c8
a8>c8<a8 f c16f16
a>c8<a c16f16
a>c8<a c8
b-8>c8<b-8 g >c8
<f2

Below is the popular Japanese song "tōryanse" written using MML in PC-6001( NEC PC-6000 series ) N60-BASIC.It is listed for comparison with Classical MML. [20]

10 A$="o4e2r32e4r32d4r32e4r32e8r32d8r32o3b2r16"
20 B$="o4f4r32f8r32f8r32a4r32f8r32e8r32f8r32e8r32d8r32d8r32e2r16"
30 C$="o4c4r32c8r32c8r32e4r32c8r32o3b8r32o4c8r32o3b8r32a8r32a8r32b2r16"
40 D$="o4e8r32e8r32e8r32e8r32e8r32e8r32d8r32"
50 E$="o4e8r32e8r32e8r32d8r32o3a8r32a8r32b2r16"
60 F$="o3a8r32b8r32o4c8r32d8r32e8r32f8r32e8r32"
70 G$="o4f4r32a4r32b8r32a8r32f4r32"
80 H$="e4r32e8r32d8r32e2r16"
100 PLAY "t120"
110 PLAY A$
120 PLAY B$
130 PLAY B$
140 PLAY C$
150 PLAY C$
160 PLAY B$
170 PLAY C$
180 PLAY D$
190 PLAY E$
200 PLAY F$
210 PLAY G$
220 PLAY H$

### SMX

Standard Musical Expression (SMX) is a variant of Modern MML provided by Microsoft in QBASIC, BASICA, and GW-BASIC's `PLAY` statement.[13] The version used by GW-BASIC is part of the modern BSDs, FreeBSD,[21] NetBSD, OpenBSD, and MirOS; see speaker(4) for the language.[22]

## Historical BASIC MML comparison

The following example shows the same melody (Twinkle, Twinkle, Little Star) written using BASIC syntax in two early Japanese microcomputer MML dialects: BASIC for the Sharp MZ and NEC PC-6001 N60-BASIC. The comparison illustrates differences in syntax structure, command integration, and playback methods between early implementations of Music Macro Language.

### SHARP MZ BASIC (SP-5030)

Characteristics:

* Tempo is defined using a separate BASIC command.
* The melody is stored in a string variable.
* Additional phrases are appended using BASIC string concatenation.
* Note lengths are expressed numerically after each pitch.
* Playback is executed using the BASIC `MUSIC` statement.
* Sound output is monophonic due to hardware limitations of early systems.
* Sound is produced through the internal speaker controlled directly by the computer.

Example

10 TEMPO 4
20 A$="C3C3G3G3A3A3G6"
30 A$=A$+"F3F3E3E3D3D3C6"
40 A$=A$+"G3G3F3F3E3E3D6"
50 A$=A$+"G3G3F3F3E3E3D6"
60 A$=A$+"C3C3G3G3A3A3G6"
70 A$=A$+"F3F3E3E3D3D3C6"
80 MUSIC A$

In this implementation the musical data is constructed step-by-step as a BASIC string variable. The melody is expanded using string concatenation (`A$=A$+"..."`) before being passed to the `MUSIC` command for playback.

### NEC PC-6001 (N60-BASIC)

Characteristics:

* Tempo (`T`), octave (`O`), and default note length (`L`) are embedded within the PLAY string.
* The melody is written directly using inline MML within a BASIC `PLAY` statement.
* Default note length can be set once and reused for subsequent notes.
* Note lengths may be explicitly specified or inherited from the default length.
* Playback is executed using the BASIC `PLAY` statement.
* Sound output remains monophonic, typical of early home computer sound hardware.
* Sound is generated using the computer's internal speaker.

Example

10 PLAY "T120 O4 L4"
20 PLAY "C C G G A A G2"
30 PLAY "F F E E D D C2"
40 PLAY "G G F F E E D2"
50 PLAY "G G F F E E D2"
60 PLAY "C C G G A A G2"
70 PLAY "F F E E D D C2"

These examples illustrate how early BASIC-based MML implementations often relied on surrounding program structure, whereas later systems increasingly integrated musical control parameters directly within the MML command syntax.

Early forms of MML were commonly implemented in BASIC interpreters on Japanese 8-bit microcomputers during the late 1970s and early 1980s. Systems such as the Sharp MZ series and NEC PC-6001 allowed users to compose simple melodies using textual notation embedded in BASIC programs. These early implementations established conventions such as note letters, octave control, and tempo parameters that later evolved into more sophisticated MML dialects used in music drivers and game development environments on platforms including the NEC PC-8801 and PC-9801.

Early BASIC-based MML systems on Japanese microcomputers later influenced more advanced music drivers and composition environments developed for programmable sound hardware, including software such as Professional Music Driver used on NEC PC-9801 systems.

## 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.[23][24][25] 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".[26] 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 (few KiB) tool to play any MML files (often called *.PLY) given on the command line.
* Eric S. Raymond wrote a UNIX System V driver that offers /dev/speaker in a GW-BASIC-compatible format.[27] It was subsequently ported to 386BSD and is present in modern BSD operating systems.[22]
* 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.[13][28]
* 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."[29]
* Various MML utilities were written for the NEC PC-9801 family of computers, including PMD (Professional Music Driver)[15] by game composer Masahiro Kajihara (most commonly known as KAJA),[30] 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,[14][31] 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.[15]
* The xpmck utility for creating music for various systems, including the Master System, Game Gear, Mega Drive, Nintendo Game Boy, and Commodore 64.[32]
* Some cellular phones utilize MML as a ringtone format.[33] 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.[34]
* 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 - MyArchive.Nihongo -> :ja:ポケットコンピュータの製品一覧.
* Macrotune is a free MML editor available for Windows and OS X while also offering Shared libraries for software/game developers.
* FlopPI-Music (archived old documentation page) uses an extended format with a file header with metadata (such as Author, Title, etc.), a newline, and then one line for each staff, supporting multiple instruments, with bar lines. It is designed to output to up to eight 3 1⁄2 in (89 mm) floppy disc drives on Raspberry Pi GPIO ports. It also contains a standalone MML parser and MusicXML exporter library and utility, tested with MuseScore, allowing easy debugging of especially mass-parallel MML files, score sheet printing (ideally after some minimal postprocessing, but the defaults are usually legible), 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.
* An MMO called Mabinogi allows players to type MML code onto in-game music score scrolls which can then be played for everyone nearby to hear using an equipped instrument. Due to that social aspect, users often made their own MML versions of popular songs and uploaded them to fansites. The game also teaches users the syntax via skill books, which doubled as a way to unlock a higher size limit when writing the code. ArcheAge MMO provides the same features.
* A Windows program called 3MLE was made by a Mabinogi user to assist in writing MML scrolls. The program functions similarly to an IDE, allowing the user to write, optimize, and test MML code for different instruments.

## See also

* Chiptune
* Electronic music
* HTML audio
* MIDI
* Synthetic music mobile application format
* MUCOM88
* Professional Music Driver
* YM2608

## References

1. ↑ 1.0 1.1 Kocher, Christopher P.; Keith, Michael (May 1982). "Six Personal Computers from Japan". BYTE 7 (5): 66. https://archive.org/details/BYTE_Vol_07-05_1982-05_Japanese_Computers. "Another sublanguage called MML (Music Macro Language) is used.".
2. ↑ Microsoft GW-BASIC User's Guide and Reference. Microsoft. 1989. https://www.bitsavers.org/pdf/microsoft/gw-basic/Microsoft_GW-BASIC_Users_Guide_and_Reference_1989.pdf.
3. ↑ Selfridge-Field, Eleanor, ed (1997). Beyond MIDI: The Handbook of Musical Codes. MIT Press. ISBN 9780262193948.
4. ↑ IF800によるBASICテキスト. コロナ社. 1982. pp. 137–139. https://dl.ndl.go.jp/pid/12631702.
5. ↑ Compiled by "Tomohiro Nishikado" (西角友宏/にしかどともひろ) worked in the Pacific Industrial Co., Ltd. All compiled alone.
6. ↑ PDF file;Micro Computer BASIC MASTER MB-6880 Music method \- Kunihiko, Nagai; Teruhiro, Takezawa; Kazuma, Yoshimura; KaTsutoshi, Tajima (1979-04-26). "Hitachi Hyoron April 1979 Special Features:A micro-computer, the application method". http://digital.hitachihyoron.com/digital/search_pdf/1979/.
7. ↑ "SHARP MZ.org MZ-80K monitor sub $0030". 2012-09-20. http://www.sharpmz.org/mz-80k/monisubprg.htm.
8. ↑ CPU is Z-80 Zilog Licensed Secondary source
9. ↑ Nobuaki Ohishi (2012-09-20). "Nibbles lab.SHARP Museum,MZ-80K Photo and Catalog.". http://www.retropc.net/ohishi/museum/mz80k.htm.
10. ↑ SHARP Corporation; nagusa_kei (1978). MZ-80 BASIC SP-5030 マニュアル. SHARP Corporation. p. 110. -Document(validation) Upper Version SP-5030 "twitter oec_Nibbleslab". 2012-09-22. https://mobile.twitter.com/oec_Nibbleslab/status/249167231089528833#!/oec_Nibbleslab/status/249167231089528833. - ~~"twitter PlayTrueName". 2012-09-22. https://mobile.twitter.com/PlayTrueName/status/249321942530801664#!/PlayTrueName/status/249321942530801664. ~~"twitter(twilog) PlayTrueName". 2012-09-22. http://twilog.org/tweets.cgi?id=PlayTrueName&word=SP-5030のMUSIC文. SHARP Corporation (1978). MZ-80 BASIC マニュアル. SHARP Corporation. p. 110.
11. ↑ "SHARP MZ.org MZ-80K monitor sub $0030". 2012-09-20. http://www.sharpmz.org/mz-80k/monisubprg.htm. /"SHARP MZ.org MZ-700 monitor sub $0030". 2012-09-20. http://www.sharpmz.org/mz-700/monisubprg.htm.
12. ↑ Motoi, Kenkichi. "Viewpoint of the eye. She said "you playing" I'm crying/Awamomo Office". http://d.hatena.ne.jp/awamomo/20120919. Programmed and arranged by Motoi, Kenkichi. "Twitter @PlayTrueName Σ:D『So long time wake up to the◎Programming to sound of music". https://mobile.twitter.com/PlayTrueName/status/248576767986655232#!/PlayTrueName/status/248576767986655232. Licensed #AAAP(Including Creative Commons CC-BY-SA and Text of GNU Free Documentation License.).
13. ↑ 13.0 13.1 13.2 13.3 13.4 13.5 Selfridge-Field, Eleanor (1997). Beyond Midi: The Handbook of Musical Codes. Cambridge: MIT Press. ISBN 0-262-19394-9.
14. ↑ 14.0 14.1 "VORC Internet Chiptune Encyclopedia - mck". http://www.vorc.org/en/info=mck.
15. ↑ 15.0 15.1 15.2 "VORC Internet Chiptune Encyclopedia - MML". http://www.vorc.org/en/info=MML.
16. ↑ "VORC: VGM or Chiptune of The Year 2001". 2001-12-31. http://www.vorc.org/en/columns/hally/2001best10e.html.
17. ↑ Johnson, Jeremiah. "MCK/MML Beginners Guide". http://www.nullsleep.com/treasure/mck_guide/.
18. ↑ "IBM BASIC manual, Second Edition (May 1982), Version 1.10". http://maben.homeip.net/static/S100/IBM/software/languages/IBM B.pdf.
19. ↑ MirBSD speaker device documentation
20. ↑ Programmed by MOTOI_Kenkichi November,11 2024.Licensed #AAAP(Including Creative Commons CC-BY-SA and Text of GNU Free Documentation License.).
21. ↑ FreeBSD speaker(4) manual page
22. ↑ 22.0 22.1 speaker(4) manual page
23. ↑ QBasic manual. Microsoft Corporation. 1991.
24. ↑ IBM Personal Computer BASIC manual. IBM Corporation. 1982.
25. ↑ BASICA manual. Microsoft Corporation. 1982.
26. ↑ GW-BASIC manual. Microsoft Corporation. 1987.
27. ↑ Raymond, Eric (7 May 1995). "Eric Raymond's Open-Source Works". http://www.catb.org/~esr/software.html.
28. ↑ Koshiro, Yūzō. "Yuzo Koshiro Interview" (Interview). Interviewed by Kikizo Games. Retrieved 2008-02-13.
29. ↑ Szczepaniak, John. "Retro Japanese Computers: Gaming's Final Frontier". Hardcore Gaming 101. http://www.hardcoregaming101.net/JPNcomputers/Japanesecomputers.htm. Reprinted from  Retro Gamer, 2009
30. ↑ "ツールのお部屋" (in ja). http://www5.airnet.ne.jp/kajapon/tool.html.
31. ↑ "VORC Internet Chiptune Encyclopedia - ppmck". http://www.vorc.org/en/info=ppmck.
32. ↑ Swimm, Peter (December 21, 2009). "XPMCK - Cross Platform Music Compiler Kit updated". True Chip Till Death. https://truechiptilldeath.com/blog/2009/12/21/xpmck-cross-platform-music-compiler-kit-updated/.
33. ↑ "着信メロディは再び自分で作る時代に？──MIDIファイルやWAVファイルを着メロに変換". ITmedia, Inc.. 2001-04-03. https://plusd.itmedia.co.jp/mobile/0104/03/music.html.
34. ↑ "ANSI Music - The Technical Details". http://artscene.textfiles.com/ansimusic/information/ansimtech.txt.

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Music Macro Language. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Music_Macro_Language&oldid=4345043"