Pitches

In MML, notes and rests are represented by alphabetic letters. As shown below, notes on the C major scale are represented by c, d, e, f, g, a, b, and rests are represented by r.

cdefgabr

Uppercase letters can also be used for notes and rests, and their meaning is the same as lowercase letters.

A sharp is represented by + or # (both meaning the same) and a flat is represented by - or b (both meaning the same). Up to two of these can be specified after a note. The lowercase b letter only signifies a flat (or double flat if two are used) when placed immediately after a capital-letter note. Otherwise, it is interpreted as a note representing the B note.

accidentals

Unlike sheet music, there is no rule that sharps or flats apply to every subsequent note of the same pitch until the end of the measure. In such cases, each individual note must be marked with sharps or flats.

Space, tab, and newline characters can be freely inserted between notes and rests. For example, they can be inserted at bar boundaries to improve readability. Additionally, any text from a semicolon (;) to the end of the line is treated as a comment.

While Pytakt MML offers flexibility regarding uppercase/lowercase letters, sharp/flat symbols, and spaces, to avoid confusion (especially regarding the double meaning of b), we recommend conforming to one of the following two styles.

       Example phrase accidentals

ceff+ gb-gr
C E F F#  G Bb G r

Style 1 focuses on ease of typing and compactness, making it suitable for writing small pieces or embedding MML within Python programs. Style 2 prioritizes readability, offering advantages particularly when adding expression instructions like velocity. For storing MML in files to describe large pieces, Style 2 is recommended.

Specifying octaves

To raise the octave of a note, place a ^ before the note. Conversely, to lower the octave, place an _ before it. Adding multiple of these characters allows shifting by two or more octaves. (While suffixing ' or , as employed in LilyPond is also available, it is not used in this tutorial.)

specifying octaves

To raise or lower the octave for a group of notes, enclose the notes in { and }, and place ^ or _ before the group.

cdefgab^{cdefgab^cbagfedc}bagfedc

specifying octaves with braces

The base octave (the octave when no ^ or _ is present on a note) is initially set to 4 (meaning the octave starting from the middle C), but can be changed later. While the ^{ and } shown above also cause an implicit change of the base octave inside the group, it is also possible to specify it explicitly. For example, o=3 changes the base octave to 3, and o+=1 increases the base octave by 1, although excessive use of these is not recommended as they can blur the octave of each note.

o=3 gab^c o+=1 defg

specifying octaves with assignments

Additionally, you can directly specify the octave of each note by suffixing an octave number as below (place it after sharps or flats if they present). The pitch of a note specified in this manner is never affected by ^, _, or the base octave.

C4 C5 G3 C#2 Bbb3

Specify the key to automatically add sharps and flats

While this feature is not highly recommended as it can make the MML difficult to read, you can specify the key signature to automatically add sharps and flats. For example, for a piece in D-flat major, the following notation is possible:

key=-5  A G% A ^C B Abb Abb Ab

specifying keys

where the number after key= indicates the number of sharps or flats (a negative number for flats) contained in the key signature, and % represents a natural. The Ab at the end can also be written as A. The equivalent notation without using key is as follows:

Ab G Ab ^C Bb Abb Abb Ab


Last update: Jan 30 2026 18:49 JST     Copyright (C) 2026 Satoshi Nishimura Top Page