Language for algorithmic generation of MIDI files

Latest on Hackage:1.0.2

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

GPL-3 licensed and maintained by Mark Karpov


License GPL 3 Hackage Build Status

MIDA is a minimalistic declarative language for algorithmic generation of MIDI files. MIDA is not interactive in sense that you cannot control result of its activity in real time, it is intended for producers and should be used with a DAW. MIDA can help you create variative elements in your music in a very simple way. Since MIDI can control a lot of different instruments, power of MIDA is truly great.

Main reason for MIDA development is to create software tool that can be used in such a way that does not change established workflow, so people could use familiar plugins and software instruments.

Currently MIDA can be used to translate source files into .mid files, and also in interactive mode that will help you to understand how MIDA language works.

MIDA is a member of Linux Audio consortium.


  1. Install the Haskell Tool Stack.

  2. Add ~/.local/bin directory to your PATH, like this:

    # in .bashrc or similar
    export PATH=$HOME/.local/bin:$PATH
  3. Clone the repo, cd into it, and let stack do its thing:

    $ git clone
    $ cd mida
    $ stack build --copy-bins
  4. Check it out:

    $ mida --version
    MIDA 1.0.0


Here is a simple example of MIDA program that demonstrates syntax and declarative nature of the language.

# Example of MIDA program
# Tempo ≈ 50

dur0   = 6
dur1   = dur0
dur2   = dur0
dur3   = {96 $ 2, 24}
pch0   = c5 {e5 d5 [a5 a5]} $ 2, g5
pch1   = pch0
pch2   = {c2 c3}
pch3   = {c6 d6 e6 f6 g6 a6 b6 c7 e7}
quiet  = {40..80}
normal = quiet + 30
vel0   = quiet
vel1   = quiet
vel2   = 0, normal $ 2, 0
vel3   = normal

See MIDA Manual for more information.

How to control other things?

If you’re into this sort of thing, you may like my another project, called ALGA. It allows to control automation natively in various DAWs.


Copyright © 2014–2016 Mark Karpov

Distributed under GNU GPL, version 3.


MIDA 1.0.2

  • Refactoring, switch to Hspec for testing and Megaparsec 5.

MIDA 1.0.1

  • Fixed issues with directory package. Please use directory- or newer. stack.yaml file is updated accordingly, if you clone the repository.

MIDA 1.0.0

  • Use the path-io library.

  • Use YAML files for configuration.

  • Cosmetic changes in the interface.

MIDA 0.4.6

  • Support for Stack and other maintenance stuff;

  • Refactoring, more type-safe code and better libraries used.

MIDA 0.4.5

  • Various cosmetic changes;

  • Make the executable Cabal-installable.

MIDA 0.4.4

  • Cosmetic corrections in source code;

  • Switch to better libraries.

MIDA 0.4.3

  • Various corrections and cosmetic changes;

  • Improved printing of syntax trees;

  • Allow more flexible looping expressions.

MIDA 0.4.2

  • Introduced simplifications on the level of internal language;

  • Changed default values of some parameters;

  • Some characters have been replaced with pretty Unicode symbols;

  • Improved manual.

MIDA 0.4.1

  • Dramatically improved efficiency, now very long compositions can be quickly rendered;

  • Lexer: changed style of comments, shell-like comments adopted;

  • Changed alias of notes: dièse is written now as s not as #, so middle octave is: c5, cs5, d5, ds5, e5, etc.;

  • Now there are alias for all supported (in MIDI) pitches from 0 to 127, that is: from c0 to g10 (alias c10g10 added);

  • Changed alias of modulation signs, reason for such change is purely technical – all alias now are predefined definitions, rather than syntactic sugar, so all alias must be valid identifiers;

  • Identifiers can contain underline sign (_);

  • Arbitrary number of files can be specified for loading (from command line, as well as from interactive REPL);

  • Many purely technical changes that are difficult to explain concisely, but they should be mentioned, most important being addition of test suite and ability to generate source files from syntax trees;

  • Added command line options: --license and --version.

MIDA 0.4.0

  • Fixed bug in batch mode;

  • Added tab completion based on contents of current input line, including completion of file names for some commands;

  • Detection and rejection of recursive definitions;

  • Improved interface;

  • Wholly refactored (and sometimes rewritten) code (it’s finally sufficiently elegant);

  • More intuitive logic of evaluation in some corner cases;

  • Optional displaying of simplified principles (for debug and educational purposes);

  • Ability to set tempo and program for preview;

  • Improved documentation.

MIDA 0.3.0

  • Improved interface and parsing;

  • Added :prv and :load special commands;

  • Added additional parameters: modulation, breath, aftertouch, and pitch bend;

  • Fixed minor bugs.

MIDA 0.2.0

  • Better command line experience: history, auto-completion and more;

  • Fixed bug with infinite translation of scores that consist of elements which have zero duration;

  • Introduced conception of sections;

  • All operations have become fully polymorphic.

MIDA 0.1.0

  • Initial release.
comments powered byDisqus