On 2021-04-23 1:58 am, Jean Abou Samra wrote:
If you have it at hand in Scheme:
\version "2.23.
#(define (first-element music)
(first (ly:music-property music 'elements)))
{ #(first-element #{ { c'1 } #}) }
It would be helpful to understand your use
case; this sounds like you may not necessarily
need to unpack a sequential music expression.
In my usual fashion, here's an over-engineered option showing off some
of the built-in functions in an easily extensible pattern:
%%%%
\version "2.22.0"
extract =
#(define-music-function
(which what music)
(symbol? symbol? ly:music?)
(let ((extracted (extract-typed-music music what)))
(case which
((first) (first extracted))
((last) (last extracted))
((all all-as-sequence) (make-sequential-music extracted))
((all-as-chord) (make-event-chord extracted))
(else (ly:input-warning (*location*)
"\\extract does not understand '~s'" which)
music))))
foo = { c <e g> }
\fixed c' {
\extract first event-chord \foo
\extract last note-event \foo
\extract all note-event \foo
\extract all-as-chord note-event \foo
}
%%%%
-- Aaron Hill