The Net is a surprisingly vast place. Did you ever hit this link?

http://web.mit.edu/music21/

It's a Python library that, among musicological tasks, features
import from a dozen of different file formats, including MusicXML,
MIDI and ABC, as well as export to LilyPond.

Performing the conversion seems to be as simple as

from music21 import *
converter.parse('/path/to/input.[ext]').write('lilypond', '/path/to/output.ly')

I have been unsuccessfully trying to show `make check` output when
using this converter…  See the dev/jas/test-music21-2 branch in case
you're interested. Anyway, here is a simple ABC file:

X:1
T:Notes
M:C
L:1/4
K:C
C, D, E, F,|G, A, B, C|D E F G|A B c d|e f g a|b c' d' e'|f' g' a' b'|]

Attached are four LilyPond files. Two of them are produced using abc2ly
and music21. The remaining two are the result of processing music21
MusicXML output via musicxml2ly and xml2ly.

Neither option is perfect; the xml2ly route seems to do the best job though.

I'm running out of time for LilyPond right now, but I wanted to mention this
thing. Maybe we can make a good anything2ly converter out of it, possibly
pairing its MusicXML support with xml2ly. Being a Python library makes it
easy to include in Frescobaldi.

Cheers,
Jean -- in a puzzled state of mind.

\version "2.7.40"
\header {
	crossRefNumber = "1"
	footnotes = ""
	tagline = "Lily was here 2.21.6 -- automatically converted from ABC"
	title = "Notes"
}
voicedefault =  {
\set Score.defaultBarType = ""

 \override Staff.TimeSignature #'style = #'C
 \time 4/4 \key c \major   c4    d4    e4    f4  \bar "|"   g4    a4    b4    
c'4  \bar "|"   d'4    e'4    f'4    g'4  \bar "|"   a'4    b'4    c''4    d''4 
 \bar "|"   e''4    f''4    g''4    a''4  \bar "|"   b''4    c'''4    d'''4    
e'''4  \bar "|"   f'''4    g'''4    a'''4    b'''4  \bar "|."   
}

\score{
    <<

	\context Staff="default"
	{
	    \voicedefault 
	}

    >>
	\layout {
	}
	\midi {}
}
\version "2.21" 
\include "lilypond-book-preamble.ly"
    
color = #(define-music-function (parser location color) (string?) #{
        \once \override NoteHead #'color = #(x11-color color)
        \once \override Stem #'color = #(x11-color color)
        \once \override Rest #'color = #(x11-color color)
        \once \override Beam #'color = #(x11-color color)
     #})
    
\header { 
 title = "Notes"   
  
  } 
 
\score  { 
 
      << \new Staff  = xzffddcfdfwwbcw \with  { 
         \autoBeamOff 
          } 
          { \clef "treble" 
             \key c \major 
             \time 4/4
             c 4  
             d 4  
             e 4  
             f 4  
             \bar "|"  %{ end measure 0 %} 
             g 4  
             a 4  
             b 4  
             c' 4  
             \bar "|"  %{ end measure 1 %} 
             d' 4  
             e' 4  
             f' 4  
             g' 4  
             \bar "|"  %{ end measure 2 %} 
             a' 4  
             b' 4  
             c'' 4  
             d'' 4  
             \bar "|"  %{ end measure 3 %} 
             e'' 4  
             f'' 4  
             g'' 4  
             a'' 4  
             \bar "|"  %{ end measure 4 %} 
             b'' 4  
             c''' 4  
             d''' 4  
             e''' 4  
             \bar "|"  %{ end measure 5 %} 
             f''' 4  
             g''' 4  
             a''' 4  
             b''' 4  
             \bar "|."  %{ end measure 6 %} 
              } 
            
 
        >>
      
  } 
 
\paper { }
\layout {
  \context {
    \RemoveEmptyStaffContext
    \override VerticalAxisGroup #'remove-first = ##t
  }
 }
 
\version "2.21.6"
% automatically converted by musicxml2ly from test.xml
\pointAndClickOff

\header {
    title =  Notes
    subtitle =  Notes
    composer =  "Music21"
    encodingsoftware =  "music21 v.6.1.0"
    encodingdate =  "2020-09-13"
    }

#(set-global-staff-size 20.0)
\paper {
    
    }
\layout {
    \context { \Score
        autoBeaming = ##f
        }
    }
PartPbSixNineThreefOneeOneeTwoFourEightTwoThreeSixEightZerocZerocEightEightOneEightNineacaOneFoureaVoiceOne = 
\relative c {
    \clef "treble" \numericTimeSignature\time 4/4 \key c \major c4 d4 e4
    f4 | % 1
    g4 a4 b4 c4 | % 2
    d4 e4 f4 g4 | % 3
    a4 b4 c4 d4 | % 4
    e4 f4 g4 a4 | % 5
    b4 c4 d4 e4 | % 6
    f4 g4 a4 b4 \bar "|."
    }


% The score definition
\score {
    <<
        
        \new Staff
        <<
            
            \context Staff << 
                \mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
                \context Voice = "PartPbSixNineThreefOneeOneeTwoFourEightTwoThreeSixEightZerocZerocEightEightOneEightNineacaOneFoureaVoiceOne" {  \PartPbSixNineThreefOneeOneeTwoFourEightTwoThreeSixEightZerocZerocEightEightOneEightNineacaOneFoureaVoiceOne }
                >>
            >>
        
        >>
    \layout {}
    % To create MIDI output, uncomment the following line:
    %  \midi {\tempo 4 = 100 }
    }

\version "2.19.83"

% Comment or adapt next line as needed (default is 20)
#(set-global-staff-size 20)

\header {
  title              = "Notes"
  subtitle           = "Notes"
  composer           = "Music21"
  software           = "music21 v.6.1.0"
  miscellaneousField = "1"
}

\paper {
  paper-height                   = 297\mm
  paper-width                    = 210\mm
  
  %left-margin                    = 0.0\mm
  %right-margin                   = 0.0\mm
  %top-margin                     = 0.0\mm
  %bottom-margin                  = 0.0\mm
  
  %horizontal-shift               = 0.0\mm
  %indent                         = 0.0\mm
  %short-indent                   = 0.0\mm
  
  %markup-system-spacing.padding  = 0.0\mm
  %between-system-space           = 0.0\mm
  %page-top-space                 = 0.0\mm
  
  %page-count                     = -1
  %system-count                   = -1
  
  oddHeaderMarkup                = ""
  evenHeaderMarkup               = ""
  oddFooterMarkup                = ""
  evenFooterMarkup               = ""
}

\layout {
  \context {
    \Score
    autoBeaming = ##f % to display tuplets brackets
  }
  \context {
    \Voice
  }
}

% Pick your choice from the next two lines as needed
myBreak = { \break }
%myBreak = { }

% Pick your choice from the next two lines as needed
myPageBreak = { \pageBreak }
%myPageBreak = { }

Part_PbSixHundredAndNinetyThreefOneeOneeTwentyFourThousandEightHundredAndTwentyThreeThousandSixHundredAndEightyZerocZerocEightyEightThousandOneHundredAndEightyNineacaFourteenea_Staff_One_Voice_One = \absolute {
  \language "nederlands"
  \key c \major
  \numericTimeSignature \time 4/4
  
  \clef "treble"
  c4 d e f | % 2
  \barNumberCheck #2
  g4 a b c' | % 3
  \barNumberCheck #3
  d'4 e' f' g' | % 4
  \barNumberCheck #4
  a'4 b' c'' d'' | % 5
  \barNumberCheck #5
  e''4 f'' g'' a'' | % 6
  \barNumberCheck #6
  b''4 c''' d''' e''' | % 7
  \barNumberCheck #7
  f'''4 g''' a''' b'''
  \bar "|."
  | % 8
  \barNumberCheck #8
}

\book {
  \header {
  }
  
  \score {
    <<
      
      \new Staff = "Part_PbSixHundredAndNinetyThreefOneeOneeTwentyFourThousandEightHundredAndTwentyThreeThousandSixHundredAndEightyZerocZerocEightyEightThousandOneHundredAndEightyNineacaFourteenea_Staff_One"
      \with {
      }
      <<
        \context Voice = "Part_PbSixHundredAndNinetyThreefOneeOneeTwentyFourThousandEightHundredAndTwentyThreeThousandSixHundredAndEightyZerocZerocEightyEightThousandOneHundredAndEightyNineacaFourteenea_Staff_One_Voice_One" <<
          \Part_PbSixHundredAndNinetyThreefOneeOneeTwentyFourThousandEightHundredAndTwentyThreeThousandSixHundredAndEightyZerocZerocEightyEightThousandOneHundredAndEightyNineacaFourteenea_Staff_One_Voice_One
        >>
      >>
      
    >>
    
    \layout {
      \context {
        \Score
        autoBeaming = ##f % to display tuplets brackets
      }
      \context {
        \Voice
      }
    }
    
    \midi {
      \tempo 4 = 90
    }
  }
  
  \paper {
    paper-height                   = 297\mm
    paper-width                    = 210\mm
    
    %left-margin                    = 0.0\mm
    %right-margin                   = 0.0\mm
    %top-margin                     = 0.0\mm
    %bottom-margin                  = 0.0\mm
    
    %horizontal-shift               = 0.0\mm
    %indent                         = 0.0\mm
    %short-indent                   = 0.0\mm
    
    %markup-system-spacing.padding  = 0.0\mm
    %between-system-space           = 0.0\mm
    %page-top-space                 = 0.0\mm
    
    %page-count                     = -1
    %system-count                   = -1
    
    oddHeaderMarkup                = ""
    evenHeaderMarkup               = ""
    oddFooterMarkup                = ""
    evenFooterMarkup               = ""
  }
  
}

Reply via email to