Hi,
ich habe folgendes Problem. Ich habe eine define-markup-command-Funktion definiert und möchte deren Ergebnisse in einer markuplist-table anordnen.
Derzeit habe ich folgenden Code produziert:
\version "2.19.83"
\language "deutsch"
#(define (music-elts x)
(if (not (ly:music? x))
'()
(ly:music-property x 'elements)))
#(define (music-name x)
(if (not (ly:music? x))
#f
(ly:music-property x 'name)))
#(define (list-all-chords-from-music music)
;; each element of the list is ly:music
(reverse!
(let loop ((music music) (pitches '()))
(let ((p (music-name music)))
(if (eq? p 'EventChord)
(cons music pitches)
(let ((elt (ly:music-property music 'element)))
(fold loop
(if (ly:music? elt)
(loop elt pitches)
pitches)
(music-elts music))))))))
#(define-markup-command (chord-symbol layout props mus)
(ly:music?)
(interpret-markup layout props
#{
\markup \score {
\new Staff
{
$mus \bar "||"
}
\layout {
line-width = #50
}
}
#}))
%% diese Funktion sollte als Input eine Folge von Akkorden verarbeiten
%% und eine Markup-Liste ausgeben
%% wahrscheinlich ist hier irgendwo ein Hund begraben ;-)
#(define-markup-list-command (my-markuplist layout props args) (ly:music?)
(map
(lambda (chord)
chord-symbol chord)
(list-all-chords-from-music args))
)
mychords = \chordmode { c1 d e }
\markuplist #my-markuplist ##{ \mychords #} %% funktioniert nicht mit div. Fehlermeldungen
%% das Ergebnis soll so ausschauen wie hier:
\markuplist {
\table
#'(1 1 1)
{
\chord-symbol ##{ \chordmode { c1 } #}
\chord-symbol ##{ \chordmode { d1 } #}
\chord-symbol ##{ \chordmode { e1 } #}
}
}
Hallo,
zwei Probleme:
(1) Ein markup-list-command muß eine stencil-list ausgeben, keine markup-list.
D.h. (interpret-markup-list layou props markup-list)
(2) 'chord-symbol' ist ein markup-command.
In scheme-syntax verwende (make-chord-symbol-markup ...) oder in ly-syntax #{ \markup \chord-symbol ... #}
Außerdem habe ich 'list-all-chords-from-music' raus geworfen 'extract-named-music' tuts hier genauso.
\version "2.19.83"
#(define-markup-command (chord-symbol layout props mus)
(ly:music?)
(interpret-markup layout props
#{
\markup \score {
\new Staff
{
$mus \bar "||"
}
\layout {
line-width = #50
%% NB
indent = 0
}
}
#}))
#(define-markup-list-command (my-markuplist layout props args) (ly:music?)
(interpret-markup-list layout props
(map
(lambda (chord)
(make-chord-symbol-markup chord)
;; or ly-Syntax:
;#{ \markup \chord-symbol #chord #}
)
(extract-named-music args 'EventChord))))
%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%
mychords = \chordmode { c1 d e }
myChordList = \markuplist \my-markuplist ##{ \mychords #}
\markup \line { "markup" \myChordList }
\markup \draw-hline
\markup
\override #'(word-space . 10)
\line { "markup increased word-space" \myChordList }
\markup \draw-hline
\markuplist { "simple markuplist" \my-markuplist ##{ \mychords #} }
\markup \draw-hline
mychordsII = \chordmode { c1 d c1 d c1 d c1 d c1 d c1 d c1 d c1 d c1 d c1 d
c1 d c1 d c1 d c1 d c1 d c1 d c1 d c1 d }
\markuplist
\column-lines { "markuplist wordwrap-lines"
\wordwrap-lines \my-markuplist ##{ \mychordsII #}
}
\markup \draw-hline
mychordsIII = \chordmode { c1 d c1 d c1 d c1 d }
\markuplist
\table
#'(1 1 1)
{ "markuplist table" "" "" \my-markuplist ##{ \mychordsIII #} }
HTH,
Harm
Danke Harm, ich weiß keine Superlative mehr :) ;)
Und wieder scheitere ich...
Ich möchte als zusätzlichen Parameter einen pitch einbauen, der das ganze transponieren soll.
\version "2.19.83"
\language "deutsch"
#(define-markup-command (chord-symbol layout props mus)
(ly:music?)
(interpret-markup layout props
#{
\markup \score {
\new Staff
{
$mus \bar "||"
}
\layout {
line-width = #50
%% NB
indent = 0
}
}
#}))
#(define-markup-list-command (my-markuplist layout props args) (ly:music?)
(interpret-markup-list layout props
(map
(lambda (chord)
(make-chord-symbol-markup chord)
)
(extract-named-music args 'EventChord))))
mychords = \chordmode { c1 d e }
#(define-markup-list-command (more-markuplist layout props mus p)
(ly:music? ly:pitch?)
#{
\markuplist
\table
#'(1 1 1)
{ \my-markuplist \transpose c $p $mus }
#}
)
\markuplist \more-markuplist ##{ \mychords #} ##{ d #} %% funktioniert nicht
Du hast das mit (interpret-markup-list layout props ...) vergessen ;)
Außerdem erwartet \table eine Liste als zweites Argument, da my-markuplist aber schon eine Liste zurüchgibt, steht da jetzt eine geschachtelte Liste. Mit anderen Worten ein {}-Paar zu viel.
Außerdem muß ein Musik-argument mittels ##{ ...#}-Syntax an ein markup-(list-)command übergeben werden, zumindest solange Du in ly-syntax bist.
Also:
#(define-markup-list-command (more-markuplist layout props mus p)
(ly:music? ly:pitch?)
(interpret-markup-list layout props
#{
\markuplist
\table
#'(1 1 1)
\my-markuplist ##{ \transpose c $p $mus #}
#}))
HTH,
Harm
Danke für deine Geduld, Harm!
Zitat von: harm6 am Sonntag, 1. März 2020, 15:59
Du hast das mit (interpret-markup-list layout props ...) vergessen ;)
Das habe ich auch probiert, jedoch ohne Erfolg (wegen der anderen Fehler) ;)