Selected Topics

Proposal for a new method of Generating Lilypond Files from ABC files

My original methodology is described below, and I will continue to use it until this effort proves to do a better job. Conceptually, it involves creating an intermediate file(s) from the source document with a consistent, easily-read format (i.e. descriptive english), then running a second process to convert it to lilypond format. The idea here is that we can seperate issues reading/translating input files from conversion to and writing the output file format. It will provide for easier troubleshooting, and should provide a consistent platform for other file formats, if desired. FF_ST_NewLilypondFromABC.html

Generating Lilypond Files from ABC files

Lilypond provides a set of python scripts to import/export files from/to various file formats. One of them is abc2ly. This page describes my experiences with this script, and how to work around the deficiencies.

The abc2ly script is command-line based, so you have to open a terminal window first. Then, issue the following;

	abc2ly -o filename.abc
      

Description: The -o option generates an output file (same name as the source).

Complications:

  • Python (I'm guessing it's python causing the problem...) doesn't understand spaces in windows filenames. The easiest fix for this is to copy the abc file, replacing the spaces with underscores ('_').
  • abc2ly doesn't understand the abc method of indicating acciaccatura grace notes (the ones with the little lines through them...), which is to follow the { with a / (i.e. '{/' ). The best thing to do here is to simply delete the offending /'s! The grace notes can be fixed up properly later in the .ly file.
  • Likewise, abc2ly doesn't seem to undestand what to do with expression symbols, eg. '!trill!' and '!breath!'. Just delete them (from the abc file), and add them back in later in the ly file.
  • abc2ly provides the -b option, which allows us to preserve the 'beam' pattern of the abc file, instead of relying on lilypond's defaults. The problem wiht this is that abc will happily ignore 1/4 notes that are placed together (the method used to arrange beaming for 1/8th notes and smaller), abc2ly also happily transliterates the placement into beaming symbols ('[' and ']'). While Lilypond ignores incorrect beaming requests like this, when applied to 1/4 notes and longer, it complains vociferously in the log file. And while this is not a major problem, it does make finding real errors in the log file difficult. My suggestion is to rely on Lilypond's auto-beaming feature (i.e. don't use -b in abc2ly), unless it doesn't give you satisfactory results. If you do use -b, you probably will have to go in and clean up either the abc file or the .ly file to mollify the error trapping.
  • whoever wrote abc2ly decided to transliterate the abc '|' symbol to '\bar "|"' in .ly . While functionally correct (abc doesn't have a notion of bar checking), this ignores the benefit of the bar checking in Lilypond. My recommendation is to do a global search and replace of the '\bar "|"' to change them to "|" .
  • abc2ly generates chords in lilypond by generating 'text scripts' in the form: '^"G"'. This actually works well, in that it doesn't insert any new notes into the score. It does, however, mean that the placement of the chord symbols is subject to the note leger lines moving up and down, so the position of the chord letters is not fixed - they wander up and down, instead of being at some fixed level. Lilypond is actually quite intelligent about 'real' chords (i.e. not 'text scripts'). In 'chord mode', you can give it a series of notes, and it will extract the correct chord name for you, and even provide fret diagrams, etc. It's a lot of work, though - you have to encode each chord as a series on notes. Best to put up with the wandering letters.
  • abc2ly doesn't know quite what to do with some of the abc header constructs. Actually, it's ABC that doesn't work well for me, so I have sometimes cheated... the composer command actually does work, but some of the abc utilities move it around from the top right-hand location, so in many of my abc files I have used the O: (origin) construct to indicate 'trad - FF Version'. This needs to be changed (when it occurs) in the .ly file to 'composer'.
  • Other things to do in the .ly header;
    • delete the 'crossRefNumber'. This is brought in by the X: command, and serves no useful purpose in Lilypond (I checked).
    • any footnotes (brought in by the N: command) need to be moved to a '\markup{notes}' section (can be tacked on at the end).
    • change the tagline to "the Fumblin' Fingers score version nnnnnnn - Music Engraving by Lilypond".
    • include the tune's rhythm description as a 'meter = "rhythm_description"' construct.
    • include the tune's 8-bar phrase structure (if available) as a 'piece = "AABBAB" construct (this puts it in the upper left corner of the page, where we expect it...)

Almost all of the details outlined in the box to the right are taken care of by using the perl script "wdm_abc2ly.pl", but first I use "wdm_abcsplit.pl" to pull out the extra tunes from an abc file and create individual files for each. This process takes care of multiple tunes in an ABC file by creating individual .abc files for each, and then processing each individually. This does mean that the multiple .ly files that result will have to be combined by hand when done. This is not too much of a hassle, since a certain amount of hand-tweaking has to be done anyway, such as stripping out all the chord names into a chord-mode section.

Note that originally I used these scripts to process both FF- and var- files, until I realized that I really didn't need the hassle of having to post-process all those var- variant files into one. When you think about it, I don't really need the var- files in squeeky-clean lilypond format anyway - keep them in abc format is fine.


Copyright © 2007 Wayne Mercer.

~ FF_ST_LilypondFromABC.html ~   Created: 8 Nov, 2007   last modified on 09:05:44 07-Oct-2022