Am Freitag, 29. Januar 2010 18:09:25 schrieb Ewald Gutenkunst:
> My hope: there is a internal variable, which represents the actual
>  music-moment for each event.

Thanks to Han-Wen's new scheme engraver possibilities, you can now implement 
your own engraver (in this case it's simply a listener) in Scheme, which just 
listens for all note and rest events and prints them out to the console as 
they are caught (they are already in the correct time order)...

Attached is a simple example (actually just the regtest stripped down a little 
and adjusted where needed), where I don't bother to nicely format the 
duration/pitch. Currently, the duration/pitch is simply dumped as it is. In 
your case, you probably want to print it out in a format that can be read into 
your favorite statistics program. I'll leave that up to you ;-) 

Cheers,
Reinhold

PS: Wouldn't it be great to have a simple statistics engraver, which only 
counts how many notes, rests, articulations, etc. a score has?
-- 
------------------------------------------------------------------
Reinhold Kainhofer, reinh...@kainhofer.com, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
\version "2.13.11"

%%%% Helper functions, which simply print out the observed rest/note events
%%%% in a nice format:
#(define (format-rest engraver event)
  (let* ((context (ly:translator-context engraver))
         (moment (ly:context-current-moment context))
         (duration (ly:event-property event 'duration)))
    ; TODO: Format the duration and the moment
    (ly:message "REST event of duration ~a at ~a\n" duration moment)
    ; or dump the whole event to see what information is available:
    ; (ly:message "REST event at ~a: ~a\n" moment event)
  )
)

#(define (format-note engraver event)
  (let* ((context (ly:translator-context engraver))
         (moment (ly:context-current-moment context))
         (duration (ly:event-property event 'duration))
         (pitch (ly:event-property event 'pitch)))
    ; TODO: Format the duration, pitch and the moment
    (ly:message "NOTE event of duration ~a, pitch ~a at ~a\n" duration pitch moment)
    ; or dump the whole event to see what information is available:
    ; (ly:message "NOTE event at ~a: ~a\n" moment event)
  )
)


%%%% The actual engraver definition: We just install some listeners so we
%%%% are notified about all notes and rests. We don't create any grobs or
%%%% change any settings.

\layout {
  \context {
    % I add this to the score, so all voices are caught. You can also only add
    % the engraver to selected voices to get the statistics split down.
    \Score
    \consists
    #(list
      (cons 'listeners
       (list
        (cons 'rest-event format-rest)
        (cons 'note-event format-note)
       ))
    )
  }
}


\relative c' {
  c8[ r c]
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to