← Back to context

Comment by dghf

6 days ago

Similar things:

* Perl MIDI::Score -- https://metacpan.org/pod/MIDI::Score

* Csound standard numeric scores -- https://csound.com/docs/manual/ScoreTop.html

* CsBeats (alternative score language for Csound) -- https://csound.com/docs/manual/CsBeats.html

Lilypond, too. Though it needs a full scheme interpreter to evaluate macros (provided by both the system and the user), it can emit midi files.

  • Lilypond isn't well-known enough!

    https://en.wikipedia.org/wiki/LilyPond#Integration_into_Medi...

    https://www.mutopiaproject.org

    https://lilypond.org/text-input.html

         \relative c' { 
            \key d
            \major
            fis4 fis g a
            a g fis e
            d d e fis
            fis4. e8 e2
         }
    

    ...but why is it so complicated? A novice interpretation of "music" is "a bunch of notes!" ... my amateur interpretation of "music" is "layers of notes".

    You can either spam 100 notes in a row, or you effectively end up with:

        melody   = [ a, b, [c+d], e, ... ]
        bassline = [ b, _, b,     _, ... ]
        music = melody + bassline
        score = [
           "a bunch of helper text",
           + melody,
           + bassline,
           + page_size, etc...
        ]
    

    ...so Lilypond basically made "Tex4Music", and the format serves a few dual purposes:

    Engraving! Basically "typesetting" the music for human eyeballs (ie: `*.ly` => `*.pdf`).

    Rendering! Basically "playing" the music for human ears (ie: `*.ly` => `*.mid`)

    Librarification! Basically, if your music format has "variables" and "for-loops", you can end up with an end score that's something like: `song = [ intro + chorus + bridge + chorus + outro ]`, and then not have to chase down and modify all the places you use `chorus` when you modify it. (See this answer for more precision: https://music.stackexchange.com/a/130894 )

    ...now imagine doing all of the above for multiple instruments and parceling out `guitar.pdf`, `bass.pdf`, `drums.pdf` and `whole-song.pdf`

    TL;DR: Music is haaard, and a lot closer to programming than you think!

    • Lilypond is the only music engraving system I'm aware of that can handle polytempo scores. The TEX-ness really comes in handy.