Fact-checked by Grok 2 weeks ago

Music Macro Language

Music Macro Language (MML) is a text-based music description language that enables the sequencing and playback of music on early personal computers and consoles using simple alphanumeric strings to denote notes, durations, octaves, tempos, and effects. Originating in during the late 1970s, it was first implemented as music commands within interpreters on systems like the series, allowing direct embedding of into program code for hardware-limited sound generation via components such as the timer. The formal naming of "Music Macro Language" emerged with GW-BASIC in the 1980s, where the PLAY statement processed strings to produce tones through the , supporting features like note specification (e.g., C for middle C), length modifiers (e.g., L4 for quarter notes), octave shifts (e.g., O3), and tempo settings (e.g., T120 for 120 beats per minute). This syntax, resembling ASCII sheet music, facilitated easy composition without specialized editors and became integral to Japanese computing culture on platforms like the NEC PC-88 and MSX. Over time, MML evolved beyond , powering sound drivers in video games for consoles such as the () and through compilers like the Music Compiler Kit (MCK), which convert MML text into binary audio data compatible with specific sound chips (e.g., the NES's 2A03). Its simplicity and portability made it a staple in the scene, enabling retro-style music creation, (e.g., via tools like AddMusicK for ), and modern applications in software editors like Macrotune. Despite the rise of graphical trackers, MML persists among enthusiasts for its precise control and text-based workflow, particularly in Japan's doujin game development and online communities.

Overview and History

Definition and Purpose

Music Macro Language (MML) is a designed for describing musical sequences through concise alphanumeric notations. Early concepts originated in 1978 with Corporation's MZ-80K computer, using proprietary BASIC commands for music generation, and evolved into a standardized form as an extension within interpreters for microcomputers in the early 1980s. This text-based system enables the specification of pitches, durations, volumes, and other musical parameters in a compact, readable format, allowing users to compose and play music directly via simple string inputs. The primary purpose of MML is to facilitate programmatic music generation on resource-constrained hardware, providing an accessible method for creating tones, rhythms, and effects without requiring graphical user interfaces or complex software tools. It was particularly suited to the limitations of early computers, where and power were scarce, by translating human-readable commands into instructions for playback. This approach democratized music for hobbyists and developers, integrating seamlessly into programming environments like BASIC's PLAY statement. Key advantages of MML include its compact representation, which minimizes storage needs for musical data; ease of embedding within code for dynamic generation or modification; and inherent support for polyphony, enabling multiple simultaneous voices despite hardware constraints such as limited sound channels. These features made it ideal for applications on 8-bit systems, where it allowed efficient polyphonic music in environments with only three or four voice channels. The formal term "Music Macro Language" emerged around 1983 with and , developed in collaboration between and for the standard launched in 1983, which incorporated synthesis and aimed to unify software across manufacturers. Over time, evolved into variants used in video games and music trackers.

Origins and Early Development

Music Macro Language (MML) originated in as a text-based system for generating music on early personal computers, with its foundational commands first implemented in 1978 by on the MZ-80K model. This was integrated into the SP-1002 IOCS and SP-5001 operating systems, utilizing the for generation and featuring statements such as , , and to control , duration, and through ASCII data strings. The development of MML was influenced by earlier text-based music notation systems used in mainframe computing during the 1960s and 1970s, such as those in programs like MUSIC IV, which allowed composers to describe musical structures algorithmically, but adapted for the limitations of affordable home computing hardware lacking dedicated synthesizers. This shift addressed the need for simple, programmable music synthesis on resource-constrained 8-bit systems, enabling users to create chiptune-style audio without complex assembly code. Early adoption of occurred primarily among Japanese microcomputers, beginning with the standard launched in 1983, where it became a method for sound programming via the PLAY statement in , supporting polyphonic playback on the system's Programmable Sound Generator (). Key milestones in MML's initial spread included its integration into interpreters as early as 1978 on systems and by 1984 on platforms like the PC-8801, where it facilitated music creation alongside the system's PSG hardware; early documentation appeared in MZ-80K user manuals from 1978 and subsequent guides in the early 1980s, solidifying its role in hobbyist and game development. By the 1990s, MML began transitioning toward more advanced variants for emerging applications.

Core Syntax and Elements

Basic Note and Rhythm Notation

In Music Macro Language (MML), musical pitches are denoted using the letters A through G, typically in lowercase to distinguish them from commands, representing the notes of the from A to G. These letters can be modified with sharps (+) or flats (-) for chromatic alterations, such as c+ for or d- for D-flat. Octave shifts are managed explicitly with the 'o' command followed by a digit from 1 to 8, where o4 sets the octave containing middle C (C4); subsequent notes adopt this octave until changed, and relative adjustments use '>' to ascend or '<' to descend by one . For instance, the sequence o4 c d e plays C, D, and E in the fourth . Rhythm and duration are specified by appending a number after the note letter, which scales the length relative to a whole note (1); common values include 4 for a quarter note or 8 for an eighth note, with the default assuming quarter-note length if unspecified. The global default length can be set with 'l' followed by a number (e.g., l8 for eighth notes), applying to notes without explicit durations. Ties extend a note's duration using '&' to connect it to the next identical pitch, such as c4 & c4 equating to a half note. Dotted notes, indicated by '.', add half the note's value (e.g., c4. for a dotted quarter note), allowing for rhythmic variation without ties. Rests are notated with 'r' followed by an optional duration number, mirroring note syntax; for example, r4 inserts a quarter-note rest, and the default length follows the current 'l' setting. A basic sequence might read o4 l4 c d r e, producing quarter notes C and D, a quarter rest, and E in the fourth octave. Tempo is established at the sequence's start with 't' followed by a value in beats per minute (typically 30 to 255), such as t120 for 120 BPM, influencing the playback speed across all channels. Volume levels are set per channel or note using 'v' followed by an integer from 0 (silent) to 15 (maximum), for example v8 before a note to play at medium volume; this scales the amplitude in implementations supporting 4-bit volume resolution. While classical MML variants like the MSX BASIC PLAY command use uppercase equivalents (e.g., O for octave, T for tempo), modern chiptune applications standardize on lowercase for consistency.

Control and Modulation Commands

In Music Macro Language (MML), control commands manage the flow and structure of musical sequences, enabling composers to organize playback without redundant notation. Looping and repetition are fundamental, with square brackets enclosing a sequence followed by a repeat count, such as [CDE]4 to play the notes C, D, and E four times in succession. This construct supports nested loops up to 32 levels in implementations like , allowing complex patterns while optimizing code length for resource-constrained systems. Additionally, the L command designates a global loop point, returning playback to that position upon reaching the sequence end, which facilitates indefinite repetition in channels until interrupted. Modulation commands adjust pitch and timbre dynamically, with > and < shifting the up or down by one, respectively, for relative changes without specifying absolute values; for instance, >C raises C to the next octave. Vibrato and effects, often platform-specific, apply modulation to pitch or , such as using envelope shaping commands like 'E' in PMD to define parameters for SSG/PCM envelopes, or @MP in MCK for depth, speed, and delay. These commands enhance expressiveness in compositions by simulating analog-like variations on digital hardware. Channel and controls support multi-voice arrangements, where sequences for different tracks are separated by commas in a single string, such as CDE,EFG to assign the first to one and a to another. Gate length modulates note sustain, with Q followed by a value like Q4 setting a 50% gate for effects, cutting the note duration relative to its full length. End-of-sequence markers like ; terminate input strings, preventing parsing errors and allowing comments, ensuring clean termination in multi-channel notations. These features vary slightly across variants, such as MSX's emphasis on channels versus PMD's support.

Versions and Variants

Classical MML

Classical originated in 1978 as an integrated feature within the of the MZ-80 series computers, using the MUSIC statement to generate simple melodies through the system's speaker without dedicated audio hardware beyond the built-in sound capabilities. This early implementation marked one of the first standardized notations for algorithmic music in consumer hardware, tied closely to the era's limitations. The of classical was constrained by hardware, supporting mono output, limited note ranges (typically three ), and basic duration specifications. Notes were denoted by letters A-G, with # for sharps, R for rests, numbers 1-9 after notes for length (1 longest, 9 shortest), and octave shifts via '+' for higher or numbers for specific octaves. The statement set playback speed (e.g., 7), and strings were limited by available memory, often short to avoid overflow. Integration with allowed dynamic generation using variables, such as M, where M holds the , enabling loops or variations. Errors for invalid halted execution with diagnostic messages. A representative example of classical MML in Sharp MZ BASIC is:
300 TEMPO 7
310 MUSIC "DE#FGA"
This sets a moderate tempo and plays D, E, F#, G, A as default-length notes (quarter notes), demonstrating the concise notation for embedding music in programs. Such syntax laid foundational conventions for note and control symbols, influencing later variants despite its simplicity.

Modern MML

Modern MML emerged in the early 1980s with implementations in on Japanese personal computers, such as the NEC PC-6001 (1981) and systems (1983), adapting classical forms for more advanced home computers and consoles. This version expanded flexibility for compositions, supporting multi-channel playback for via the (PSG) in , without reliance on hardware-specific routines. The PLAY statement in processes MML strings, as in PLAY "CDE" for a basic scale on the primary channel, with enhanced commands for octaves (O), lengths (L), and tempo (T). Tools like SmileBASIC and PPMCK further this by defining sequences across tracks, e.g., :0 for and :1 for harmony. Key enhancements include control over parameters like envelopes and . In MCK for NES chiptunes, envelopes use @v0={10 9 8 7 6 3 2} for decaying . via [sequence]count enables structured pieces, and length limits are lifted; SmileBASIC allows 1 million characters, while MCK uses #BANK-CHANGE for extensions beyond 8K. In chiptune communities, syntax varies for 8-bit hardware, with Japanese scenes using MML for retro emulation (e.g., VRC6 for NES) and Western demoscene blending with trackers for chips like SID or 2A03. Tools like XPMCK compile for multiple targets including and 64. A representative multi-track example in SmileBASIC-style syntax: t120 :0 o4 C4 D4 E4 G4 :1 o3 G4 r4 <A4 r4 B4. Here, t120 sets tempo, :0 plays melody in octave 4, :1 provides bass in octave 3 with rests, synchronizing for harmony.

SMX and Other Extensions

Standard Musical eXpression (SMX) is a variant of modern MML used in Microsoft's QBASIC, BASICA, and GW-BASIC via the PLAY statement, for simple music on early IBM PC-compatibles. It supports note specification (e.g., C for middle C), length (L4 for quarter notes), octave (O3), and tempo (T120), but is limited to the PC speaker's square wave output. For instance, PLAY "O4 L4 C D E F G" plays an ascending scale. This syntax facilitated inline composition in BASIC programs. The Music Compiler Kit (MCK) extends for chiptunes, with macros for envelopes (@v for , e.g., @v0={15,12,10,8,6,3,2,1,0}) and timbres (@t for duty cycles on pulse s). uses channel D with @0 for mode (e.g., D l4 o1 @0 @v2 [b e]4 for percussion). Other extensions include libraries for microcontrollers, such as mml_parser in RTOS for embedded audio with basic support (notes, octaves O, T, V). For SNES, AddmusicK's variant uses @ prefixes for and instruments (e.g., @80 for with ADSR), enabling hardware modulation in sample synthesis.

Implementations and Applications

Historical Platforms and BASIC Integration

Music Macro Language (MML) found early adoption on several Japanese 8-bit personal computers in the 1980s, where it was integrated directly into the interpreters for straightforward music generation. The standard, launched in 1983, featured the General Instrument AY-3-8910 programmable sound generator (PSG) chip, which provided three channels of square wave synthesis along with noise and envelope capabilities. 's ROM-embedded PLAY command parsed MML strings at runtime, translating note durations, pitches, and control sequences into direct hardware register writes for the AY-3-8910, enabling real-time playback without additional software overhead. Similarly, the series, including the MZ-80K (1979) and MZ-700 (1983) models, incorporated support in their S-BASIC interpreters through the MUSIC command. This command accepted one or more string variables containing MML notation—such as note names (e.g., "C3"), durations, and rests (e.g., "R5")—and synthesized output via the system's built-in sound hardware, with tempo adjustable via the TEMPO command for speeds from 1 (slowest) to 7 (fastest). The MZ-700's documentation emphasized MML's role in simple music programming, allowing up to three simultaneous voices in examples like chord progressions. The NEC PC-88 and PC-98 series also embedded MML in their N88-BASIC dialects, utilizing the PLAY command to handle up to six channels across FM and SSG (square wave) synthesis. Strings passed to PLAY followed MML syntax for pitches (e.g., "Cx" for note C in octave x), lengths (e.g., "Lx" for duration), and octaves (e.g., "Ox"), with modes for musical playback (#0), sound effects (#1), or chorus sampling modulation (#2). This runtime parsing interfaced directly with the PC-88's FM synthesis hardware, such as the YM2203 chip, supporting polyphony limited to three SSG channels in base configurations. On these platforms, powered music in user demos, educational programs, and early commercial , with three-channel constraints typical of the era. Limitations like fixed 3-voice output and lack of advanced effects encouraged creative shifts and within MML commands. By the early 1990s, MML's prominence waned as developers shifted to custom assembly-based sound drivers for enhanced control over evolving hardware, such as expanded channels and wave tables.

Modern Software and Game Engines

In the , Music Macro Language (MML) has found renewed application in various software tools designed for music composition and playback, particularly within and communities. NASequencer, a text-based MIDI sequencer for macOS developed by Keijiro Takahashi, supports as its primary input format, allowing users to compose multi-track sequences that are compiled into for playback and export. Released in the 2010s, it emphasizes rapid prototyping and file management through plain-text MML scripts, integrating with digital audio workstations for further editing. Similarly, SmileBASIC, a programming environment for the launched in 2014 by SmileBoom, incorporates MML via its BGMPLAY and BGMSET commands, enabling users to script directly in code for games and applications. This implementation, denoted as MML@ , supports note durations, octaves, and effects, facilitating procedural audio in user-created programs on the handheld platform. For embedded systems, the mml_parser library, integrated into the in recent versions, provides a lightweight MML interpreter for resource-constrained devices, parsing strings into note events for audio output via FM synthesis or other drivers. MML's utility extends to modern game engines and production, where it aids in retro-style audio design for homebrew and indie projects. In SNES homebrew development, drivers like those documented in the MML Guide support MML compilation for the console's SPC-700 , enabling composers to generate compact binary sequences for custom games with features such as multi-channel and integration. For instance, Shaw02's driver, popular among developers since the , optimizes MML for space-efficient playback in fan-made titles. trackers like FamiTracker, while primarily using a graphical for NES music, have community extensions and converters that import or export MML-compatible formats, bridging tracker workflows with text-based scripting for NSF file generation. Indie games and MMORPGs, such as Mabinogi (developed by since 2004), leverage MML for player-composed music, where users input sequences to drive in-game instruments, fostering -driven soundtracks. Contemporary applications of MML highlight its role in niche creative scenes and emerging technologies. In the demoscene, MML compilers like mck have been adopted since the early for compositions in demos, allowing programmatic generation within size-limited executables that run on modern hardware emulating retro systems. and procedural tools, including iOS apps like rlib-MML (released in 2021 by Thinkridge), parse MML for real-time playback on touch devices, supporting algorithmic variations for dynamic soundscapes in apps and games. Open-source parsers, such as the NuttX mml_parser and the npm-based mml-parser on (developed by Mao Shizhong in the 2020s), enable real-time synthesis by converting MML to event streams compatible with Web Audio API or embedded audio pipelines, powering interactive installations and browser-based tools. These modern implementations underscore MML's advantages in the chiptune revival, where its text-based nature ensures compatibility with retro emulators and synthesis engines, while facilitating in collaborative projects via standard tools like . This format's simplicity promotes accessibility for , contrasting with binary-heavy alternatives and sustaining its use in hobbyist and professional audio design.

References

  1. [1]
    Music Macro Language - NASequencer
    Music Macro Language (MML) is a music description language that was invented in the early days of computer music for sequencing by text descriptions.
  2. [2]
    Micro-Music (EMM Mar 81) - mu:zines
    Let us examine the musical commands available from the Sharp Basic in detail. Seven tempos can be assigned from very slow to fast using Tempos 1-7. Notes are ...
  3. [3]
    [PDF] Microsoft® GW-BASIC® Interpreter - Bitsavers.org
    Reading, Mass.: Addison-Wesley Publishing Co., 1978. Ettlin, Walter A. and ... To play music by embedding a music macro language into the string data ...<|control11|><|separator|>
  4. [4]
    Introduction - pedipanol's guide to MML
    MML, standing for Music Macro Language, was introduced to the general public as the internal music driver in Microsoft BASIC for japanese personal computers in ...
  5. [5]
    Chipmusic > MML (Music Macro Language) - Woolyss
    MML (Music Macro Language) is a music description language used in sequencing music on a number of computer and video game system platforms.
  6. [6]
    Macrotune by PoseMotion - itch.io
    Rating 4.9 (8) Macrotune is a Music Macro Language (MML) editor. Easily create retro style music for an app, game or just for fun!
  7. [7]
    Category:MSX-BASIC Instructions - MSX Wiki
    Aug 28, 2025 · PLAY, MSX1, Executes Music Macro Language (MML) instructions to play notes on PSG channel(s) This instruction is extended by MSX-AUDIO BASIC ...
  8. [8]
    Music Macro Language | Electronic Music Wiki | Fandom
    The Intel 8253 Mode 3 Square Wave generator was used for music, in the Kit computer MZ-40K() by SHARP Corporation, made in Japan in May 1978. Another Micro ...
  9. [9]
  10. [10]
    Computer music | Electronic Music Wiki | Fandom
    The field of computer music can trace its roots back to the origins of electronic music, and the very first experiments and innovations with electronic ...
  11. [11]
    PLAY - MSX Wiki
    Feb 14, 2025 · Executes the instructions of a Music Macro Language (MML) allowing to play notes on one or several PSG channels (and optionally on MSX-AUDIO/PCM, MSX-MUSIC or ...Missing: 1983 | Show results with:1983
  12. [12]
    The Basic Sequence - pedipanol's guide to MML - Read the Docs
    All notes must be typed in lowercase as to, for example, not be treated as a command that may use the capital letter. Note lengths are specified by a number ...
  13. [13]
    MCK/MML Beginners Guide - NesDev.org
    In MML notation this is saying, for channels A, B, C, D, and E set the tempo to 150 beats per minute. The valid range of values for tempo is 1 to 255.
  14. [14]
    PMDMML_EN.MAN
    Summary of each segment:
  15. [15]
    Cassette Data File Input/Output Statements - Sharp MZ-80A Owner's ...
    Sharp MZ-80A Manual Online: music control statements, Graphic Control Statements, Cassette Data File Input/Output Statements. Music The Music Statement ...
  16. [16]
    reference:about_mml [SmileBASIC 4]
    ・The maximum length of MML is 1 million characters. Pitch. Basic Pitch. Any one character of CDEFGAB represents the pitch of tone chromatic scale. Sharp, Flat.
  17. [17]
    What is the releation between demoscene, chiptune and VGM scene
    Apr 6, 2022 · I found there are so many different. for example MML (Music Macro Language) is much more popular in Japan and Trackers are much more popular in ...
  18. [18]
    8. Chip music as hacker culture | Introduction to Demoscene - GitBook
    Dec 15, 2022 · As we have already mentioned in the previous lesson, for game developers in the 80s, modifying the program code directly or using MML (Music ...
  19. [19]
    Microsoft BASIC MML - ModdingWiki - shikadi.net
    Sep 3, 2022 · Microsoft BASIC MML is a Music Macro Language developed by Microsoft for their version of the BASIC computer language.Missing: SMX syntax
  20. [20]
    mml_parser Music Macro Language (MML) Parser library
    MML has often been used as a language for describing music in strings, for example, in the BASIC language. The mml_parser is a minimalistic Music Macro Language ...Missing: origins 1983-1984 Japanese developers<|control11|><|separator|>
  21. [21]
    AddmusicK - MML Compiler-Inserter for Super Mario World - GitHub
    Run AMK from anywhere as long as it is available in $PATH · Conditional compilation for both sound driver and music data · Makefile / Ruby script for inserting ...
  22. [22]
    General Instrument AY-3-8910 - MSX Wiki
    Apr 26, 2025 · The AY-3-8910 is a 3-voice programmable sound generator (PSG) designed by General Instrument in 1978. It's the original chip that has been ...
  23. [23]
    [PDF] SHARP MZ-700 Disk Basic MZ-2Z009
    The manual provides a general explanation of the use and programming of the DISK. BASIC system software for the personal computer. This system software is ...
  24. [24]
    N88-BASIC(86) PLAY命令 - radioc.dat - FC2
    〈文字列1~6〉で指定するMML(ミュージックマクロランゲージ)の指示に従って,音楽を演奏します. 〈文字列1~3〉はチャンネル1~3に対応するFM音源,〈文字列4~6〉はチャンネル4 ...
  25. [25]
    Konami Vampire Killer SCC version - msx.org
    Jan 14, 2018 · The new SCC music has been written in a MML-style language (see mml/vkiller_scc.mml) and then compiled into the Konami music format andKonami SCC Games Sound Enhancement - MSX.ORGSimple way to play sound effects on MSX PSGMore results from www.msx.org
  26. [26]
    Operation Manual - NASequencer
    Operation Manual. NASequencer is a text-based MIDI composer for OS X, which focuses on quick composing and easy management.
  27. [27]
    Instruction List - SmileBasic
    - Pressing the Help button for "MML" will display descriptions of MML commands ... - Channel specification within the defined MML is not allowed - For label ...Graphics · Sprites · Bg
  28. [28]
    List of MML Music Drivers
    A sound driver for the SNES by undisbeliever, has its own GUI editor that allows for instant playback. Syntax is based on PMD, so a lot of non-FM specific ...English Documented · Terrific Audio Driver (SNES) · Non-translatedMissing: 'n' | Show results with:'n'
  29. [29]
    MML? - FamiTracker
    Nov 28, 2011 · Hey guys. I've been rather interested lately in the creation of NSFs with MML files. It seems like a much harder way to create music than ...ppmck, mml and me. - FamiTrackerFamiTrackerMore results from famitracker.com
  30. [30]
    MMORPG & MMO Games With Player-Made Music Composition ...
    MMOs with player-made music composition & instruments are massively multiplayer online games that allow players to create their own music by means of MML ...
  31. [31]
    9. "New generation" chip music scene | Introduction to Demoscene
    Dec 15, 2022 · That's not what chiptune is about, but we are getting a ton of people from that community, thanks to Chiptunes=Win and DJ Cutman, who came from ...
  32. [32]
    rlib-MML アプリ - App Store - Apple
    Download rlib-MML アプリ by Thinkridge Co., Ltd. on the App Store. See screenshots, ratings and reviews, user tips and more games like rlib-MML アプリ.<|control11|><|separator|>
  33. [33]
    mao-sz/mml-parser: Modern MML (Music Macro Language ... - GitHub
    A Modern MML parser that converts a string containing Modern MML to an array of objects for each note/rest. Install. npm install mml-parser ...
  34. [34]
    Modernizing MML for 2022 (1) Overture - music to your ears
    Dec 15, 2021 · MML is a classic language and no one uses in "modern" production (at least beyond prototypes), but I believe that whether to use MML or not ...Missing: mainframe | Show results with:mainframe