日本語English

SMF Conversion Tool (Smf2GoFMML)

A standalone command-line tool that reads a Standard MIDI File (SMF) and converts it into a go-fmml .mml file.

Overview

Smf2GoFMML is a standalone command-line app under tools/smf2gofmml, separate from go-fmml's core (the FM/PCM synthesis engine and MML playback). It reads a Standard MIDI File (assumed to be Format 1), parses each track's notes, tempo, and track name, and writes out a .mml text file following go-fmml's own MML spec. It doesn't need go-fmml's audio engine (oto/v3 etc.) at all - it only performs the file conversion.

Treat the output as a starting draft, not a finished song. Anything an SMF file has no way of expressing - voice IDs, mute, reverb sends, loop settings, a conductor part, and so on - is filled in with fixed default values, so the expected workflow is to hand-edit the resulting .mml afterward, referring to the MML File Structure and MML Command Reference pages, and pair it with voice files you author separately.

Building

From the repository's tools/smf2gofmml directory, build the executable straight into the cmd subfolder (the tool resolves its input/output folders relative to its own executable's location, so this placement matters).

cd tools/smf2gofmml
go build -o cmd/Smf2GoFMML.exe .

Usage

Next to the built executable (cmd/Smf2GoFMML.exe) live an input smf folder and an output convert folder (created automatically if missing).

# Run from inside the cmd folder
cd tools/smf2gofmml/cmd

# A bare file name is looked up under the sibling smf folder
Smf2GoFMML.exe bgm1.mid          # resolves to ./smf/bgm1.mid

# An absolute path is read as-is
Smf2GoFMML.exe C:\path\to\bgm1.mid
ItemDetails
ArgumentThe path to the SMF file to convert - either a full path, or a bare file name resolved against the smf folder next to the executable.
Output locationThe convert folder next to the executable (created automatically if it doesn't exist).
Output file name<song name>.mml. The song name comes from the SMF's sequence/track-name meta event (characters invalid in a Windows file name are replaced with _; falls back to untitled if none is found).
On errorPrints the reason to the console and exits (e.g. the file can't be read, the SMF itself is malformed, or no track contains any note data).
On warningConversion continues; details are printed to the console prefixed with warning: (e.g. a track skipped for exceeding a part-count limit).

Track-name tags

Prefixing a track's name (its sequence/track-name meta event) with one of the following tags controls what kind of part it converts into.

TagConverts to
[FM]An FM voice part ([partN])
[PCM long]A PCM voice part, long type ([pcmPartX], partType: long)
[PCM oneShot]A PCM voice part, oneShot type ([pcmPartX], partType: oneShot)
No tagTreated as an FM voice part (the default)
Tag matching is case-insensitive, and whitespace anywhere inside the brackets (e.g. [PCM oneShot ] or [ PCM oneShot ]) is ignored - a bit of inconsistency from hand-typed track names is tolerated. The words themselves still need to match (PCM / long / oneShot). The remainder of the track name (tag stripped) is automatically written as a comment (#) directly above that part's settings entry and body section in the output .mml.
# Example track names
[FM]Lead
[PCM long]Strings
[PCM oneShot]Drums
Bass                # no tag -> treated as an FM voice part

What gets converted

The [global] section

FieldHow it's derived
tempoThe first tempo meta event found anywhere in the SMF (decimal part dropped). Defaults to 120 if none is found.
sequenceIDThe first track name (sequence name) found in the SMF, with any double-quote characters stripped. Defaults to untitled if none is found.
loopAlways false (fixed default).
volumeAlways 100 (fixed default).
reverbAlways false (fixed default).
reverbTypeAlways normal (fixed default).
reverbTimeAlways 2.0 (fixed default).
reverbLevelAlways 100 (fixed default).

Part assignment

Part volume and pan

Notes → MML commands (FM / PCM long)

Notes → MML commands (PCM oneShot)

Caveats

The output is a draft, not a finished product. Anything an SMF has no way to express - voice IDs, mute, solo, transpose, reverb send, a conductor part, loop settings - is written with fixed default values, never actually converted. Turning it into a real song requires hand-editing the resulting .mml against the MML File Structure page, and pairing it with voice files you author using the FM Voice Parameters / PCM Voice Parameters specs.