Petri Moilanen <petri.moila...@newentures.com> writes:

> Can Lilypond be used to import xml piano sheet music

XML import quality is so-so.  Expect to hand-edit afterwards.

> and then run a snippet which will calculate a relative position for
> each note against middle c and output the same back as pdf having the
> number added below each note on the right and left staff ? The middle
> c would start from 1 and then b would be -1.
>
> I would like to automate the process so that I could run a command
> from the command line to process several xml files in a batch.
>
> If this cannot be done using a snippet, what other alternatives one
> could have ?

This is a basic engraver application:

\version "2.18.0"

scale-nos =
#(lambda (c)
  (let ((notes '()))
   (make-engraver
    (listeners ((note-event this note)
		(let ((p (ly:event-property note 'pitch)))
		 (if (ly:pitch? p)
		  (set! notes (cons (ly:pitch-steps p) notes))))))
    ((process-acknowledged this)
     (if (pair? notes)
      (let ((grob (ly:engraver-make-grob this 'TextScript '())))
       (set! (ly:grob-property grob 'text)
	#{ \markup \center-align \override #'(baseline-skip . 1.5)
	   \right-column
	   \finger #(map number->string (sort notes >)) #})
       (set! (ly:grob-property grob 'parent-alignment-X) CENTER)
       (set! notes '())))))))

\new Staff \with { \consists \scale-nos }
{
  \partial 8 c'8 | <c' e' g>2. r8
  c'8 | <c' e' g'> 2. r8
  c'8 | <c'' e' g'>1 | \bar "|."
}
-- 
David Kastrup
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to