[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Ambitus
From: |
Neil Puttock |
Subject: |
Re: Ambitus |
Date: |
Mon, 1 Feb 2010 21:41:36 +0000 |
On 31 January 2010 20:01, Reinhold Kainhofer <address@hidden> wrote:
> You can write your own engraver that listens to the note-event rather than the
> created NoteHead grobs. There, you can easily extract the pitch...
Of course! Though there's still the problem of how to funnel the
pitch information to a title markup...
As an alternative, it's possible to use a music function to grab the
pitches; since it's easy to store this information in a global
identifier, there's no problem in getting the ambitus information into
a \header block (so long as the header comes after the \score).
\version "2.13.12"
pitches = #'()
extractAmbitus =
#(define-music-function (parser location music) (ly:music?)
"Extract the pitches from MUSIC, then sort lexicographically.
Stores sorted pitch list in `pitches' variable for later use."
(music-map
(lambda (m)
(if (memq 'note-event (ly:music-property m 'types))
(set! pitches (cons (ly:music-property m 'pitch) pitches)))
m)
music)
(set! pitches (stable-sort pitches ly:pitch<?))
music)
\pageBreak
voice = \extractAmbitus \relative c' {
c4 b c d
e4 g c2
}
\score {
\voice
}
\header {
title = "The ambitus for the music on the next page:"
subtitle = \markup \score {
\new Staff {
\time 2/4
<\withMusicProperty #'pitch #(first pitches) c>4
<\withMusicProperty #'pitch #(last pitches) c>4
}
\layout {
indent = 0
\context {
\Staff
\remove "Time_signature_engraver"
}
}
}
}
Regards,
Neil
- Re: Ambitus,
Neil Puttock <=