Skip to content

transcriptaze/midiasm

Repository files navigation

build

midiasm

MIDI assembler/disassembler to convert between standard MIDI files and a text/JSON equivalent.

Raison d'être

A Go reimplementation of Jeff Glatt's long defunct Windows-only MIDIASM (last seen archived at MIDI Technical Fanatic's Brainwashing Center). Because sometimes it's easier to just programmatically deal with text or JSON.

Installation

Executables for all the supported operating systems are packaged in the releases. Installation is straightforward - download the archive and extract it to a directory of your choice.

midiasm help will list the available commands and associated options (documented below).

Building from source

Required tools:

  • Go 1.23+
  • make (optional but recommended)

To build using the included Makefile:

git clone https://github.com/transcriptaze/midiasm.git
cd midiasm
make build

Without using make:

git clone https://github.com/transcriptaze/midiasm.git
cd midiasm
go build -trimpath -o bin/ ./...

The above commands build the midiasm executable to the bin directory.

Dependencies

None

midiasm

Usage: midiasm <command> <options>

Supported commands:

Defaults to disassemble if the command is not provided.

disassemble

Disassembles a MIDI file and displays the tracks in a human readable format.

Command line:

midiasm [--debug] [--verbose] [--C4] [--split] [--out <file>] <MIDI file>

  --out <file>  Writes the disassembly to a file. Default is to write to stdout.
  --split       Writes each track to a separate file. Default is `false`.

  Options:

  --C4       Uses C4 as middle C (Yamaha convention). Defaults to C3.
  --debug    Displays internal information while processing a MIDI file. Defaults to false
  --verbose  Enables 'verbose' logging. Defaults to false

  Example:

  midiasm --debug --verbose --out one-time.txt one-time.mid

assemble

Assembles a MIDI file from a text or JSON source.

Command line:

midiasm assemble [--debug] [--verbose] [--C4] [--out <MIDI file>] <file>

  --out <file>  Output MIDI file. Defaults to the input file with a .midi extension.

  Options:

  --C4       Uses C4 as middle C (Yamaha convention). Defaults to C3.
  --debug    Displays internal information while processing a MIDI file. Defaults to false
  --verbose  Enables 'verbose' logging. Defaults to false

  Example:

  midiasm assemble --debug --verbose --out one-time.mid one-time.json

export

Extracts the MIDI information as JSON for use with other tools (e.g. jq).

Command line:

midiasm export [--debug] [--verbose] [--C4] [--out <file>] <MIDI file>

  --out <file>     Writes the JSON to a file. Default is to write to stdout.
  --json           Formats the output as JSON - the default is human readable text.
  --transpose <N>  Transposes the notes up or down by N semitones.

  Options:

  --C4       Uses C4 as middle C (Yamaha convention). Defaults to C3.
  --debug    Displays internal information while processing a MIDI file. Defaults to false
  --verbose  Enables 'verbose' logging. Defaults to false

  Example:

  midiasm notes --debug --verbose --out one-time.json one-time.mid

notes

Extracts the NoteOn and NoteOff events to generate a list of notes with start times and durations.

Command line:

midiasm notes [--debug] [--verbose] [--C4] [--out <file>] <MIDI file>

  --out <file>  Writes the notes to a file. Default is to write to stdout.

  Options:

  --C4       Uses C4 as middle C (Yamaha convention). Defaults to C3.
  --debug    Displays internal information while processing a MIDI file. Defaults to false
  --verbose  Enables 'verbose' logging. Defaults to false

  Example:

  midiasm notes --debug --verbose --out one-time.notes one-time.mid

click

Extracts the beats from the MIDI file in a format that can be used to create a click track.

Command line:

midiasm click [--debug] [--verbose] [--C4] [--out <file>] <MIDI file>

  --out <file>  Writes the click track to a file. Default is to write to stdout.

  Options:

  --C4       Uses C4 as middle C (Yamaha convention). Defaults to C3.
  --debug    Displays internal information while processing a MIDI file. Defaults to false
  --verbose  Enables 'verbose' logging. Defaults to false

  Example:
  
  midiasm click --debug --verbose --out one-time.click one-time.mid

transpose

Transposes the key of the notes (and key signature) and writes it back as MIDI file.

Command line:

midiasm transpose [--debug] [--verbose] [--C4] --semitones <steps> --out <file> <MIDI file>

  --semitones <N>  Number of semitones to transpose up or down. Defaults to 0.
  --out <file>     (required) Destination file for the transposed MIDI. 

  Options:

  --C4       Uses C4 as middle C (Yamaha convention). Defaults to C3.
  --debug    Displays internal information while processing a MIDI file. Defaults to false
  --verbose  Enables 'verbose' logging. Defaults to false

  Example:
  
  midiasm transpose --debug --verbose --semitones +5 --out one-time+5.mid one-time.mid

tsv

Extracts the MIDI information as a TSV or fixed width file for use with other tools (e.g. miller)

Command line:

midiasm tsv [--debug] [--verbose] [--C4] [--out <file>] <MIDI file>

  --out <file>   Output filepath. Default is to write to stdout.
  --delimiter    Column delimiter for TSV files. Defaults to TAB.
  --tabular      Formats the outputs as fixed width columns

  Options:

  --C4       Uses C4 as middle C (Yamaha convention). Defaults to C3.
  --debug    Displays internal information while processing a MIDI file. Defaults to false
  --verbose  Enables 'verbose' logging. Defaults to false

  Example:

  midiasm tsv --debug --verbose --out one-time.tsv one-time.mid

Tools

  1. jq
  2. miller

References

  1. The Complete MIDI 1.0 Detailed Specification
  2. Somascape - MIDI Files Specification
  3. (archive) MIDI Technical Fanatic's Brainwashing Center
  4. StackExchange::Music Transposing key signatures - how to do so quickly?
  5. An Introduction to MIDI
  6. Roland: Midi Guidebook
  7. Timing in MIDI files

Alternatives

  1. mido
  2. midicsv
  3. Werkmeister
  4. pymidi
  5. DryWetMIDI
  6. Online MIDI Editor
  7. go-midi
  8. midiutil
  9. music21
  10. fq

About

MIDI assembler/disassembler

Resources

License

Stars

Watchers

Forks

Packages

No packages published