← ブログ一覧

Making a synthesiser sing with MML — reading the notation, writing a short tune

MML is an old notation that writes notes as characters, and it still works as input for singing synthesis. Starting from cdefgab, through note lengths, octaves and tempo, with examples you can play.

株式会社KOOFFICE3 min read#MML#使い方

MML — Music Macro Language — writes notes as a run of characters. Do-re-mi is c d e f g a b, and symbols are added for length and pitch.

It began as a way to hand tunes to sound chips, and was widespread on home computers and consoles through the 1980s. It is still handy wherever you want to pass a melody as text. Comeyomi uses it to make the speech synthesiser sing.

A short tune fits in a few dozen characters. Knowing how to read it carries over to other MML-capable tools.

The shortest example

cdefgab

That plays do-re-mi-fa-so-la-ti. No length is given, so every note takes the default — a quarter note.

Lyrics follow the notes:

cdefgab doremifasolati

Notes and lyric characters pair up one to one. Matching the counts gets you what you intended.

Length

A number after a note sets its length, as the number of divisions of a whole note.

WrittenLength
c4Quarter note
c8Eighth note
c2Half note
c1Whole note
c16Sixteenth note

Bigger numbers mean shorter notes. Reading it as a denominator makes it stick.

A period after the length dots the note, making it one and a half times as long:

c4.

Writing that every time gets tiresome, so l sets the default:

l8 cdefgab

From there, notes without a number are eighth notes.

Pitch

> goes up an octave and < goes down.

cde>cde<cde

o with a number sets the octave outright. o4 is the baseline.

o5 cde

Semitones use + (or #) and -:

c+ d- e

c+ is C sharp, d- is D flat.

Rests and tempo

r is a rest, and takes a length like a note:

c4 r4 e4 r4 g4

t sets the tempo in BPM:

t150 cdefgab

The default is 120. Larger numbers are faster.

Putting it together

The opening of Twinkle Twinkle Little Star:

ccggaag2 twinkle

c c g g a a are quarter notes and the closing g2 is a half note.

Slowing it down:

t100 ccggaag2 twinkle

Using it in Comeyomi

From the web chat, !sing followed by MML and lyrics:

!sing cdefgab doremifasolati

The limits:

  • MML up to 200 characters
  • Songs up to 60 seconds
  • Once per 15 seconds, shared across everyone in the Space

Past 60 seconds, use fewer notes or raise the tempo with t.

To choose a singer, put the number first:

!sing 3003 cdefgab aiueo

Numbers come from !singers. Reading voices and singing voices are separate lists, so a number from !speakers will not give you the voice you expect.

The synthesiser is Japanese, so lyrics in Japanese sit far better than lyrics in English, which come out with Japanese phonetics.

Writing tips

Match the note count to the lyric length. When they drift, syllables land on the wrong notes. Play the notes alone first to check the melody, then add lyrics.

Work in small pieces. Two hundred characters is a lot to debug at once. Four bars at a time finishes faster.

Contracted syllables are counted inconsistently. Whether something like "kya" counts as one or two depends on the tool. If it does not line up, add or remove a note.

Length settings persist. After l8 everything stays an eighth note until you say otherwise with another l.

The notation, in one table

SymbolMeaning
c d e f g a bNotes
rRest
+ or #Sharp
-Flat
digits after a noteLength (4 is a quarter note)
.Dotted — one and a half times
> <Octave up, octave down
o + digitsSet the octave
l + digitsSet the default length
t + digitsSet the tempo

That is enough for most short melodies.


The full list of commands is in the command reference.

More posts