I saw a recent notation software product that seemed to offer a novel and concise way to code your music notation. I can't find it so I'm reaching out for your help.
6 Answers
There is LilyPond which does what you are looking for. It was first released in 1996, but it still gets updates.
LilyPond is a computer program and file format for music engraving. One of LilyPond's major goals is to produce scores that are engraved with traditional layout rules, reflecting the era when scores were engraved by hand.
LilyPond is cross-platform, and is available for several common operating systems; released under the terms of the GNU General Public License, LilyPond is free software.
For example:
\version "2.18.2" \header { title = "Speed the Plough" composer = "Trad." } \score { \new Staff { \clef "treble" \key g \major \time 4/4 \numericTimeSignature \repeat volta 2 { g'8 a' b' c'' d'' e'' d'' b' | d''8 e'' d'' b' d'' e'' d'' b' | c''4 e''8 c'' b'4 d''8 b' | c''4 a'4 a' b'8 a' | \break g'8 a' b' c'' d'' e'' d'' b' | d''8 e'' d'' b' d'' e'' d'' b' | c''4 e''8 c'' b'4 d''8 b' | a'4 fis' g'2 | } \break \repeat volta 2 { g''4 g''8 fis'' g''8 d'' b' d'' | g''4 fis'' e'' d'' | c''4 e''8 c'' b'4 d''8 b' | c''4 a'4 a' d''8 fis'' | \break g''4 g''8 fis'' g''4 b'8 d'' | g''4 fis'' e'' d'' | c''4 e''8 c'' b'4 d''8 b' | a'4 fis' g'2 | } } }
On the Wiki page, there are more nice examples with some code and the output.
We have had many questions tagged lilypond in this site, so you can look through these to get a general idea.
There is also ABC Notation, which is text-based notation (not exactly coding), like:
X:1 T:Speed the Plough M:4/4 C:Trad. K:G |:GABc dedB|dedB dedB|c2ec B2dB|c2A2 A2BA| GABc dedB|dedB dedB|c2ec B2dB|A2F2 G4:| |:g2gf gdBd|g2f2 e2d2|c2ec B2dB|c2A2 A2df| g2gf g2Bd|g2f2 e2d2|c2ec B2dB|A2F2 G4:|
and gives you the result:
X:1
T:Speed the Plough
M:4/4
C:Trad.
K:G
|:GABc dedB|dedB dedB|c2ec B2dB|c2A2 A2BA|
GABc dedB|dedB dedB|c2ec B2dB|A2F2 G4:|
|:g2gf gdBd|g2f2 e2d2|c2ec B2dB|c2A2 A2df|
g2gf g2Bd|g2f2 e2d2|c2ec B2dB|A2F2 G4:|
I have not personally used any of them yet, but there are multiple packages for typesetting music with LaTeX.
-
8I don't think any of these can really take it up with Lilypond though (which, incidentally, started out as a LaTeX package too, but became standalone when it was determined that music typesetting diverges from standard document typesetting in too many ways for this to be a really practical approach). Dec 21, 2015 at 18:09
-
7As a LaTeX professional and an avid LilyPond user, I have to afree with @leftaroundabout that LaTeX is not really suitable for typesetting music.– yo'Dec 21, 2015 at 20:30
As mentioned previously, LilyPond might meet your specifications. For one thing, its input is text form, something which some people equate with "programming" (for example, the answer proposing MusicXML does not make any sense without that assumption). For another, one of its implementation languages is Scheme (more exactly, Guile), and Scheme is immediately accessible in its source files as an extension language useful for algorithmic programming. One example of mixing music and programming is in this unrelated answer to a StackExchange question.
Sorry for not linking to LilyPond and Guile, but my reputation allows only for 2 links, so I had to be selective.
MusicXML, in any text editor, is my favorite way to "code" music. A tutorial can be found here. When your code is complete, you can import it into almost any music editing software such as MuseScore, Sibelius, or Noteflight.
An older option is MUP, which has been kicking around since 1995 and is now open-source freeware. It takes in an input file that looks like this and outputs a PostScript file that looks like this.
Note, however, that PostScript is something of an older file format, and you may need to download an extra piece of software to view the files and/or convert them to a different format. On Mac OS, the built-in "Preview" application will do it, but I'm not sure what the equivalent software would be on a Windows or Linux system.
-
1Postscript is not an 'older file format'. It is undwrstood directly by many current printers and can be converted directly to PDF. Dec 21, 2015 at 21:03
-
1@EJP: you're right that PS is not obsolete, but I would argue that it is currently much, much less common than PDF (which is basically now the de facto standard for so-called "fixed-format" printer-ready documents.) Postscript is also literally an old format, having been first introduced 33 years ago. Dec 21, 2015 at 21:27
-
Ghostscript works fairly well for this, including conversion to PDF.– user16935Dec 21, 2015 at 22:23
Trinket allows you to write music with code. It's rather small at the moment but it works well for smaller projects. I haven't noticed any development though in the last few months so I'm not sure if they mean to continue it.