Deutsches Lilypond Forum (Archiv)
Allgemein => Fragen zu Funktionen => Thema gestartet von: erich am Mittwoch, 6. April 2016, 11:02
-
Hallo allen
Das Script
\version "2.18.2"
note_chord =
#(define-music-function (parser location music)
(ly:music?)
(music-map
(lambda (music)
(if (eq? (ly:music-property music 'name) 'NoteEvent)
(begin (display-scheme-music music) music)
music)
)
music
) )
\score {
<<
\new Voice \note_chord{ e <e>}
>>
}
protokolliert mir
(make-music
'NoteEvent
'pitch
(ly:make-pitch -1 2 0)
'duration
(ly:make-duration 2 0 1))
(make-music
'NoteEvent
'duration
(ly:make-duration 2 0 1)
'pitch
(ly:make-pitch -1 2 0))
Die Darstellungen der NoteEvents unterscheiden sich also nur in der Reihenfolge von pitch und duration
Ich möchte gerne nur die echten NoteEvents weiterbehandeln können, also nicht diejenigen, die Teil eines EventChords sind; wie kann man diese rausfischen?
Gruß
Erich
-
\version "2.18.2"
note_chord =
#(define-music-function (parser location music)
(ly:music?)
(for-each
(lambda (m)
(cond ((eq? (ly:music-property m 'name) 'EventChord)
m)
((eq? (ly:music-property m 'name) 'NoteEvent)
(begin (display-scheme-music m) m))
(else m)))
(ly:music-property music 'elements))
music)
\score {
<<
\new Voice \note_chord { e <e> }
>>
}
HTH,
Harm
-
Hallo Harm,
bei der Suche nach der Erklärung was for-each macht, fand ich map-in-order, die mir für mein Anliegen geeigneter schien, da for-each kein Ergebnis abliefert.
Ich bin dann zu folgendem Script gelangt:
\version "2.18.2"
note = {c''}
note_chord =
#(define-music-function (parser location music)
(ly:music?)
(set! (ly:music-property music 'elements)
(map-in-order
(lambda (m)
(cond ((eq? (ly:music-property m 'name) 'EventChord)
m)
((eq? (ly:music-property m 'name) 'NoteEvent)
note)
(else m)))
(ly:music-property music 'elements)
)
)
music)
\score {
<<
\new Voice \note_chord{ e' <e'> }
>>
}
Die Ausgabe der anderen Note c'' dient also nur dazu, die lokale Veränderung der eingegebenen Noten zu demonstrieren.
Danke für Deine Hilfe
Gruß
Erich